From 180a1e6360586c86a1f618ea465af2bd7060eb7a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 26 Apr 2024 10:03:13 -0400 Subject: [PATCH] Define LegoEntity::Type enum (#854) * Define LegoEntity::Type enum * Use enum constant --- LEGO1/lego/legoomni/include/legoentity.h | 14 +++++-- LEGO1/lego/legoomni/include/legogamestate.h | 2 +- .../src/common/legoanimationmanager.cpp | 2 +- .../src/common/legocharactermanager.cpp | 4 +- LEGO1/lego/legoomni/src/entity/legoactor.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legoentity.cpp | 38 ++++++++++--------- .../legoomni/src/video/legomodelpresenter.cpp | 2 +- 7 files changed, 37 insertions(+), 27 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index c3b2bcf0..9b44c4d8 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -12,6 +12,14 @@ // SIZE 0x68 class LegoEntity : public MxEntity { public: + enum Type { + e_character = 0, + e_unk1, + e_plant, + e_building, + e_unk4 + }; + enum { c_bit1 = 0x01, c_bit2 = 0x02 @@ -64,7 +72,7 @@ class LegoEntity : public MxEntity { virtual void VTable0x4c(); // vtable+0x4c void FUN_10010c30(); - void FUN_100114e0(MxU8 p_unk0x59); + void SetType(MxU8 p_type); void SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool p_und); Mx3DPointFloat GetWorldDirection(); Mx3DPointFloat GetWorldUp(); @@ -75,7 +83,7 @@ class LegoEntity : public MxEntity { inline MxU8 GetFlags() { return m_flags; } inline MxFloat GetWorldSpeed() { return m_worldSpeed; } inline LegoROI* GetROI() { return m_roi; } - inline MxU8 GetUnknown0x59() { return m_unk0x59; } + inline MxU8 GetType() { return m_type; } inline MxBool GetCameraFlag() { return m_cameraFlag; } inline void SetFlags(MxU8 p_flags) { m_flags = p_flags; } @@ -96,7 +104,7 @@ class LegoEntity : public MxEntity { MxFloat m_worldSpeed; // 0x50 LegoROI* m_roi; // 0x54 MxBool m_cameraFlag; // 0x58 - MxU8 m_unk0x59; // 0x59 + MxU8 m_type; // 0x59 // For tokens from the extra string that look like this: // "Action:openram;\lego\scripts\Race\CarRaceR;0" Extra::ActionType m_actionType; // 0x5c diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 80b6e2d0..08c1d5e7 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -165,7 +165,7 @@ class LegoGameState { inline Area GetUnknown0x42c() { return m_unk0x42c; } inline History* GetHistory() { return &m_history; } - inline void SetDirty(MxBool p_dirty) { m_isDirty = p_dirty; } + inline void SetDirty(MxBool p_isDirty) { m_isDirty = p_isDirty; } inline void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; } inline void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; } inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index fa3ce08b..1693be7b 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -502,7 +502,7 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt MxResult result = FAILURE; LegoROI* roi = p_entity->GetROI(); - if (p_entity->GetUnknown0x59() == 0) { + if (p_entity->GetType() == LegoEntity::e_character) { LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); if (actor) { diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 8bc6ecc2..ba2ddde5 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -211,7 +211,7 @@ LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity) LegoExtraActor* actor = new LegoExtraActor(); actor->SetROI(character->m_roi, FALSE, FALSE); - actor->FUN_100114e0(0); + actor->SetType(LegoEntity::e_character); actor->SetFlag(LegoActor::c_bit2); GetData(p_key)->m_actor = actor; } @@ -783,7 +783,7 @@ LegoROI* LegoCharacterManager::FUN_10085210(const char* p_name, const char* p_lo LegoEntity* entity = new LegoEntity(); entity->SetROI(roi, FALSE, FALSE); - entity->FUN_100114e0(4); + entity->SetType(LegoEntity::e_unk4); entity->SetFlag(LegoActor::c_bit2); } } diff --git a/LEGO1/lego/legoomni/src/entity/legoactor.cpp b/LEGO1/lego/legoomni/src/entity/legoactor.cpp index 3d41dc34..6c27fd34 100644 --- a/LEGO1/lego/legoomni/src/entity/legoactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoactor.cpp @@ -127,7 +127,7 @@ void LegoActor::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2) for (MxU32 i = 1; i <= _countof(g_actorNames) - 1; i++) { if (!strcmpi(name, g_actorNames[i])) { - m_unk0x59 = 0; + m_type = e_character; m_actorId = i; break; } diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 78dae287..a55693f9 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -27,7 +27,7 @@ void LegoEntity::Init() m_flags = 0; m_actionType = Extra::ActionType::e_unknown; m_targetEntityId = -1; - m_unk0x59 = 4; + m_type = e_unk4; } // FUNCTION: LEGO1 0x10010650 @@ -247,16 +247,16 @@ void LegoEntity::VTable0x34(MxBool p_und) MxU32 objectId = 0; const LegoChar* roiName = m_roi->GetName(); - switch (m_unk0x59) { - case 0: + switch (m_type) { + case e_character: objectId = CharacterManager()->FUN_10085140(m_roi, p_und); break; - case 1: + case e_unk1: break; - case 2: + case e_plant: objectId = PlantManager()->FUN_10026ba0(this, p_und); break; - case 3: + case e_building: objectId = BuildingManager()->FUN_1002ff40(this, p_und); break; } @@ -280,14 +280,16 @@ void LegoEntity::VTable0x38() // FUNCTION: LEGO1 0x10011300 void LegoEntity::VTable0x3c() { - switch (m_unk0x59) { - case 0: + switch (m_type) { + case e_character: CharacterManager()->SwitchHat(m_roi); break; - case 2: + case e_unk1: + break; + case e_plant: PlantManager()->FUN_100269e0(this); break; - case 3: + case e_building: BuildingManager()->FUN_1002fdb0(this); break; } @@ -321,9 +323,9 @@ void LegoEntity::VTable0x4c() } // FUNCTION: LEGO1 0x100114e0 -void LegoEntity::FUN_100114e0(MxU8 p_unk0x59) +void LegoEntity::SetType(MxU8 p_type) { - m_unk0x59 = p_unk0x59; + m_type = p_type; } // FUNCTION: LEGO1 0x100114f0 @@ -359,17 +361,17 @@ MxLong LegoEntity::Notify(MxParam& p_param) VTable0x4c(); break; case 6: - switch (m_unk0x59) { - case 0: - case 1: + switch (m_type) { + case e_character: + case e_unk1: break; - case 2: + case e_plant: PlantManager()->FUN_10026c50(this); break; - case 3: + case e_building: BuildingManager()->FUN_10030000(this); break; - case 4: + case e_unk4: break; } } diff --git a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp index 7e76154d..7417748f 100644 --- a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp @@ -256,7 +256,7 @@ void LegoModelPresenter::ReadyTickle() ->SetFlags( ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() & ~LegoEntity::c_bit2 ); - ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->FUN_100114e0(0); + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->SetType(LegoEntity::e_character); } ParseExtra();