Implement/match a few LegoEntity functions (#445)

* Implement/match a few LegoEntity functions

* Add annotations
This commit is contained in:
Christian Semmler 2024-01-16 14:33:03 -05:00 committed by GitHub
parent b1fdb780de
commit 6af0c6cb1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 74 additions and 27 deletions

View file

@ -37,7 +37,7 @@ class LegoCameraController : public LegoPointOfViewController {
virtual MxResult Create(); // vtable+0x44 virtual MxResult Create(); // vtable+0x44
void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up); void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up);
void FUN_100123e0(MxMatrix& p_transform, MxU32); void FUN_100123e0(const MxMatrix& p_transform, MxU32);
Mx3DPointFloat GetWorldUp(); Mx3DPointFloat GetWorldUp();
Mx3DPointFloat GetWorldLocation(); Mx3DPointFloat GetWorldLocation();
Mx3DPointFloat GetWorldDirection(); Mx3DPointFloat GetWorldDirection();

View file

@ -12,10 +12,19 @@
// SIZE 0x68 (probably) // SIZE 0x68 (probably)
class LegoEntity : public MxEntity { class LegoEntity : public MxEntity {
public: public:
enum {
Flag_Bit1 = 0x01
};
// Inlined at 0x100853f7 // Inlined at 0x100853f7
inline LegoEntity() { Init(); } inline LegoEntity() { Init(); }
__declspec(dllexport) virtual ~LegoEntity() override; // vtable+0x0 #ifdef ISLE_APP
__declspec(dllexport) virtual ~LegoEntity() override;
#else
// FUNCTION: LEGO1 0x1000c290
__declspec(dllexport) virtual ~LegoEntity() override { Destroy(TRUE); }
#endif
virtual MxLong Notify(MxParam& p_param) override; // vtable+0x4 virtual MxLong Notify(MxParam& p_param) override; // vtable+0x4
@ -58,15 +67,15 @@ class LegoEntity : public MxEntity {
void Init(); void Init();
void SetWorld(); void SetWorld();
undefined m_unk0x10; undefined m_unk0x10; // 0x10
undefined m_unk0x11; MxU8 m_flags; // 0x11
Mx3DPointFloat m_worldLocation; // 0x14 Mx3DPointFloat m_worldLocation; // 0x14
Mx3DPointFloat m_worldDirection; // 0x28 Mx3DPointFloat m_worldDirection; // 0x28
Mx3DPointFloat m_worldUp; // 0x3c Mx3DPointFloat m_worldUp; // 0x3c
MxFloat m_worldSpeed; // 0x50 MxFloat m_worldSpeed; // 0x50
LegoROI* m_roi; // 0x54 LegoROI* m_roi; // 0x54
MxBool m_cameraFlag; // 0x58 MxBool m_cameraFlag; // 0x58
undefined m_unk0x59; undefined m_unk0x59; // 0x59
// For tokens from the extra string that look like this: // For tokens from the extra string that look like this:
// "Action:openram;\lego\scripts\Race\CarRaceR;0" // "Action:openram;\lego\scripts\Race\CarRaceR;0"
ExtraActionType m_actionType; // 0x5c ExtraActionType m_actionType; // 0x5c
@ -74,4 +83,7 @@ class LegoEntity : public MxEntity {
MxS32 m_actionArgNumber; // 0x64 MxS32 m_actionArgNumber; // 0x64
}; };
// SYNTHETIC: LEGO1 0x1000c3b0
// LegoEntity::`scalar deleting destructor'
#endif // LEGOENTITY_H #endif // LEGOENTITY_H

View file

@ -114,6 +114,7 @@ class LegoOmni : public MxOmni {
MxBackgroundAudioManager* GetBackgroundAudioManager() { return m_bkgAudioManager; } MxBackgroundAudioManager* GetBackgroundAudioManager() { return m_bkgAudioManager; }
MxTransitionManager* GetTransitionManager() { return m_transitionManager; } MxTransitionManager* GetTransitionManager() { return m_transitionManager; }
MxDSAction& GetCurrentAction() { return m_action; } MxDSAction& GetCurrentAction() { return m_action; }
LegoUnkSaveDataWriter* GetUnkSaveDataWriter() { return m_saveDataWriter; }
inline void SetNavController(LegoNavController* p_navController) { m_navController = p_navController; } inline void SetNavController(LegoNavController* p_navController) { m_navController = p_navController; }
inline void SetWorld(LegoWorld* p_currentWorld) { m_currentWorld = p_currentWorld; } inline void SetWorld(LegoWorld* p_currentWorld) { m_currentWorld = p_currentWorld; }
@ -157,6 +158,7 @@ LegoControlManager* ControlManager();
IslePathActor* GetCurrentVehicle(); IslePathActor* GetCurrentVehicle();
LegoPlantManager* PlantManager(); LegoPlantManager* PlantManager();
LegoWorld* GetCurrentWorld(); LegoWorld* GetCurrentWorld();
LegoUnkSaveDataWriter* GetUnkSaveDataWriter();
GifManager* GetGifManager(); GifManager* GetGifManager();
void FUN_10015820(MxU32, MxU32); void FUN_10015820(MxU32, MxU32);
LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid); LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid);

View file

@ -4,6 +4,7 @@
#include "decomp.h" #include "decomp.h"
#include "mxtypes.h" #include "mxtypes.h"
class LegoROI;
class LegoStream; class LegoStream;
struct LegoSaveDataEntry3 { struct LegoSaveDataEntry3 {
@ -32,7 +33,9 @@ struct LegoSaveDataEntry3 {
}; };
class LegoUnkSaveDataWriter { class LegoUnkSaveDataWriter {
public:
MxResult WriteSaveData3(LegoStream* p_stream); MxResult WriteSaveData3(LegoStream* p_stream);
void FUN_10083db0(LegoROI* p_roi);
}; };
#endif // LEGOUNKSAVEDATAWRITER_H #endif // LEGOUNKSAVEDATAWRITER_H

View file

@ -29,7 +29,6 @@ void LegoFullScreenMovie::SetValue(const char* p_option)
LegoVideoManager* videomanager = VideoManager(); LegoVideoManager* videomanager = VideoManager();
if (videomanager) { if (videomanager) {
if (!strcmp(m_value.GetData(), g_strEnable)) { if (!strcmp(m_value.GetData(), g_strEnable)) {
videomanager->EnableFullScreenMovie(TRUE); videomanager->EnableFullScreenMovie(TRUE);
return; return;

View file

@ -47,3 +47,9 @@ MxResult LegoUnkSaveDataWriter::WriteSaveData3(LegoStream* p_stream)
} }
return result; return result;
} }
// STUB: LEGO1 0x10083db0
void LegoUnkSaveDataWriter::FUN_10083db0(LegoROI* p_roi)
{
// TODO
}

View file

@ -78,7 +78,7 @@ void LegoCameraController::SetWorldTransform(const Vector3& p_at, const Vector3&
} }
// STUB: LEGO1 0x100123e0 // STUB: LEGO1 0x100123e0
void LegoCameraController::FUN_100123e0(MxMatrix& p_transform, MxU32) void LegoCameraController::FUN_100123e0(const MxMatrix& p_transform, MxU32)
{ {
} }

View file

@ -2,17 +2,13 @@
#include "define.h" #include "define.h"
#include "legoomni.h" #include "legoomni.h"
#include "legounksavedatawriter.h"
#include "legoutil.h" #include "legoutil.h"
#include "legovideomanager.h"
#include "legoworld.h" #include "legoworld.h"
DECOMP_SIZE_ASSERT(LegoEntity, 0x68) DECOMP_SIZE_ASSERT(LegoEntity, 0x68)
// FUNCTION: LEGO1 0x1000c290
LegoEntity::~LegoEntity()
{
Destroy(TRUE);
}
// FUNCTION: LEGO1 0x100105f0 // FUNCTION: LEGO1 0x100105f0
void LegoEntity::Init() void LegoEntity::Init()
{ {
@ -20,10 +16,10 @@ void LegoEntity::Init()
m_worldDirection.Fill(0); m_worldDirection.Fill(0);
m_worldSpeed = 0; m_worldSpeed = 0;
m_roi = NULL; m_roi = NULL;
m_cameraFlag = 0; m_cameraFlag = FALSE;
m_actionArgString = NULL; m_actionArgString = NULL;
m_unk0x10 = 0; m_unk0x10 = 0;
m_unk0x11 = 0; m_flags = 0;
m_actionType = ExtraActionType_unknown; m_actionType = ExtraActionType_unknown;
m_actionArgNumber = -1; m_actionArgNumber = -1;
m_unk0x59 = 4; m_unk0x59 = 4;
@ -50,11 +46,22 @@ MxResult LegoEntity::Create(MxDSAction& p_dsAction)
return SUCCESS; return SUCCESS;
} }
// STUB: LEGO1 0x10010810 // FUNCTION: LEGO1 0x10010810
void LegoEntity::Destroy(MxBool p_fromDestructor) void LegoEntity::Destroy(MxBool p_fromDestructor)
{ {
if (m_roi) { if (m_roi) {
// TODO if (m_flags & Flag_Bit1) {
if (m_roi->GetUnknown0x104() == this)
m_roi->SetUnknown0x104(NULL);
GetUnkSaveDataWriter()->FUN_10083db0(m_roi);
}
else {
VideoManager()->Get3DManager()->GetLego3DView()->Remove(*m_roi);
if (m_roi)
delete m_roi;
}
} }
delete[] m_actionArgString; delete[] m_actionArgString;
@ -82,9 +89,13 @@ void LegoEntity::SetLocation(Mx3DPointFloat& p_location, Mx3DPointFloat& p_direc
// TODO // TODO
} }
// STUB: LEGO1 0x10010c30 // FUNCTION: LEGO1 0x10010c30
void LegoEntity::FUN_10010c30() void LegoEntity::FUN_10010c30()
{ {
LegoWorld* world = GetCurrentWorld();
if (m_cameraFlag && world && world->GetCamera() && m_roi)
world->GetCamera()->FUN_100123e0(m_roi->GetLocal2World(), 1);
} }
// FUNCTION: LEGO1 0x10010e10 // FUNCTION: LEGO1 0x10010e10

View file

@ -181,6 +181,12 @@ LegoWorld* GetCurrentWorld()
return LegoOmni::GetInstance()->GetCurrentOmniWorld(); return LegoOmni::GetInstance()->GetCurrentOmniWorld();
} }
// FUNCTION: LEGO1 0x100157b0
LegoUnkSaveDataWriter* GetUnkSaveDataWriter()
{
return LegoOmni::GetInstance()->GetUnkSaveDataWriter();
}
// FUNCTION: LEGO1 0x100157e0 // FUNCTION: LEGO1 0x100157e0
LegoPlantManager* PlantManager() LegoPlantManager* PlantManager()
{ {

View file

@ -49,12 +49,13 @@ void LegoPalettePresenter::Destroy()
MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk) MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk)
{ {
MxU8 buffer[40]; MxU8 buffer[40];
RGBQUAD palleteData[256]; RGBQUAD palette[256];
MxResult result = FAILURE; MxResult result = FAILURE;
LegoMemoryStream stream((char*) p_chunk->GetData()); LegoMemoryStream stream((char*) p_chunk->GetData());
if (stream.Read(buffer, 40) == SUCCESS) { if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) {
if (stream.Read(palleteData, sizeof(RGBQUAD) * 256) == SUCCESS) { if (stream.Read(palette, sizeof(palette)) == SUCCESS) {
m_palette = new MxPalette(palleteData); m_palette = new MxPalette(palette);
if (m_palette) { if (m_palette) {
result = SUCCESS; result = SUCCESS;
} }

View file

@ -6,6 +6,8 @@
typedef MxBool (*ROIHandler)(char*, char*, MxU32); typedef MxBool (*ROIHandler)(char*, char*, MxU32);
class LegoEntity;
// Note: There is an extra class between LegoROI and ViewROI, // Note: There is an extra class between LegoROI and ViewROI,
// maybe called "AutoROI". VTABLE 0x100dbe38 // maybe called "AutoROI". VTABLE 0x100dbe38
@ -15,6 +17,9 @@ class LegoROI : public ViewROI {
public: public:
LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList, MxTime p_time); LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList, MxTime p_time);
// Note: Actually part of parent class (doesn't exist yet)
virtual void UpdateWorldBoundingVolumes() override; // vtable+0x18
__declspec(dllexport) void SetDisplayBB(MxS32 p_displayBB); __declspec(dllexport) void SetDisplayBB(MxS32 p_displayBB);
__declspec(dllexport) static void configureLegoROI(MxS32 p_roi); __declspec(dllexport) static void configureLegoROI(MxS32 p_roi);
@ -32,12 +37,13 @@ class LegoROI : public ViewROI {
void FUN_100a46b0(Matrix4& p_transform); void FUN_100a46b0(Matrix4& p_transform);
void FUN_100a58f0(Matrix4& p_transform); void FUN_100a58f0(Matrix4& p_transform);
// Note: Actually part of parent class (doesn't exist yet) inline LegoEntity* GetUnknown0x104() { return m_unk0x104; }
virtual void UpdateWorldBoundingVolumes() override; // vtable+0x18 inline void SetUnknown0x104(LegoEntity* p_unk0x104) { m_unk0x104 = p_unk0x104; }
private: private:
undefined m_pad[0x28]; // 0xe0 undefined m_pad[0x24]; // 0xe0
MxTime m_time; // 0x108 LegoEntity* m_unk0x104; // 0x104
MxTime m_time; // 0x108
}; };
#endif // LEGOROI_H #endif // LEGOROI_H

View file

@ -24,7 +24,7 @@ class MxMediaManager : public MxCore {
MxResult Init(); MxResult Init();
protected: protected:
MxPresenterList* m_presenters; MxPresenterList* m_presenters; // 0x8
MxThread* m_thread; // 0xc MxThread* m_thread; // 0xc
MxCriticalSection m_criticalSection; // 0x10 MxCriticalSection m_criticalSection; // 0x10
}; };

View file

@ -28,6 +28,7 @@ class OrientableROI : public ROI {
virtual void UpdateWorldData(const MxMatrix& p_transform); // vtable+0x28 virtual void UpdateWorldData(const MxMatrix& p_transform); // vtable+0x28
virtual void UpdateWorldVelocity(); // vtable+0x2c virtual void UpdateWorldVelocity(); // vtable+0x2c
const MxMatrix& GetLocal2World() const { return m_local2world; }
const float* GetWorldPosition() const { return m_local2world[3]; } const float* GetWorldPosition() const { return m_local2world[3]; }
const float* GetWorldDirection() const { return m_local2world[2]; } const float* GetWorldDirection() const { return m_local2world[2]; }
const float* GetWorldUp() const { return m_local2world[1]; } const float* GetWorldUp() const { return m_local2world[1]; }