Implement/match LegoPathController::Read (#904)

* Implement/match LegoPathController::Read

* Add size asserts
This commit is contained in:
Christian Semmler 2024-05-11 12:23:18 -04:00 committed by GitHub
parent 5df947dbb9
commit f442f1a2f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 276 additions and 27 deletions

View file

@ -376,6 +376,7 @@ add_library(lego1 SHARED
LEGO1/lego/legoomni/src/paths/legopathboundary.cpp LEGO1/lego/legoomni/src/paths/legopathboundary.cpp
LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp
LEGO1/lego/legoomni/src/paths/legopathpresenter.cpp LEGO1/lego/legoomni/src/paths/legopathpresenter.cpp
LEGO1/lego/legoomni/src/paths/legopathstruct.cpp
LEGO1/lego/legoomni/src/pizzeria/pizzamissionstate.cpp LEGO1/lego/legoomni/src/pizzeria/pizzamissionstate.cpp
LEGO1/lego/legoomni/src/pizzeria/pizzeriastate.cpp LEGO1/lego/legoomni/src/pizzeria/pizzeriastate.cpp
LEGO1/lego/legoomni/src/police/policeentity.cpp LEGO1/lego/legoomni/src/police/policeentity.cpp

View file

@ -26,6 +26,7 @@ typedef set<LegoAnimPresenter*, LegoAnimPresenterSetCompare> LegoAnimPresenterSe
class LegoPathBoundary : public LegoWEGEdge { class LegoPathBoundary : public LegoWEGEdge {
public: public:
LegoPathBoundary(); LegoPathBoundary();
~LegoPathBoundary() override;
MxResult AddActor(LegoPathActor* p_actor); MxResult AddActor(LegoPathActor* p_actor);
void FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPathActor* p_actor); void FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPathActor* p_actor);
@ -35,7 +36,7 @@ class LegoPathBoundary : public LegoWEGEdge {
inline LegoAnimPresenterSet* GetPresenters() { return &m_presenters; } inline LegoAnimPresenterSet* GetPresenters() { return &m_presenters; }
// SYNTHETIC: LEGO1 0x10047a80 // SYNTHETIC: LEGO1 0x10047a80
// LegoPathBoundary::`scalar deleting destructor' // LegoPathBoundary::`vector deleting destructor'
private: private:
LegoPathActorSet m_actors; // 0x54 LegoPathActorSet m_actors; // 0x54

View file

@ -2,20 +2,31 @@
#define LEGOPATHCONTROLLER_H #define LEGOPATHCONTROLLER_H
#include "decomp.h" #include "decomp.h"
#include "geom/legounkown100db7f4.h"
#include "legopathactor.h" #include "legopathactor.h"
#include "legopathboundary.h" #include "legopathboundary.h"
#include "mxcore.h" #include "mxcore.h"
#include "mxstl/stlcompat.h" #include "mxstl/stlcompat.h"
class LegoAnimPresenter; class LegoAnimPresenter;
class LegoPathStruct;
class LegoWorld; class LegoWorld;
class MxAtomId; class MxAtomId;
class Vector3; class Vector3;
struct LegoPathControllerComparator { // VTABLE: LEGO1 0x100d7da8
MxBool operator()(const undefined*, const undefined*) const { return 0; } // SIZE 0x40
class LegoPathCtrlEdge : public LegoUnknown100db7f4 {};
struct LegoPathCtrlEdgeCompare {
MxU32 operator()(const LegoPathCtrlEdge* p_lhs, const LegoPathCtrlEdge* p_rhs) const
{
return (MxS32) p_lhs < (MxS32) p_rhs;
}
}; };
typedef set<LegoPathCtrlEdge*, LegoPathCtrlEdgeCompare> LegoPathCtrlEdgeSet;
// VTABLE: LEGO1 0x100d7d60 // VTABLE: LEGO1 0x100d7d60
// SIZE 0x40 // SIZE 0x40
class LegoPathController : public MxCore { class LegoPathController : public MxCore {
@ -41,7 +52,7 @@ class LegoPathController : public MxCore {
// SYNTHETIC: LEGO1 0x10045740 // SYNTHETIC: LEGO1 0x10045740
// LegoPathController::`scalar deleting destructor' // LegoPathController::`scalar deleting destructor'
virtual void VTable0x14(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger); // vtable+0x14 virtual void Create(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger); // vtable+0x14
virtual void Destroy(); // vtable+0x18 virtual void Destroy(); // vtable+0x18
MxResult FUN_10045c20( MxResult FUN_10045c20(
@ -61,30 +72,66 @@ class LegoPathController : public MxCore {
void FUN_10046bb0(LegoWorld* p_world); void FUN_10046bb0(LegoWorld* p_world);
private: private:
MxResult Read(LegoStorage* p_storage);
MxResult FUN_10047b30(LegoStorage* p_storage);
MxResult FUN_10047c10(LegoStorage* p_storage);
MxResult FUN_10047e90(LegoStorage* p_storage);
static MxResult FUN_100482b0(LegoStorage* p_storage, Mx3DPointFloat&);
LegoPathBoundary* m_unk0x08; // 0x08 LegoPathBoundary* m_unk0x08; // 0x08
undefined4 m_unk0x0c; // 0x0c LegoPathCtrlEdge* m_unk0x0c; // 0x0c
undefined4 m_unk0x10; // 0x10 Mx3DPointFloat* m_unk0x10; // 0x10
undefined4 m_unk0x14; // 0x14 LegoPathStruct* m_unk0x14; // 0x14
MxU16 m_numL; // 0x18 MxU16 m_numL; // 0x18
MxU16 m_numE; // 0x1a MxU16 m_numE; // 0x1a
MxU16 m_numN; // 0x1c MxU16 m_numN; // 0x1c
MxU16 m_numT; // 0x1e MxU16 m_numT; // 0x1e
set<undefined*, LegoPathControllerComparator> m_pfsE; // 0x20 LegoPathCtrlEdgeSet m_pfsE; // 0x20
LegoPathActorSet m_actors; // 0x30 LegoPathActorSet m_actors; // 0x30
}; };
// clang-format off // clang-format off
// TEMPLATE: LEGO1 0x100451a0 // TEMPLATE: LEGO1 0x100451a0
// _Tree<unsigned char *,unsigned char *,set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >::_Kfn,LegoPathControllerComparator,allocator<unsigned char *> >::~_Tree<unsigned char *,unsigned char *,set<unsigned char *,LegoPathControl // _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::~_Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathControl
// TEMPLATE: LEGO1 0x100457e0 // TEMPLATE: LEGO1 0x100457e0
// Set<unsigned char *,LegoPathControllerComparator>::~Set<unsigned char *,LegoPathControllerComparator> // Set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare>::~Set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare>
// TEMPLATE: LEGO1 0x10045830 // TEMPLATE: LEGO1 0x10045830
// set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >::~set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> > // set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::~set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >
// TEMPLATE: LEGO1 0x10047550
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Insert
// TEMPLATE: LEGO1 0x100474e0
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::iterator::_Dec
// TEMPLATE: LEGO1 0x10047530
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Buynode
// TEMPLATE: LEGO1 0x100477d0
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Lrotate
// TEMPLATE: LEGO1 0x10047830
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Rrotate
// SYNTHETIC: LEGO1 0x10047940
// LegoPathCtrlEdge::`vector deleting destructor'
// SYNTHETIC: LEGO1 0x100479d0
// LegoPathCtrlEdge::LegoPathCtrlEdge
// SYNTHETIC: LEGO1 0x10047a30
// LegoPathCtrlEdge::~LegoPathCtrlEdge
// SYNTHETIC: LEGO1 0x10047ae0
// LegoUnknown100db7f4::~LegoUnknown100db7f4
// TEMPLATE: LEGO1 0x1004a780
// _Construct
// GLOBAL: LEGO1 0x100f4360 // GLOBAL: LEGO1 0x100f4360
// _Tree<unsigned char *,unsigned char *,set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >::_Kfn,LegoPathControllerComparator,allocator<unsigned char *> >::_Nil // _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Nil
// clang-format on // clang-format on
#endif // LEGOPATHCONTROLLER_H #endif // LEGOPATHCONTROLLER_H

View file

@ -0,0 +1,50 @@
#ifndef LEGOPATHSTRUCT_H
#define LEGOPATHSTRUCT_H
#include "decomp.h"
#include "mxatom.h"
#include "mxtypes.h"
// VTABLE: LEGO1 0x100d7d9c
// SIZE 0x0c
class LegoPathStructBase {
public:
LegoPathStructBase() : m_unk0x04(NULL), m_unk0x08(0) {}
// FUNCTION: LEGO1 0x10047420
virtual ~LegoPathStructBase()
{
if (m_unk0x04 != NULL) {
delete m_unk0x04;
}
}
private:
undefined* m_unk0x04; // 0x04
undefined4 m_unk0x08; // 0x08
};
// VTABLE: LEGO1 0x100d7da0
// SIZE 0x14
class LegoPathStruct : public LegoPathStructBase {
public:
// FUNCTION: LEGO1 0x100473a0
LegoPathStruct() : m_unk0x0c(0) {}
// FUNCTION: LEGO1 0x10047470
~LegoPathStruct() override {}
void VTable0x04(undefined4, undefined4, undefined4); // vtable+0x04
private:
undefined4 m_unk0x0c; // 0x0c
MxAtomId m_atomId; // 0x10
};
// SYNTHETIC: LEGO1 0x10047440
// LegoPathStructBase::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x10047890
// LegoPathStruct::`vector deleting destructor'
#endif // LEGOPATHSTRUCT_H

View file

@ -8,6 +8,13 @@ DECOMP_SIZE_ASSERT(LegoPathBoundary, 0x74)
// STUB: LEGO1 0x10056a70 // STUB: LEGO1 0x10056a70
LegoPathBoundary::LegoPathBoundary() LegoPathBoundary::LegoPathBoundary()
{ {
// TODO
}
// STUB: LEGO1 0x10057260
LegoPathBoundary::~LegoPathBoundary()
{
// TODO
} }
// FUNCTION: LEGO1 0x100573f0 // FUNCTION: LEGO1 0x100573f0

View file

@ -1,18 +1,21 @@
#include "legopathcontroller.h" #include "legopathcontroller.h"
#include "legopathstruct.h"
#include "misc/legostorage.h"
#include "mxmisc.h" #include "mxmisc.h"
#include "mxtimer.h" #include "mxtimer.h"
DECOMP_SIZE_ASSERT(LegoPathController, 0x40) DECOMP_SIZE_ASSERT(LegoPathController, 0x40)
DECOMP_SIZE_ASSERT(LegoPathCtrlEdge, 0x40)
// FUNCTION: LEGO1 0x10044f40 // FUNCTION: LEGO1 0x10044f40
// FUNCTION: BETA10 0x100b6860 // FUNCTION: BETA10 0x100b6860
LegoPathController::LegoPathController() LegoPathController::LegoPathController()
{ {
m_unk0x08 = NULL; m_unk0x08 = NULL;
m_unk0x0c = 0; m_unk0x0c = NULL;
m_unk0x10 = 0; m_unk0x10 = NULL;
m_unk0x14 = 0; m_unk0x14 = NULL;
m_numL = 0; m_numL = 0;
m_numE = 0; m_numE = 0;
m_numN = 0; m_numN = 0;
@ -20,7 +23,7 @@ LegoPathController::LegoPathController()
} }
// STUB: LEGO1 0x10045880 // STUB: LEGO1 0x10045880
void LegoPathController::VTable0x14(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger) void LegoPathController::Create(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger)
{ {
// TODO // TODO
} }
@ -118,3 +121,94 @@ void LegoPathController::Enable(MxBool p_enable)
{ {
// TODO // TODO
} }
// FUNCTION: LEGO1 0x10046e50
// FUNCTION: BETA10 0x100b781f
MxResult LegoPathController::Read(LegoStorage* p_storage)
{
if (p_storage->Read(&m_numT, sizeof(m_numT)) != SUCCESS) {
return FAILURE;
}
if (m_numT > 0) {
m_unk0x14 = new LegoPathStruct[m_numT];
}
if (p_storage->Read(&m_numN, sizeof(m_numN)) != SUCCESS) {
return FAILURE;
}
if (m_numN > 0) {
m_unk0x10 = new Mx3DPointFloat[m_numN];
}
if (p_storage->Read(&m_numE, sizeof(m_numE)) != SUCCESS) {
return FAILURE;
}
if (m_numE > 0) {
m_unk0x0c = new LegoPathCtrlEdge[m_numE];
}
if (p_storage->Read(&m_numL, sizeof(m_numL)) != SUCCESS) {
return FAILURE;
}
if (m_numL > 0) {
m_unk0x08 = new LegoPathBoundary[m_numL];
}
if (m_numT > 0 && FUN_10047b30(p_storage) != SUCCESS) {
return FAILURE;
}
if (m_numN > 0) {
for (MxS32 i = 0; i < m_numN; i++) {
if (FUN_100482b0(p_storage, m_unk0x10[i]) != SUCCESS) {
return FAILURE;
}
}
}
if (m_numE > 0 && FUN_10047c10(p_storage) != SUCCESS) {
return FAILURE;
}
if (m_numL > 0 && FUN_10047e90(p_storage) != SUCCESS) {
return FAILURE;
}
for (MxS32 j = 0; j < m_numE; j++) {
m_pfsE.insert(&m_unk0x0c[j]);
}
return SUCCESS;
}
// STUB: LEGO1 0x10047b30
// FUNCTION: BETA10 0x100b7cd6
MxResult LegoPathController::FUN_10047b30(LegoStorage* p_storage)
{
// TODO
return SUCCESS;
}
// STUB: LEGO1 0x10047c10
// FUNCTION: BETA10 0x1100b7df3
MxResult LegoPathController::FUN_10047c10(LegoStorage* p_storage)
{
// TODO
return SUCCESS;
}
// STUB: LEGO1 0x10047e90
// FUNCTION: BETA10 0x100b8293
MxResult LegoPathController::FUN_10047e90(LegoStorage* p_storage)
{
// TODO
return SUCCESS;
}
// STUB: LEGO1 0x100482b0
// FUNCTION: BETA10 0x100b8864
MxResult LegoPathController::FUN_100482b0(LegoStorage* p_storage, Mx3DPointFloat&)
{
// TODO
return SUCCESS;
}

View file

@ -70,9 +70,9 @@ void LegoPathPresenter::Destroy()
// FUNCTION: LEGO1 0x10044c20 // FUNCTION: LEGO1 0x10044c20
void LegoPathPresenter::ReadyTickle() void LegoPathPresenter::ReadyTickle()
{ {
LegoWorld* currentWorld = CurrentWorld(); LegoWorld* world = CurrentWorld();
if (currentWorld) { if (world) {
MxStreamChunk* chunk = m_subscriber->PopData(); MxStreamChunk* chunk = m_subscriber->PopData();
if (chunk) { if (chunk) {
@ -84,8 +84,8 @@ void LegoPathPresenter::ReadyTickle()
else { else {
ParseExtra(); ParseExtra();
controller->VTable0x14(chunk->GetData(), m_action->GetLocation(), m_trigger); controller->Create(chunk->GetData(), m_action->GetLocation(), m_trigger);
currentWorld->AddPath(controller); world->AddPath(controller);
m_subscriber->FreeDataChunk(chunk); m_subscriber->FreeDataChunk(chunk);
ProgressTickleState(MxPresenter::e_starting); ProgressTickleState(MxPresenter::e_starting);

View file

@ -0,0 +1,11 @@
#include "legopathstruct.h"
DECOMP_SIZE_ASSERT(LegoPathStructBase, 0x0c)
DECOMP_SIZE_ASSERT(LegoPathStruct, 0x14)
// STUB: LEGO1 0x1001b700
// FUNCTION: BETA10 0x100c26c5
void LegoPathStruct::VTable0x04(undefined4, undefined4, undefined4)
{
// TODO
}

View file

@ -1,3 +1,12 @@
#include "legounkown100db7f4.h" #include "legounkown100db7f4.h"
DECOMP_SIZE_ASSERT(LegoUnknown100db7f4, 0x40) DECOMP_SIZE_ASSERT(LegoUnknown100db7f4, 0x40)
// FUNCTION: LEGO1 0x1009a630
// FUNCTION: BETA10 0x10183050
LegoUnknown100db7f4::LegoUnknown100db7f4()
{
m_unk0x24 = 0;
m_unk0x28.Clear();
m_unk0x3c = 0;
}

View file

@ -9,6 +9,8 @@
// SIZE 0x40 // SIZE 0x40
class LegoUnknown100db7f4 : public LegoEdge { class LegoUnknown100db7f4 : public LegoEdge {
public: public:
LegoUnknown100db7f4();
// FUNCTION: LEGO1 0x1002ddc0 // FUNCTION: LEGO1 0x1002ddc0
// FUNCTION: BETA10 0x100372a0 // FUNCTION: BETA10 0x100372a0
LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point) LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point)
@ -25,6 +27,9 @@ class LegoUnknown100db7f4 : public LegoEdge {
return SUCCESS; return SUCCESS;
} }
// SYNTHETIC: LEGO1 0x1009a6c0
// LegoUnknown100db7f4::`scalar deleting destructor'
private: private:
LegoU16 m_unk0x24; // 0x24 LegoU16 m_unk0x24; // 0x24
Mx3DPointFloat m_unk0x28; // 0x28 Mx3DPointFloat m_unk0x28; // 0x28

View file

@ -18,6 +18,15 @@
// LIBRARY: LEGO1 0x1008b020 // LIBRARY: LEGO1 0x1008b020
// ___CxxFrameHandler // ___CxxFrameHandler
// LIBRARY: LEGO1 0x1008b24c
// __global_unwind2
// LIBRARY: LEGO1 0x1008b28e
// __local_unwind2
// LIBRARY: LEGO1 0x1008b322
// __NLG_Notify
// LIBRARY: LEGO1 0x1008b3dc // LIBRARY: LEGO1 0x1008b3dc
// __CIacos // __CIacos
@ -81,6 +90,15 @@
// LIBRARY: LEGO1 0x1008c200 // LIBRARY: LEGO1 0x1008c200
// _sscanf // _sscanf
// LIBRARY: LEGO1 0x1008c250
// ??_L@YGXPAXIHP6EX0@Z1@Z
// LIBRARY: LEGO1 0x1008c2e0
// ??_M@YGXPAXIHP6EX0@Z@Z
// LIBRARY: LEGO1 0x1008c370
// ?__ArrayUnwind@@YGXPAXIHP6EX0@Z@Z
// LIBRARY: LEGO1 0x1008c410 // LIBRARY: LEGO1 0x1008c410
// _strlwr // _strlwr
@ -93,6 +111,9 @@
// LIBRARY: LEGO1 0x1008c6a0 // LIBRARY: LEGO1 0x1008c6a0
// _isdigit // _isdigit
// LIBRARY: LEGO1 0x1008c980
// __except_handler3
// LIBRARY: LEGO1 0x1008ca60 // LIBRARY: LEGO1 0x1008ca60
// _abort // _abort
@ -120,4 +141,7 @@
// LIBRARY: LEGO1 0x100d2270 // LIBRARY: LEGO1 0x100d2270
// __beginthreadex // __beginthreadex
// LIBRARY: LEGO1 0x100fc8bc
// __NLG_Destination
#endif #endif