From f30ed0212b5b6de8a72114dd707dba982da75aec Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 6 Apr 2024 13:59:38 -0400 Subject: [PATCH] Implement/match LegoEntity::Notify (#778) --- .../legoomni/include/legobuildingmanager.h | 1 + LEGO1/lego/legoomni/include/legoentity.h | 18 ++--- .../include/legoeventnotificationparam.h | 1 + .../lego/legoomni/include/legoplantmanager.h | 1 + .../src/build/legobuildingmanager.cpp | 6 ++ .../legoomni/src/common/legoplantmanager.cpp | 6 ++ LEGO1/lego/legoomni/src/entity/legoentity.cpp | 72 ++++++++++++++++--- 7 files changed, 86 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legobuildingmanager.h b/LEGO1/lego/legoomni/include/legobuildingmanager.h index eb242399..2cdc7225 100644 --- a/LEGO1/lego/legoomni/include/legobuildingmanager.h +++ b/LEGO1/lego/legoomni/include/legobuildingmanager.h @@ -34,6 +34,7 @@ class LegoBuildingManager : public MxCore { MxResult Load(LegoStorage* p_storage); MxBool FUN_1002fdb0(LegoEntity* p_entity); MxU32 FUN_1002ff40(LegoROI*, MxBool); + void FUN_10030000(LegoEntity* p_entity); void FUN_10030590(); // SYNTHETIC: LEGO1 0x1002f940 diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index f8de2914..92571dc9 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -55,13 +55,13 @@ class LegoEntity : public MxEntity { // FUNCTION: LEGO1 0x10001090 virtual void SetWorldSpeed(MxFloat p_worldSpeed) { m_worldSpeed = p_worldSpeed; } // vtable+0x30 - virtual void VTable0x34(MxBool p_und); // vtable+0x34 - virtual void VTable0x38(); // vtable+0x38 - virtual void VTable0x3c(); // vtable+0x3c - virtual void VTable0x40(); // vtable+0x40 - virtual void VTable0x44(); // vtable+0x44 - virtual void VTable0x48(); // vtable+0x48 - virtual void VTable0x4c(); // vtable+0x4c + virtual void VTable0x34(MxBool p_und); // vtable+0x34 + virtual void VTable0x38(); // vtable+0x38 + virtual void VTable0x3c(); // vtable+0x3c + virtual void VTable0x40(); // vtable+0x40 + virtual void VTable0x44(); // vtable+0x44 + virtual void VTable0x48(LegoROI* p_roi); // vtable+0x48 + virtual void VTable0x4c(); // vtable+0x4c void FUN_10010c30(); void FUN_100114e0(MxU8 p_unk0x59); @@ -97,8 +97,8 @@ class LegoEntity : public MxEntity { // For tokens from the extra string that look like this: // "Action:openram;\lego\scripts\Race\CarRaceR;0" Extra::ActionType m_actionType; // 0x5c - char* m_actionArgString; // 0x60 - MxS32 m_actionArgNumber; // 0x64 + char* m_filename; // 0x60 + MxS32 m_targetEntityId; // 0x64 }; // SYNTHETIC: LEGO1 0x1000c3b0 diff --git a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h index 5563a5e9..b0591b9d 100644 --- a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h +++ b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h @@ -40,6 +40,7 @@ class LegoEventNotificationParam : public MxNotificationParam { { } + inline LegoROI* GetROI() { return m_roi; } inline MxU8 GetModifier() { return m_modifier; } inline MxU8 GetKey() const { return m_key; } diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index 1dcedd40..817157e7 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -31,6 +31,7 @@ class LegoPlantManager : public MxCore { MxResult Load(LegoStorage* p_storage); MxBool FUN_100269e0(LegoEntity* p_entity); MxU32 FUN_10026ba0(LegoROI*, MxBool); + void FUN_10026c50(LegoEntity* p_entity); void FUN_10027120(); static void SetCustomizeAnimFile(const char* p_value); diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index a97409d7..989beb05 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -89,6 +89,12 @@ void LegoBuildingManager::SetCustomizeAnimFile(const char* p_value) } } +// STUB: LEGO1 0x10030000 +void LegoBuildingManager::FUN_10030000(LegoEntity* p_entity) +{ + // TODO +} + // STUB: LEGO1 0x10030220 MxResult LegoBuildingManager::Tickle() { diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index cc09b332..b51a1ec7 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -82,6 +82,12 @@ void LegoPlantManager::SetCustomizeAnimFile(const char* p_value) } } +// STUB: LEGO1 0x10026c50 +void LegoPlantManager::FUN_10026c50(LegoEntity* p_entity) +{ + // TODO +} + // STUB: LEGO1 0x10026e00 MxResult LegoPlantManager::Tickle() { diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 506854e2..0349aa61 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -3,6 +3,7 @@ #include "define.h" #include "legobuildingmanager.h" #include "legocharactermanager.h" +#include "legogamestate.h" #include "legoplantmanager.h" #include "legoutils.h" #include "legovideomanager.h" @@ -21,11 +22,11 @@ void LegoEntity::Init() m_worldSpeed = 0; m_roi = NULL; m_cameraFlag = FALSE; - m_actionArgString = NULL; + m_filename = NULL; m_unk0x10 = 0; m_flags = 0; m_actionType = Extra::ActionType::e_unknown; - m_actionArgNumber = -1; + m_targetEntityId = -1; m_unk0x59 = 4; } @@ -96,7 +97,7 @@ void LegoEntity::Destroy(MxBool p_fromDestructor) } } - delete[] m_actionArgString; + delete[] m_filename; Init(); } @@ -229,11 +230,11 @@ void LegoEntity::ParseAction(char* p_extra) if (m_actionType != Extra::ActionType::e_exit) { char* token = strtok(NULL, g_parseExtraTokens); - m_actionArgString = new char[strlen(token) + 1]; - strcpy(m_actionArgString, token); + m_filename = new char[strlen(token) + 1]; + strcpy(m_filename, token); if (m_actionType != Extra::ActionType::e_run) { - m_actionArgNumber = atoi(strtok(NULL, g_parseExtraTokens)); + m_targetEntityId = atoi(strtok(NULL, g_parseExtraTokens)); } } } @@ -308,7 +309,7 @@ void LegoEntity::VTable0x44() } // STUB: LEGO1 0x10011420 -void LegoEntity::VTable0x48() +void LegoEntity::VTable0x48(LegoROI* p_roi) { // TODO } @@ -325,10 +326,61 @@ void LegoEntity::FUN_100114e0(MxU8 p_unk0x59) m_unk0x59 = p_unk0x59; } -// STUB: LEGO1 0x100114f0 +// FUNCTION: LEGO1 0x100114f0 MxLong LegoEntity::Notify(MxParam& p_param) { - // TODO + LegoEventNotificationParam& param = (LegoEventNotificationParam&) p_param; - return 0; + if (param.GetNotification() != c_notificationType11) { + return 0; + } + + if (m_actionType != Extra::e_unknown) { +#ifdef COMPAT_MODE + { + MxAtomId atom(m_filename, e_lowerCase2); + InvokeAction(m_actionType, atom, m_targetEntityId, this); + } +#else + InvokeAction(m_actionType, MxAtomId(m_filename, e_lowerCase2), m_targetEntityId, this); +#endif + } + else { + switch (GameState()->GetActorId()) { + case 1: + if (GameState()->GetCurrentAct() != LegoGameState::e_act2 && + GameState()->GetCurrentAct() != LegoGameState::e_act3) { + VTable0x3c(); + } + break; + case 2: + VTable0x40(); + break; + case 3: + VTable0x44(); + break; + case 4: + VTable0x48(param.GetROI()); + break; + case 5: + VTable0x4c(); + break; + case 6: + switch (m_unk0x59) { + case 0: + case 1: + break; + case 2: + PlantManager()->FUN_10026c50(this); + break; + case 3: + BuildingManager()->FUN_10030000(this); + break; + case 4: + break; + } + } + } + + return 1; }