diff --git a/LEGO1/lego/legoomni/include/legocameracontroller.h b/LEGO1/lego/legoomni/include/legocameracontroller.h index 48256789..7d038d02 100644 --- a/LEGO1/lego/legoomni/include/legocameracontroller.h +++ b/LEGO1/lego/legoomni/include/legocameracontroller.h @@ -37,7 +37,7 @@ public: virtual MxResult Create(); // vtable+0x44 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 GetWorldLocation(); Mx3DPointFloat GetWorldDirection(); diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 56960110..c8e3df35 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -12,10 +12,19 @@ // SIZE 0x68 (probably) class LegoEntity : public MxEntity { public: + enum { + Flag_Bit1 = 0x01 + }; + // Inlined at 0x100853f7 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 @@ -58,15 +67,15 @@ protected: void Init(); void SetWorld(); - undefined m_unk0x10; - undefined m_unk0x11; + undefined m_unk0x10; // 0x10 + MxU8 m_flags; // 0x11 Mx3DPointFloat m_worldLocation; // 0x14 Mx3DPointFloat m_worldDirection; // 0x28 Mx3DPointFloat m_worldUp; // 0x3c MxFloat m_worldSpeed; // 0x50 LegoROI* m_roi; // 0x54 MxBool m_cameraFlag; // 0x58 - undefined m_unk0x59; + undefined m_unk0x59; // 0x59 // For tokens from the extra string that look like this: // "Action:openram;\lego\scripts\Race\CarRaceR;0" ExtraActionType m_actionType; // 0x5c @@ -74,4 +83,7 @@ protected: MxS32 m_actionArgNumber; // 0x64 }; +// SYNTHETIC: LEGO1 0x1000c3b0 +// LegoEntity::`scalar deleting destructor' + #endif // LEGOENTITY_H diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index deab2d44..2199afdf 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -114,6 +114,7 @@ public: MxBackgroundAudioManager* GetBackgroundAudioManager() { return m_bkgAudioManager; } MxTransitionManager* GetTransitionManager() { return m_transitionManager; } MxDSAction& GetCurrentAction() { return m_action; } + LegoUnkSaveDataWriter* GetUnkSaveDataWriter() { return m_saveDataWriter; } inline void SetNavController(LegoNavController* p_navController) { m_navController = p_navController; } inline void SetWorld(LegoWorld* p_currentWorld) { m_currentWorld = p_currentWorld; } @@ -157,6 +158,7 @@ LegoControlManager* ControlManager(); IslePathActor* GetCurrentVehicle(); LegoPlantManager* PlantManager(); LegoWorld* GetCurrentWorld(); +LegoUnkSaveDataWriter* GetUnkSaveDataWriter(); GifManager* GetGifManager(); void FUN_10015820(MxU32, MxU32); LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid); diff --git a/LEGO1/lego/legoomni/include/legounksavedatawriter.h b/LEGO1/lego/legoomni/include/legounksavedatawriter.h index 039058e6..240bef11 100644 --- a/LEGO1/lego/legoomni/include/legounksavedatawriter.h +++ b/LEGO1/lego/legoomni/include/legounksavedatawriter.h @@ -4,6 +4,7 @@ #include "decomp.h" #include "mxtypes.h" +class LegoROI; class LegoStream; struct LegoSaveDataEntry3 { @@ -32,7 +33,9 @@ struct LegoSaveDataEntry3 { }; class LegoUnkSaveDataWriter { +public: MxResult WriteSaveData3(LegoStream* p_stream); + void FUN_10083db0(LegoROI* p_roi); }; #endif // LEGOUNKSAVEDATAWRITER_H diff --git a/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp b/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp index 7fcdce59..4a102fcf 100644 --- a/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp +++ b/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp @@ -29,7 +29,6 @@ void LegoFullScreenMovie::SetValue(const char* p_option) LegoVideoManager* videomanager = VideoManager(); if (videomanager) { - if (!strcmp(m_value.GetData(), g_strEnable)) { videomanager->EnableFullScreenMovie(TRUE); return; diff --git a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp index 2e4d1804..a6e7e135 100644 --- a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp +++ b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp @@ -47,3 +47,9 @@ MxResult LegoUnkSaveDataWriter::WriteSaveData3(LegoStream* p_stream) } return result; } + +// STUB: LEGO1 0x10083db0 +void LegoUnkSaveDataWriter::FUN_10083db0(LegoROI* p_roi) +{ + // TODO +} diff --git a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp index b30a78b8..d48d22ff 100644 --- a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp @@ -78,7 +78,7 @@ void LegoCameraController::SetWorldTransform(const Vector3& p_at, const Vector3& } // STUB: LEGO1 0x100123e0 -void LegoCameraController::FUN_100123e0(MxMatrix& p_transform, MxU32) +void LegoCameraController::FUN_100123e0(const MxMatrix& p_transform, MxU32) { } diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 7e377671..b4615704 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -2,17 +2,13 @@ #include "define.h" #include "legoomni.h" +#include "legounksavedatawriter.h" #include "legoutil.h" +#include "legovideomanager.h" #include "legoworld.h" DECOMP_SIZE_ASSERT(LegoEntity, 0x68) -// FUNCTION: LEGO1 0x1000c290 -LegoEntity::~LegoEntity() -{ - Destroy(TRUE); -} - // FUNCTION: LEGO1 0x100105f0 void LegoEntity::Init() { @@ -20,10 +16,10 @@ void LegoEntity::Init() m_worldDirection.Fill(0); m_worldSpeed = 0; m_roi = NULL; - m_cameraFlag = 0; + m_cameraFlag = FALSE; m_actionArgString = NULL; m_unk0x10 = 0; - m_unk0x11 = 0; + m_flags = 0; m_actionType = ExtraActionType_unknown; m_actionArgNumber = -1; m_unk0x59 = 4; @@ -50,11 +46,22 @@ MxResult LegoEntity::Create(MxDSAction& p_dsAction) return SUCCESS; } -// STUB: LEGO1 0x10010810 +// FUNCTION: LEGO1 0x10010810 void LegoEntity::Destroy(MxBool p_fromDestructor) { 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; @@ -82,9 +89,13 @@ void LegoEntity::SetLocation(Mx3DPointFloat& p_location, Mx3DPointFloat& p_direc // TODO } -// STUB: LEGO1 0x10010c30 +// FUNCTION: LEGO1 0x10010c30 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 diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 9cb67852..e0d292b4 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -181,6 +181,12 @@ LegoWorld* GetCurrentWorld() return LegoOmni::GetInstance()->GetCurrentOmniWorld(); } +// FUNCTION: LEGO1 0x100157b0 +LegoUnkSaveDataWriter* GetUnkSaveDataWriter() +{ + return LegoOmni::GetInstance()->GetUnkSaveDataWriter(); +} + // FUNCTION: LEGO1 0x100157e0 LegoPlantManager* PlantManager() { diff --git a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp index 6fbc7803..53731a1a 100644 --- a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp @@ -49,12 +49,13 @@ void LegoPalettePresenter::Destroy() MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk) { MxU8 buffer[40]; - RGBQUAD palleteData[256]; + RGBQUAD palette[256]; MxResult result = FAILURE; + LegoMemoryStream stream((char*) p_chunk->GetData()); - if (stream.Read(buffer, 40) == SUCCESS) { - if (stream.Read(palleteData, sizeof(RGBQUAD) * 256) == SUCCESS) { - m_palette = new MxPalette(palleteData); + if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) { + if (stream.Read(palette, sizeof(palette)) == SUCCESS) { + m_palette = new MxPalette(palette); if (m_palette) { result = SUCCESS; } diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index 17d66ef4..d257398e 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -6,6 +6,8 @@ typedef MxBool (*ROIHandler)(char*, char*, MxU32); +class LegoEntity; + // Note: There is an extra class between LegoROI and ViewROI, // maybe called "AutoROI". VTABLE 0x100dbe38 @@ -15,6 +17,9 @@ class LegoROI : public ViewROI { public: 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) static void configureLegoROI(MxS32 p_roi); @@ -32,12 +37,13 @@ public: void FUN_100a46b0(Matrix4& p_transform); void FUN_100a58f0(Matrix4& p_transform); - // Note: Actually part of parent class (doesn't exist yet) - virtual void UpdateWorldBoundingVolumes() override; // vtable+0x18 + inline LegoEntity* GetUnknown0x104() { return m_unk0x104; } + inline void SetUnknown0x104(LegoEntity* p_unk0x104) { m_unk0x104 = p_unk0x104; } private: - undefined m_pad[0x28]; // 0xe0 - MxTime m_time; // 0x108 + undefined m_pad[0x24]; // 0xe0 + LegoEntity* m_unk0x104; // 0x104 + MxTime m_time; // 0x108 }; #endif // LEGOROI_H diff --git a/LEGO1/omni/include/mxmediamanager.h b/LEGO1/omni/include/mxmediamanager.h index 1f2e31af..aefbd9f6 100644 --- a/LEGO1/omni/include/mxmediamanager.h +++ b/LEGO1/omni/include/mxmediamanager.h @@ -24,7 +24,7 @@ public: MxResult Init(); protected: - MxPresenterList* m_presenters; + MxPresenterList* m_presenters; // 0x8 MxThread* m_thread; // 0xc MxCriticalSection m_criticalSection; // 0x10 }; diff --git a/LEGO1/realtime/orientableroi.h b/LEGO1/realtime/orientableroi.h index 71e0fc71..821a2978 100644 --- a/LEGO1/realtime/orientableroi.h +++ b/LEGO1/realtime/orientableroi.h @@ -28,6 +28,7 @@ public: virtual void UpdateWorldData(const MxMatrix& p_transform); // vtable+0x28 virtual void UpdateWorldVelocity(); // vtable+0x2c + const MxMatrix& GetLocal2World() const { return m_local2world; } const float* GetWorldPosition() const { return m_local2world[3]; } const float* GetWorldDirection() const { return m_local2world[2]; } const float* GetWorldUp() const { return m_local2world[1]; }