From 81e8b4452ce39b1a4b1fc1e8befd3443111e76d0 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 5 Jun 2024 13:01:47 -0400 Subject: [PATCH] Implement/match LegoEntity::SwitchSound --- LEGO1/lego/legoomni/include/legoactors.h | 2 +- .../legoomni/include/legobuildingmanager.h | 2 +- .../legoomni/include/legocharactermanager.h | 3 +- LEGO1/lego/legoomni/include/legoentity.h | 2 +- .../lego/legoomni/include/legoplantmanager.h | 1 + .../src/build/legobuildingmanager.cpp | 2 +- .../src/common/legocharactermanager.cpp | 33 ++++++++++++++++--- .../legoomni/src/common/legoplantmanager.cpp | 7 ++++ LEGO1/lego/legoomni/src/entity/legoentity.cpp | 25 +++++++++++--- 9 files changed, 62 insertions(+), 15 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoactors.h b/LEGO1/lego/legoomni/include/legoactors.h index 46f288b5..5a77dc9f 100644 --- a/LEGO1/lego/legoomni/include/legoactors.h +++ b/LEGO1/lego/legoomni/include/legoactors.h @@ -22,7 +22,7 @@ struct LegoActorInfo { const char* m_name; // 0x00 LegoROI* m_roi; // 0x04 LegoExtraActor* m_actor; // 0x08 - MxS32 m_unk0x0c; // 0x0c + MxS32 m_sound; // 0x0c MxS32 m_unk0x10; // 0x10 MxU8 m_mood; // 0x14 Part m_parts[10]; // 0x18 diff --git a/LEGO1/lego/legoomni/include/legobuildingmanager.h b/LEGO1/lego/legoomni/include/legobuildingmanager.h index cf7a4099..637b1776 100644 --- a/LEGO1/lego/legoomni/include/legobuildingmanager.h +++ b/LEGO1/lego/legoomni/include/legobuildingmanager.h @@ -73,7 +73,7 @@ class LegoBuildingManager : public MxCore { MxResult Read(LegoStorage* p_storage); LegoBuildingInfo* GetInfo(LegoEntity* p_entity); MxBool SwitchVariant(LegoEntity* p_entity); - MxBool FUN_1002fe40(LegoEntity* p_entity); + MxBool SwitchSound(LegoEntity* p_entity); MxBool FUN_1002fe80(LegoEntity* p_entity); MxBool FUN_1002fed0(LegoEntity* p_entity); MxU32 GetBuildingEntityId(LegoEntity* p_entity); diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index e8d5abee..79dcf283 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -69,7 +69,8 @@ class LegoCharacterManager { LegoExtraActor* GetExtraActor(const char* p_name); LegoActorInfo* GetActorInfo(const char* p_name); LegoActorInfo* GetActorInfo(LegoROI* p_roi); - MxBool SwitchHat(LegoROI* p_roi); + MxBool SwitchVariant(LegoROI* p_roi); + MxBool SwitchSound(LegoROI* p_roi); MxU32 FUN_10085120(LegoROI* p_roi); MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und); MxU8 GetMood(LegoROI* p_roi); diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 4435ac19..5a21eebc 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -67,7 +67,7 @@ class LegoEntity : public MxEntity { virtual void ClickSound(MxBool p_und); // vtable+0x34 virtual void ClickAnimation(); // vtable+0x38 virtual void SwitchVariant(); // vtable+0x3c - virtual void VTable0x40(); // vtable+0x40 + virtual void SwitchSound(); // vtable+0x40 virtual void VTable0x44(); // vtable+0x44 virtual void VTable0x48(LegoROI* p_roi); // vtable+0x48 virtual void VTable0x4c(); // vtable+0x4c diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index 0c9e18eb..1411e9fb 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -30,6 +30,7 @@ class LegoPlantManager : public MxCore { void Write(LegoStorage* p_storage); MxResult Read(LegoStorage* p_storage); MxBool FUN_100269e0(LegoEntity* p_entity); + MxBool SwitchSound(LegoEntity* p_entity); MxU32 FUN_10026b70(LegoEntity* p_entity); MxU32 FUN_10026ba0(LegoEntity* p_entity, MxBool); void FUN_10026c50(LegoEntity* p_entity); diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index d6cc74d1..8b2d12fb 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -471,7 +471,7 @@ MxBool LegoBuildingManager::SwitchVariant(LegoEntity* p_entity) // FUNCTION: LEGO1 0x1002fe40 // FUNCTION: BETA10 0x100641d3 -MxBool LegoBuildingManager::FUN_1002fe40(LegoEntity* p_entity) +MxBool LegoBuildingManager::SwitchSound(LegoEntity* p_entity) { MxBool result = FALSE; LegoBuildingInfo* info = GetInfo(p_entity); diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index eca959d9..76cb624a 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -21,6 +21,9 @@ DECOMP_SIZE_ASSERT(LegoCharacter, 0x08) DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08) +// GLOBAL: LEGO1 0x100fc4d4 +MxU32 g_maxSound = 9; + // GLOBAL: LEGO1 0x100fc4e0 MxU32 g_unk0x100fc4e0 = 10; @@ -113,7 +116,7 @@ MxResult LegoCharacterManager::Write(LegoStorage* p_storage) for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { LegoActorInfo* info = &g_actorInfo[i]; - if (p_storage->Write(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) { + if (p_storage->Write(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) { goto done; } if (p_storage->Write(&info->m_unk0x10, sizeof(info->m_unk0x10)) != SUCCESS) { @@ -168,7 +171,7 @@ MxResult LegoCharacterManager::Read(LegoStorage* p_storage) for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { LegoActorInfo* info = &g_actorInfo[i]; - if (p_storage->Read(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) { + if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) { goto done; } if (p_storage->Read(&info->m_unk0x10, sizeof(info->m_unk0x10)) != SUCCESS) { @@ -450,7 +453,7 @@ LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key) if (!strcmpi(p_key, "pep")) { LegoActorInfo* pepper = GetActorInfo("pepper"); - info->m_unk0x0c = pepper->m_unk0x0c; + info->m_sound = pepper->m_sound; info->m_unk0x10 = pepper->m_unk0x10; info->m_mood = pepper->m_mood; @@ -703,7 +706,7 @@ LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name) } // FUNCTION: LEGO1 0x10084ec0 -MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi) +MxBool LegoCharacterManager::SwitchVariant(LegoROI* p_roi) { LegoActorInfo* info = GetActorInfo(p_roi->GetName()); @@ -756,6 +759,26 @@ MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi) return TRUE; } +// FUNCTION: LEGO1 0x10085090 +// FUNCTION: BETA10 0x100766f6 +MxBool LegoCharacterManager::SwitchSound(LegoROI* p_roi) +{ + MxBool result = FALSE; + LegoActorInfo* info = GetActorInfo(p_roi); + + if (info != NULL) { + info->m_sound++; + + if (info->m_sound >= g_maxSound) { + info->m_sound = 0; + } + + result = TRUE; + } + + return result; +} + // FUNCTION: LEGO1 0x10085120 // FUNCTION: BETA10 0x1007680c MxU32 LegoCharacterManager::FUN_10085120(LegoROI* p_roi) @@ -779,7 +802,7 @@ MxU32 LegoCharacterManager::FUN_10085140(LegoROI* p_roi, MxBool p_und) } if (info != NULL) { - return info->m_unk0x0c + g_unk0x100fc4d8; + return info->m_sound + g_unk0x100fc4d8; } return 0; diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index bcda73cd..db7ff921 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -56,6 +56,13 @@ MxBool LegoPlantManager::FUN_100269e0(LegoEntity* p_entity) return FALSE; } +// STUB: LEGO1 0x10026ad0 +MxBool LegoPlantManager::SwitchSound(LegoEntity* p_entity) +{ + // TODO + return FALSE; +} + // STUB: LEGO1 0x10026b70 MxU32 LegoPlantManager::FUN_10026b70(LegoEntity* p_entity) { diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 48ec6d62..729738cd 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -325,7 +325,7 @@ void LegoEntity::SwitchVariant() { switch (m_type) { case e_actor: - CharacterManager()->SwitchHat(m_roi); + CharacterManager()->SwitchVariant(m_roi); break; case e_unk1: break; @@ -341,11 +341,26 @@ void LegoEntity::SwitchVariant() ClickAnimation(); } -// STUB: LEGO1 0x10011360 +// FUNCTION: LEGO1 0x10011360 // FUNCTION: BETA10 0x1007f411 -void LegoEntity::VTable0x40() +void LegoEntity::SwitchSound() { - // TODO + switch (m_type) { + case e_actor: + CharacterManager()->SwitchSound(m_roi); + break; + case e_unk1: + break; + case e_plant: + PlantManager()->SwitchSound(this); + break; + case e_building: + BuildingManager()->SwitchSound(this); + break; + } + + ClickSound(FALSE); + ClickAnimation(); } // STUB: LEGO1 0x100113c0 @@ -398,7 +413,7 @@ MxLong LegoEntity::Notify(MxParam& p_param) } break; case LegoActor::c_mama: - VTable0x40(); + SwitchSound(); break; case LegoActor::c_papa: VTable0x44();