Implement LegoWorld::Add (#490)

* LegoWorld::Add

* Add annotations

* Fix include guard

* Make stub

* Change MxPresenterSet to MxCoreSet

* Improve match

* Match

* Fix annotation
This commit is contained in:
Christian Semmler 2024-01-26 17:52:03 -05:00 committed by GitHub
parent b6aac26269
commit 7b6ec235d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 236 additions and 132 deletions

View file

@ -40,6 +40,8 @@ class LegoAnimPresenter : public MxVideoPresenter {
virtual void PutFrame() override; // vtable+0x6c
virtual MxResult VTable0x88(MxStreamChunk* p_chunk); // vtable+0x88
inline LegoAnimClass* GetUnknown0x64() { return m_unk0x64; }
const char* GetActionObjectName();
protected:
@ -101,6 +103,9 @@ class LegoAnimClass : public LegoAnimClassBase {
virtual void VTable0xc() override; // vtable+0x0c
virtual MxResult VTable0x10(LegoMemory* p_stream, MxS32); // vtable+0x10
inline MxLong GetUnknown0x8() { return m_unk0x8; }
// private:
MxLong m_unk0x8; // 0x08
undefined4 m_unk0xc; // 0x0c
undefined4 m_unk0x10; // 0x10

View file

@ -0,0 +1,98 @@
#ifndef LEGOCACHESOUNDLIST_H
#define LEGOCACHESOUNDLIST_H
#include "mxlist.h"
#include "mxtypes.h"
class LegoCacheSound;
// VTABLE: LEGO1 0x100d63b0
// class MxCollection<LegoCacheSound *>
// VTABLE: LEGO1 0x100d63c8
// class MxList<LegoCacheSound *>
// VTABLE: LEGO1 0x100d63e0
// class MxPtrList<LegoCacheSound>
// VTABLE: LEGO1 0x100d63f8
// SIZE 0x18
class LegoCacheSoundList : public MxPtrList<LegoCacheSound> {
public:
LegoCacheSoundList(MxBool p_ownership = FALSE) : MxPtrList<LegoCacheSound>(p_ownership) {}
// FUNCTION: LEGO1 0x1001e650
virtual MxS8 Compare(LegoCacheSound* p_a, LegoCacheSound* p_b) override
{
return p_a == p_b ? 0 : p_a < p_b ? -1 : 1;
}; // vtable+0x14
};
// VTABLE: LEGO1 0x100d64a0
// class MxListCursor<LegoCacheSound *>
// VTABLE: LEGO1 0x100d6500
// class MxPtrListCursor<LegoCacheSound>
// VTABLE: LEGO1 0x100d6518
// SIZE 0x10
class LegoCacheSoundListCursor : public MxPtrListCursor<LegoCacheSound> {
public:
LegoCacheSoundListCursor(LegoCacheSoundList* p_list) : MxPtrListCursor<LegoCacheSound>(p_list){};
};
// TEMPLATE: LEGO1 0x1001e670
// MxCollection<LegoCacheSound *>::Compare
// TEMPLATE: LEGO1 0x1001e680
// MxCollection<LegoCacheSound *>::~MxCollection<LegoCacheSound *>
// TEMPLATE: LEGO1 0x1001e6d0
// MxCollection<LegoCacheSound *>::Destroy
// TEMPLATE: LEGO1 0x1001e6e0
// MxList<LegoCacheSound *>::~MxList<LegoCacheSound *>
// TEMPLATE: LEGO1 0x1001e770
// MxPtrList<LegoCacheSound>::Destroy
// SYNTHETIC: LEGO1 0x1001e780
// LegoCacheSoundList::`scalar deleting destructor'
// TEMPLATE: LEGO1 0x1001e7f0
// MxPtrList<LegoCacheSound>::~MxPtrList<LegoCacheSound>
// SYNTHETIC: LEGO1 0x1001e840
// MxCollection<LegoCacheSound *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001e8b0
// MxList<LegoCacheSound *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001e960
// MxPtrList<LegoCacheSound>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001f350
// LegoCacheSoundListCursor::`scalar deleting destructor'
// FUNCTION: LEGO1 0x1001f3c0
// MxPtrListCursor<LegoCacheSound>::~MxPtrListCursor<LegoCacheSound>
// SYNTHETIC: LEGO1 0x1001f410
// MxListCursor<LegoCacheSound *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001f480
// MxPtrListCursor<LegoCacheSound>::`scalar deleting destructor'
// FUNCTION: LEGO1 0x1001f4f0
// MxListCursor<LegoCacheSound *>::~MxListCursor<LegoCacheSound *>
// FUNCTION: LEGO1 0x1001f540
// LegoCacheSoundListCursor::~LegoCacheSoundListCursor
// TEMPLATE: LEGO1 0x10020840
// MxListCursor<LegoCacheSound *>::MxListCursor<LegoCacheSound *>
// TEMPLATE: LEGO1 0x100224e0
// MxList<LegoCacheSound *>::InsertEntry
#endif // LEGOCACHESOUNDLIST_H

View file

@ -92,4 +92,7 @@ class LegoEntityListCursor : public MxPtrListCursor<LegoEntity> {
// TEMPLATE: LEGO1 0x100207d0
// MxListCursor<LegoEntity *>::MxListCursor<LegoEntity *>
// TEMPLATE: LEGO1 0x10022430
// MxList<LegoEntity *>::InsertEntry
#endif // LEGOENTITYLIST_H

View file

@ -9,7 +9,9 @@
class MxAtomId;
class LegoEntity;
class LegoAnimPresenter;
void FUN_1003e050(LegoAnimPresenter* p_presenter);
Extra::ActionType MatchActionString(const char*);
void InvokeAction(Extra::ActionType p_actionId, MxAtomId& p_pAtom, int p_targetEntityId, LegoEntity* p_sender);
void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bOut, float* p_gOut);

View file

@ -1,22 +1,24 @@
#ifndef LEGOWORLD_H
#define LEGOWORLD_H
#include "legocachesound.h"
#include "legocachesoundlist.h"
#include "legocameracontroller.h"
#include "legoentity.h"
#include "legoentitylist.h"
#include "legopathcontrollerlist.h"
#include "mxcorelist.h"
#include "mxpresenter.h"
#include "mxpresenterlist.h"
class IslePathActor;
class LegoPathBoundary;
class LegoHideAnimPresenter;
struct PresenterSetCompare {
MxS32 operator()(MxPresenter* const& p_a, MxPresenter* const& p_b) const { return p_a > p_b; }
struct CoreSetCompare {
MxS32 operator()(MxCore* const& p_a, MxCore* const& p_b) const { return p_a > p_b; }
};
typedef set<MxPresenter*, PresenterSetCompare> MxPresenterSet;
typedef set<MxCore*, CoreSetCompare> MxCoreSet;
// VTABLE: LEGO1 0x100d6280
// SIZE 0xf8
@ -72,38 +74,38 @@ class LegoWorld : public LegoEntity {
// LegoWorld::`scalar deleting destructor'
protected:
LegoPathControllerList m_list0x68; // 0x68
MxPresenterList m_animPresenters; // 0x80
LegoCameraController* m_cameraController; // 0x98
LegoEntityList* m_entityList; // 0x9c
MxCoreList* m_coreList; // 0xa0
undefined m_unk0xa4; // 0xa4
MxPresenterSet m_set0xa8; // 0xa8
MxPresenterList m_controlPresenters; // 0xb8
MxPresenterSet m_set0xd0; // 0xd0
list<AutoROI*> m_list0xe0; // 0xe0
undefined4 m_unk0xec; // 0xec
undefined4 m_unk0xf0; // 0xf0
MxS16 m_unk0xf4; // 0xf4
MxBool m_worldStarted; // 0xf6
undefined m_unk0xf7; // 0xf7
LegoPathControllerList m_list0x68; // 0x68
MxPresenterList m_animPresenters; // 0x80
LegoCameraController* m_cameraController; // 0x98
LegoEntityList* m_entityList; // 0x9c
LegoCacheSoundList* m_cacheSoundList; // 0xa0
undefined m_unk0xa4; // 0xa4
MxCoreSet m_set0xa8; // 0xa8
MxPresenterList m_controlPresenters; // 0xb8
MxCoreSet m_set0xd0; // 0xd0
list<AutoROI*> m_list0xe0; // 0xe0
undefined4 m_unk0xec; // 0xec
LegoHideAnimPresenter* m_hideAnimPresenter; // 0xf0
MxS16 m_unk0xf4; // 0xf4
MxBool m_worldStarted; // 0xf6
undefined m_unk0xf7; // 0xf7
};
// clang-format off
// TEMPLATE: LEGO1 0x1001d780
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::~_Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::~_Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >
// TEMPLATE: LEGO1 0x1001d850
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::iterator::_Inc
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::iterator::_Inc
// TEMPLATE: LEGO1 0x1001d890
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::erase
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::erase
// TEMPLATE: LEGO1 0x1001dcf0
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::_Erase
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Erase
// TEMPLATE: LEGO1 0x1001dd30
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::_Init
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Init
// TEMPLATE: LEGO1 0x1001ddf0
// list<AutoROI *,allocator<AutoROI *> >::~list<AutoROI *,allocator<AutoROI *> >
@ -115,10 +117,10 @@ class LegoWorld : public LegoEntity {
// list<AutoROI *,allocator<AutoROI *> >::_Buynode
// TEMPLATE: LEGO1 0x1001de90
// set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::~set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >
// set<MxCore *,CoreSetCompare,allocator<MxCore *> >::~set<MxCore *,CoreSetCompare,allocator<MxCore *> >
// TEMPLATE: LEGO1 0x1001df00
// Set<MxPresenter *,PresenterSetCompare>::~Set<MxPresenter *,PresenterSetCompare>
// Set<MxCore *,CoreSetCompare>::~Set<MxCore *,CoreSetCompare>
// SYNTHETIC: LEGO1 0x1001eed0
// MxPresenterListCursor::`scalar deleting destructor'
@ -141,8 +143,31 @@ class LegoWorld : public LegoEntity {
// TEMPLATE: LEGO1 0x10020760
// MxListCursor<MxPresenter *>::MxListCursor<MxPresenter *>
// TEMPLATE: LEGO1 0x100208b0
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::insert
// TEMPLATE: LEGO1 0x10020b20
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::iterator::_Dec
// XTEMPLATE LEGO1 0x10020b70
// TEMPLATE: LEGO1 0x10020bb0
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Buynode
// TEMPLATE: LEGO1 0x10020bd0
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Insert
// TEMPLATE: LEGO1 0x10020e50
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Lrotate
// TEMPLATE: LEGO1 0x10020eb0
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Rrotate
// TEMPLATE: LEGO1 0x10022360
// _Construct
// GLOBAL: LEGO1 0x100f11a0
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *>>::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::_Nil
// _Tree<MxCore *,MxCore *,set<MxCore *,CoreSetCompare,allocator<MxCore *> >::_Kfn,CoreSetCompare,allocator<MxCore *> >::_Nil
// clang-format on
#endif // LEGOWORLD_H

View file

@ -10,6 +10,12 @@
#include <process.h>
#include <string.h>
// STUB: LEGO1 0x1003e050
void FUN_1003e050(LegoAnimPresenter* p_presenter)
{
// TODO
}
// FUNCTION: LEGO1 0x1003e300
Extra::ActionType MatchActionString(const char* p_str)
{

View file

@ -15,8 +15,8 @@
DECOMP_SIZE_ASSERT(LegoWorld, 0xf8)
DECOMP_SIZE_ASSERT(LegoEntityList, 0x18)
DECOMP_SIZE_ASSERT(LegoEntityListCursor, 0x10)
DECOMP_SIZE_ASSERT(MxCoreList, 0x18)
DECOMP_SIZE_ASSERT(MxCoreListCursor, 0x10)
DECOMP_SIZE_ASSERT(LegoCacheSoundList, 0x18)
DECOMP_SIZE_ASSERT(LegoCacheSoundListCursor, 0x10)
// FUNCTION: LEGO1 0x1001ca40
LegoWorld::LegoWorld() : m_list0x68(TRUE)
@ -24,9 +24,9 @@ LegoWorld::LegoWorld() : m_list0x68(TRUE)
m_unk0xf4 = 4;
m_cameraController = NULL;
m_entityList = NULL;
m_coreList = NULL;
m_cacheSoundList = NULL;
m_unk0xa4 = 0; // MxBool?
m_unk0xf0 = 0;
m_hideAnimPresenter = NULL;
m_worldStarted = FALSE;
NotificationManager()->Register(this);
@ -60,9 +60,9 @@ MxResult LegoWorld::Create(MxDSAction& p_dsAction)
if (!m_entityList)
return FAILURE;
m_coreList = new MxCoreList(TRUE);
m_cacheSoundList = new LegoCacheSoundList(TRUE);
if (!m_coreList)
if (!m_cacheSoundList)
return FAILURE;
if (!VTable0x54())
@ -152,10 +152,67 @@ MxS32 LegoWorld::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value)
return 0;
}
// STUB: LEGO1 0x10020220
// FUNCTION: LEGO1 0x10020220
void LegoWorld::Add(MxCore* p_object)
{
// TODO
if (p_object && !p_object->IsA("LegoWorld") && !p_object->IsA("LegoWorldPresenter")) {
if (p_object->IsA("LegoAnimPresenter")) {
LegoAnimPresenter* animPresenter = (LegoAnimPresenter*) p_object;
if (!strcmpi(animPresenter->GetAction()->GetObjectName(), "ConfigAnimation")) {
FUN_1003e050(animPresenter);
animPresenter->GetAction()->SetDuration(animPresenter->GetUnknown0x64()->GetUnknown0x8());
}
}
if (p_object->IsA("MxControlPresenter")) {
MxPresenterListCursor cursor(&m_controlPresenters);
if (cursor.Find((MxPresenter*) p_object))
return;
m_controlPresenters.Append((MxPresenter*) p_object);
}
else if (p_object->IsA("MxEntity")) {
LegoEntityListCursor cursor(m_entityList);
if (cursor.Find((LegoEntity*) p_object))
return;
m_entityList->Append((LegoEntity*) p_object);
}
else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) {
MxPresenterListCursor cursor(&m_animPresenters);
if (cursor.Find((MxPresenter*) p_object))
return;
((MxPresenter*) p_object)->SendToCompositePresenter(Lego());
m_animPresenters.Append(((MxPresenter*) p_object));
if (p_object->IsA("LegoHideAnimPresenter"))
m_hideAnimPresenter = (LegoHideAnimPresenter*) p_object;
}
else if (p_object->IsA("LegoCacheSound")) {
LegoCacheSoundListCursor cursor(m_cacheSoundList);
if (cursor.Find((LegoCacheSound*) p_object))
return;
m_cacheSoundList->Append((LegoCacheSound*) p_object);
}
else {
if (m_set0xa8.find(p_object) == m_set0xa8.end())
m_set0xa8.insert(p_object);
}
if (!m_set0xd0.empty() && p_object->IsA("MxPresenter")) {
if (((MxPresenter*) p_object)->IsEnabled()) {
((MxPresenter*) p_object)->Enable(FALSE);
m_set0xd0.insert(p_object);
}
}
}
}
// STUB: LEGO1 0x10020f10
@ -206,7 +263,7 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
return NULL;
}
else {
for (MxPresenterSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
if ((*it)->IsA(p_class) && (*it)->IsA("MxPresenter")) {
MxPresenter* presenter = (MxPresenter*) *it;
MxDSAction* action = presenter->GetAction();
@ -250,7 +307,7 @@ MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
return presenter;
}
for (MxPresenterSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
MxCore* core = *it;
if (core->IsA("MxPresenter")) {

View file

@ -1,95 +0,0 @@
#ifndef MXCORELIST_H
#define MXCORELIST_H
#include "mxlist.h"
#include "mxtypes.h"
class MxCore;
// VTABLE: LEGO1 0x100d63b0
// class MxCollection<MxCore *>
// VTABLE: LEGO1 0x100d63c8
// class MxList<MxCore *>
// VTABLE: LEGO1 0x100d63e0
// class MxPtrList<MxCore>
// VTABLE: LEGO1 0x100d63f8
// SIZE 0x18
class MxCoreList : public MxPtrList<MxCore> {
public:
MxCoreList(MxBool p_ownership = FALSE) : MxPtrList<MxCore>(p_ownership) {}
// FUNCTION: LEGO1 0x1001e650
virtual MxS8 Compare(MxCore* p_a, MxCore* p_b) override
{
return p_a == p_b ? 0 : p_a < p_b ? -1 : 1;
}; // vtable+0x14
};
// VTABLE: LEGO1 0x100d64a0
// class MxListCursor<MxCore *>
// VTABLE: LEGO1 0x100d6500
// class MxPtrListCursor<MxCore>
// VTABLE: LEGO1 0x100d6518
// SIZE 0x10
class MxCoreListCursor : public MxPtrListCursor<MxCore> {
public:
MxCoreListCursor(MxCoreList* p_list) : MxPtrListCursor<MxCore>(p_list){};
};
// TEMPLATE: LEGO1 0x1001e670
// MxCollection<MxCore *>::Compare
// TEMPLATE: LEGO1 0x1001e680
// MxCollection<MxCore *>::~MxCollection<MxCore *>
// TEMPLATE: LEGO1 0x1001e6d0
// MxCollection<MxCore *>::Destroy
// TEMPLATE: LEGO1 0x1001e6e0
// MxList<MxCore *>::~MxList<MxCore *>
// TEMPLATE: LEGO1 0x1001e770
// MxPtrList<MxCore>::Destroy
// SYNTHETIC: LEGO1 0x1001e780
// MxCoreList::`scalar deleting destructor'
// TEMPLATE: LEGO1 0x1001e7f0
// MxPtrList<MxCore>::~MxPtrList<MxCore>
// SYNTHETIC: LEGO1 0x1001e840
// MxCollection<MxCore *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001e8b0
// MxList<MxCore *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001e960
// MxPtrList<MxCore>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001f350
// MxCoreListCursor::`scalar deleting destructor'
// FUNCTION: LEGO1 0x1001f3c0
// MxPtrListCursor<MxCore>::~MxPtrListCursor<MxCore>
// SYNTHETIC: LEGO1 0x1001f410
// MxListCursor<MxCore *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1001f480
// MxPtrListCursor<MxCore>::`scalar deleting destructor'
// FUNCTION: LEGO1 0x1001f4f0
// MxListCursor<MxCore *>::~MxListCursor<MxCore *>
// FUNCTION: LEGO1 0x1001f540
// MxCoreListCursor::~MxCoreListCursor
// TEMPLATE: LEGO1 0x10020840
// MxListCursor<MxCore *>::MxListCursor<MxCore *>
#endif // MXCORELIST_H

View file

@ -71,4 +71,7 @@ class MxPresenterListCursor : public MxPtrListCursor<MxPresenter> {
// SYNTHETIC: LEGO1 0x1001d100
// MxPresenterList::~MxPresenterList
// TEMPLATE: LEGO1 0x10022380
// MxList<MxPresenter *>::InsertEntry
#endif // MXPRESENTERLIST_H