Start implementing LegoRaceCar (#1050)

* Implement several functions

* Limited match on LegoRaceCar::ParseAction

* WIP: progress in the right direction

* Implement LegoRaceCar::ParseAction()

* fix linter issues

* Address review comments

* fix naming

* fix naming (again)

* Relocate address annotations

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
This commit is contained in:
jonschz 2024-07-01 20:39:31 +02:00 committed by GitHub
parent fb34f86171
commit a21fd5975c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 112 additions and 22 deletions

View file

@ -128,6 +128,10 @@ const char* g_strWORLD = "WORLD";
// STRING: LEGO1 0x10101ed0
const char* g_strANIMMAN_ID = "ANIMMAN_ID";
// GLOBAL: LEGO1 0x101020d8
// STRING: LEGO1 0x10101ec8
const char* g_strCOMP = "COMP";
// GLOBAL: LEGO1 0x101020e0
// STRING: LEGO1 0x10101eb0
const char* g_strBMP_ISMAP = "BMP_ISMAP";

View file

@ -31,6 +31,7 @@ extern const char* g_strBOTTOM_TO_TOP;
extern const char* g_strTOP_TO_BOTTOM;
extern const char* g_strFILLER_INDEX;
extern const char* g_strVARIABLE;
extern const char* g_strCOMP;
extern const char* g_strBMP_ISMAP;
extern const char* g_strAUTO_CREATE;
extern const char* g_strDB_CREATE;

View file

@ -3,6 +3,7 @@
#include "decomp.h"
#include "legogamestate.h"
#include "legoracemap.h"
#include "legostate.h"
#include "legoworld.h"
#include "mxrect32.h"
@ -124,7 +125,7 @@ class LegoRace : public LegoWorld {
virtual MxLong HandleType0Notification(MxNotificationParam&) { return 0; } // vtable+0x78
// STUB: LEGO1 0x1000dac0
virtual void VTable0x7c(undefined4, undefined4) {} // vtable+0x7c
virtual void VTable0x7c(LegoRaceMap*, undefined4) {} // vtable+0x7c
// SYNTHETIC: LEGO1 0x10015cc0
// LegoRace::`scalar deleting destructor'

View file

@ -4,6 +4,12 @@
#include "legocarraceactor.h"
#include "legoracemap.h"
// SIZE 0x08
struct EdgeReference {
const char* m_name; // 0x00
LegoPathBoundary* m_data; // 0x04
};
// VTABLE: LEGO1 0x100d58a0 LegoRaceActor
// VTABLE: LEGO1 0x100d58a8 LegoAnimActor
// VTABLE: LEGO1 0x100d58b8 LegoPathActor
@ -46,7 +52,7 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap {
override; // vtable+0x98
MxResult VTable0x9c() override; // vtable+0x9c
virtual void FUN_10012ea0(float p_worldSpeed);
virtual void SetMaxLinearVelocity(float p_maxLinearVelocity);
virtual void FUN_10012ff0(float);
virtual MxBool FUN_10013130(float);
@ -57,10 +63,13 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap {
undefined m_unk0x54; // 0x54
undefined4 m_unk0x58; // 0x58
Mx3DPointFloat m_unk0x5c; // 0x5c
undefined4 m_unk0x70; // 0x70
undefined4 m_unk0x74; // 0x74
undefined4 m_unk0x78; // 0x78
undefined4 m_unk0x7c; // 0x7c
LegoAnimActorStruct* m_unk0x70; // 0x70
LegoAnimActorStruct* m_unk0x74; // 0x74
LegoPathBoundary* m_unk0x78; // 0x78
LegoPathBoundary* m_unk0x7c; // 0x7c
static EdgeReference g_edgeReferences[];
static const EdgeReference* g_pEdgeReferences;
};
#endif // LEGORACECAR_H

View file

@ -1,10 +1,46 @@
#include "legoracecar.h"
#include "define.h"
#include "legorace.h"
#include "misc.h"
#include "mxmisc.h"
#include "mxnotificationmanager.h"
#include "mxutilities.h"
DECOMP_SIZE_ASSERT(EdgeReference, 0x08)
DECOMP_SIZE_ASSERT(LegoRaceCar, 0x200)
// GLOBAL: LEGO1 0x100f0a20
EdgeReference LegoRaceCar::g_edgeReferences[] = {
{// STRING: LEGO1 0x100f0a10
"EDG03_772",
NULL
},
{// STRING: LEGO1 0x100f0a04
"EDG03_773",
NULL
},
{// STRING: LEGO1 0x100f09f8
"EDG03_774",
NULL
},
{// STRING: LEGO1 0x100f09ec
"EDG03_775",
NULL
},
{// STRING: LEGO1 0x100f09e0
"EDG03_776",
NULL
},
{// STRING: LEGO1 0x100f09d4
"EDG03_777",
NULL
}
};
// GLOBAL: LEGO1 0x100f0a50
const EdgeReference* LegoRaceCar::g_pEdgeReferences = g_edgeReferences;
// FUNCTION: LEGO1 0x10012950
LegoRaceCar::LegoRaceCar()
{
@ -18,42 +54,81 @@ LegoRaceCar::LegoRaceCar()
NotificationManager()->Register(this);
}
// STUB: LEGO1 0x10012c80
// FUNCTION: LEGO1 0x10012c80
LegoRaceCar::~LegoRaceCar()
{
// TODO
NotificationManager()->Unregister(this);
}
// STUB: LEGO1 0x10012d90
// FUNCTION: LEGO1 0x10012d90
MxLong LegoRaceCar::Notify(MxParam& p_param)
{
// TODO
return 0;
return LegoRaceMap::Notify(p_param);
}
// STUB: LEGO1 0x10012e60
// FUNCTION: LEGO1 0x10012e60
void LegoRaceCar::SetWorldSpeed(MxFloat p_worldSpeed)
{
// TODO
if (!m_userNavFlag) {
if (!LegoCarRaceActor::m_unk0x0c) {
m_maxLinearVel = p_worldSpeed;
}
LegoAnimActor::SetWorldSpeed(p_worldSpeed);
}
else {
m_worldSpeed = p_worldSpeed;
}
}
// FUNCTION: LEGO1 0x10012ea0
void LegoRaceCar::FUN_10012ea0(float p_worldSpeed)
void LegoRaceCar::SetMaxLinearVelocity(float p_maxLinearVelocity)
{
if (p_worldSpeed < 0) {
if (p_maxLinearVelocity < 0) {
LegoCarRaceActor::m_unk0x0c = 2;
m_maxLinearVel = 0;
SetWorldSpeed(0);
}
else {
m_maxLinearVel = p_worldSpeed;
m_maxLinearVel = p_maxLinearVelocity;
}
}
// STUB: LEGO1 0x10012ef0
void LegoRaceCar::ParseAction(char*)
// FUNCTION: LEGO1 0x10012ef0
void LegoRaceCar::ParseAction(char* p_extra)
{
// TODO
char buffer[256];
LegoAnimActor::ParseAction(p_extra);
LegoRaceMap::ParseAction(p_extra);
LegoRace* currentWorld = (LegoRace*) CurrentWorld();
if (KeyValueStringParse(buffer, g_strCOMP, p_extra) && currentWorld) {
currentWorld->VTable0x7c(this, atoi(buffer));
}
if (m_userNavFlag) {
for (MxU32 i = 0; i < m_animMaps.size(); i++) {
LegoAnimActorStruct* animMap = m_animMaps[i];
if (animMap->m_unk0x00 == -1.0f) {
m_unk0x70 = animMap;
}
else if (animMap->m_unk0x00 == -2.0f) {
m_unk0x74 = animMap;
}
}
// STRING: LEGO1 0x100f0bc4
const char* edge0344 = "EDG03_44";
m_unk0x78 = currentWorld->FindPathBoundary(edge0344);
// STRING: LEGO1 0x100f0bb8
const char* edge0354 = "EDG03_54";
m_unk0x7c = currentWorld->FindPathBoundary(edge0354);
for (MxS32 j = 0; j < sizeOfArray(g_edgeReferences); j++) {
g_edgeReferences[j].m_data = currentWorld->FindPathBoundary(g_edgeReferences[j].m_name);
}
}
}
// STUB: LEGO1 0x10012ff0