mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-21 08:41:58 -04:00
Game.cpp and World.cpp Cleanup (#159)
* Remove CProperties and delete dup Properties from World.h * Improvement * Fix compile * Cleanup * Document gRaceState * wip cleanup * compile * Impl PlayerBombKart * Rename CourseManager_ to CM_ * Finish renames m_ to CM_ * cleanup * Remove extra printf --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <libultraship.h>
|
||||
#include "engine/objects/Object.h"
|
||||
#include "BombKart.h"
|
||||
#include <vector>
|
||||
|
||||
@@ -71,15 +72,9 @@ OBombKart::OBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex,
|
||||
WheelPos[3][2] = _pos[2];
|
||||
check_bounding_collision(&_Collision, 2.0f, _pos[0], _pos[1], _pos[2]);
|
||||
|
||||
_count++;
|
||||
}
|
||||
|
||||
void OBombKart::Spawn() {
|
||||
find_unused_obj_index(&ObjectIndex);
|
||||
}
|
||||
|
||||
void OBombKart::BeginPlay() {
|
||||
|
||||
_count++;
|
||||
}
|
||||
|
||||
void OBombKart::Tick() {
|
||||
@@ -332,8 +327,21 @@ void OBombKart::Tick() {
|
||||
}
|
||||
|
||||
void OBombKart::Draw(s32 cameraId) {
|
||||
|
||||
if (gModeSelection == BATTLE) {
|
||||
for (size_t playerId = 0; playerId < NUM_BOMB_KARTS_BATTLE; playerId++) {
|
||||
Object* object = &gObjectList[ObjectIndex];
|
||||
if (object->state != 0) {
|
||||
s32 primAlpha = object->primAlpha;
|
||||
Player* player = &gPlayerOne[playerId];
|
||||
object->pos[0] = player->pos[0];
|
||||
object->pos[1] = player->pos[1] - 2.0;
|
||||
object->pos[2] = player->pos[2];
|
||||
object->surfaceHeight = player->unk_074;
|
||||
func_800563DC(ObjectIndex, cameraId, primAlpha);
|
||||
func_8005669C(ObjectIndex, cameraId, primAlpha);
|
||||
func_800568A0(ObjectIndex, cameraId);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -345,15 +353,10 @@ void OBombKart::Draw(s32 cameraId) {
|
||||
}
|
||||
}
|
||||
|
||||
Camera* camera;
|
||||
s32 temp_s4;
|
||||
s32 i;
|
||||
s32 state;
|
||||
|
||||
if (gGamestate == ENDING) {
|
||||
cameraId = 0;
|
||||
}
|
||||
camera = &camera1[cameraId];
|
||||
Camera* camera = &camera1[cameraId];
|
||||
if (cameraId == PLAYER_ONE) {
|
||||
if (is_obj_flag_status_active(ObjectIndex, 0x00200000) != 0) {
|
||||
Unk_4A = 0;
|
||||
@@ -364,12 +367,12 @@ void OBombKart::Draw(s32 cameraId) {
|
||||
}
|
||||
|
||||
// huh???
|
||||
state = State;
|
||||
s32 state = State;
|
||||
if (State != States::DISABLED) {
|
||||
gObjectList[ObjectIndex].pos[0] = Pos[0];
|
||||
gObjectList[ObjectIndex].pos[1] = Pos[1];
|
||||
gObjectList[ObjectIndex].pos[2] = Pos[2];
|
||||
temp_s4 = func_8008A364(ObjectIndex, cameraId, 0x31C4U, 0x000001F4);
|
||||
s32 temp_s4 = func_8008A364(ObjectIndex, cameraId, 0x31C4U, 0x000001F4);
|
||||
if (is_obj_flag_status_active(ObjectIndex, VISIBLE) != 0) {
|
||||
set_object_flag(ObjectIndex, 0x00200000);
|
||||
D_80183E80[0] = 0;
|
||||
@@ -385,28 +388,7 @@ void OBombKart::Draw(s32 cameraId) {
|
||||
}
|
||||
|
||||
void OBombKart::DrawBattle(s32 cameraId) {
|
||||
if (gModeSelection != BATTLE) {
|
||||
return;
|
||||
}
|
||||
Player* temp_v0;
|
||||
s32 temp_s1;
|
||||
s32 playerId;
|
||||
Object* object;
|
||||
|
||||
for (playerId = 0; playerId < gPlayerCount; playerId++) {
|
||||
object = &gObjectList[ObjectIndex];
|
||||
if (object->state != 0) {
|
||||
temp_s1 = object->primAlpha;
|
||||
temp_v0 = &gPlayerOne[playerId];
|
||||
object->pos[0] = temp_v0->pos[0];
|
||||
object->pos[1] = temp_v0->pos[1] - 2.0;
|
||||
object->pos[2] = temp_v0->pos[2];
|
||||
object->surfaceHeight = temp_v0->unk_074;
|
||||
func_800563DC(ObjectIndex, cameraId, temp_s1);
|
||||
func_8005669C(ObjectIndex, cameraId, temp_s1);
|
||||
func_800568A0(ObjectIndex, cameraId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OBombKart::SomeRender(Vec3f arg1) {
|
||||
@@ -455,10 +437,6 @@ void OBombKart::Waypoint(s32 screenId) {
|
||||
playerHUD[screenId].unk_74 = 1;
|
||||
}
|
||||
|
||||
void OBombKart::Collision(s32 playerId, Player* player) {
|
||||
|
||||
}
|
||||
|
||||
Player* OBombKart::FindTarget() {
|
||||
for (size_t i = 0; i < NUM_PLAYERS; i++) {
|
||||
if (gPlayers[i].type & PLAYER_HUMAN) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <libultraship.h>
|
||||
#include "src/engine/vehicles/Vehicle.h"
|
||||
#include "engine/objects/Object.h"
|
||||
#include <vector>
|
||||
#include "engine/Matrix.h"
|
||||
|
||||
@@ -22,8 +22,8 @@ extern "C" {
|
||||
* This differs from the other vehicle classes in that it does not get added to the standard actor list
|
||||
* So this is sort of its own thing. Draw call in different place too.
|
||||
*/
|
||||
class OBombKart {
|
||||
private:
|
||||
class OBombKart : public OObject {
|
||||
public:
|
||||
enum States : uint16_t { // 0,1,3,5
|
||||
DISABLED,
|
||||
CCW,
|
||||
@@ -34,8 +34,6 @@ private:
|
||||
PODIUM_CEREMONY,
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
const char* Type;
|
||||
|
||||
Vec3f Pos;
|
||||
@@ -63,12 +61,9 @@ public:
|
||||
return _count;
|
||||
}
|
||||
|
||||
void Spawn();
|
||||
void BeginPlay();
|
||||
void Tick();
|
||||
void Draw(s32 cameraId);
|
||||
virtual void Tick() override;
|
||||
virtual void Draw(s32 cameraId) override;
|
||||
void DrawBattle(s32 cameraId);
|
||||
void Collision(s32 playerId, Player* player);
|
||||
void SomeRender(Vec3f arg1);
|
||||
void LoadMtx();
|
||||
void Waypoint(s32 screenId);
|
||||
|
||||
@@ -115,7 +115,6 @@ void OBoos::func_8007CA70(void) {
|
||||
if (_isActive == false) {
|
||||
_playerId = OBoos::func_8007C9F8();
|
||||
point = &gNearestWaypointByPlayerId[_playerId];
|
||||
printf("point %d\n", *point);
|
||||
if ((*point > _active.Start) && (*point < _active.End)) {
|
||||
// First group entrance
|
||||
OBoos::BooStart(0, _playerId);
|
||||
@@ -123,7 +122,6 @@ void OBoos::func_8007CA70(void) {
|
||||
}
|
||||
if (_isActive == true) {
|
||||
point = &gNearestWaypointByPlayerId[_playerId];
|
||||
printf("point %d\n", *point);
|
||||
|
||||
if ((*point > _leftBoundary.Start) && (*point < _leftBoundary.End)) {
|
||||
// First group exit reverse direction
|
||||
@@ -240,7 +238,6 @@ void OBoos::BooStart(s32 group, s32 playerId) {
|
||||
s16 temp_s4;
|
||||
s16 temp_s5;
|
||||
SplineData* spline;
|
||||
printf("Boo Start\n");
|
||||
for (size_t i = 0; i < _numBoos; i++) {
|
||||
objectIndex = _indices[i]; // indexObjectList3[group + i];
|
||||
init_object(objectIndex, 1);
|
||||
@@ -262,7 +259,6 @@ printf("Boo Start\n");
|
||||
|
||||
void OBoos::BooExit(s32 group) {
|
||||
s32 objectIndex;
|
||||
printf("Boo Exit\n");
|
||||
for (size_t i = 0; i < _numBoos; i++) {
|
||||
objectIndex = _indices[i]; //indexObjectList3[group + temp_a0];
|
||||
gObjectList[objectIndex].unk_0DC += 1;
|
||||
|
||||
@@ -160,12 +160,12 @@ void OLakitu::func_800791F0(s32 objectIndex, s32 playerId) {
|
||||
|
||||
if ((gObjectList[objectIndex].unk_0D8 != 3) && (gObjectList[objectIndex].unk_0D8 != 7)) {
|
||||
func_800722CC(objectIndex, 1);
|
||||
if (CourseManager_GetProps()->LakituTowType == LakituTowType::ICE) {
|
||||
if (CM_GetProps()->LakituTowType == LakituTowType::ICE) {
|
||||
player->unk_0CA &= 0xFFEF;
|
||||
}
|
||||
}
|
||||
|
||||
if (CourseManager_GetProps()->LakituTowType == LakituTowType::ICE) {
|
||||
if (CM_GetProps()->LakituTowType == LakituTowType::ICE) {
|
||||
func_800722CC(objectIndex, 0x00000010);
|
||||
player->unk_0CA &= 0xFFDF;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ void OLakitu::func_800797AC(s32 playerId) {
|
||||
objectIndex = gIndexLakituList[playerId];
|
||||
player = &gPlayerOne[playerId];
|
||||
//if ((GetCourse() == GetSherbetLand()) && (player->unk_0CA & 1)) {
|
||||
if ((CourseManager_GetProps()->LakituTowType == LakituTowType::ICE) && (player->unk_0CA & 1)) {
|
||||
if ((CM_GetProps()->LakituTowType == LakituTowType::ICE) && (player->unk_0CA & 1)) {
|
||||
init_object(objectIndex, 7);
|
||||
player->unk_0CA |= 0x10;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,6 @@ OObject::OObject() {}
|
||||
void OObject::Tick() { }
|
||||
void OObject::Tick60fps() {}
|
||||
void OObject::Draw(s32 cameraId) { }
|
||||
void OObject::Collision() {}
|
||||
void OObject::Expire() { }
|
||||
void OObject::Destroy() {
|
||||
PendingDestroy = true;
|
||||
|
||||
@@ -20,7 +20,6 @@ public:
|
||||
virtual void Tick();
|
||||
virtual void Tick60fps();
|
||||
virtual void Draw(s32 cameraId);
|
||||
virtual void Collision();
|
||||
virtual void Expire();
|
||||
virtual void Destroy(); // Mark object for deletion at the start of the next frame
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user