From f6c923a84e1862248114c016d521521192a54880 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 5 Jun 2024 13:00:46 -0400 Subject: [PATCH] Implement/match LegoEntity::ClickAnimation (#994) * Implement/match LegoEntity::VTable0x38 * Update names --- .../legoomni/include/legobuildingmanager.h | 5 +- .../legoomni/include/legocharactermanager.h | 1 + LEGO1/lego/legoomni/include/legoentity.h | 6 +- LEGO1/lego/legoomni/include/legomain.h | 4 +- .../lego/legoomni/include/legoplantmanager.h | 4 +- .../src/build/legobuildingmanager.cpp | 2 +- .../src/common/legocharactermanager.cpp | 16 +++++ .../legoomni/src/common/legoplantmanager.cpp | 9 ++- LEGO1/lego/legoomni/src/common/misc.cpp | 4 +- LEGO1/lego/legoomni/src/entity/legoentity.cpp | 67 ++++++++++++++++--- 10 files changed, 95 insertions(+), 23 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legobuildingmanager.h b/LEGO1/lego/legoomni/include/legobuildingmanager.h index bec82ceb..cf7a4099 100644 --- a/LEGO1/lego/legoomni/include/legobuildingmanager.h +++ b/LEGO1/lego/legoomni/include/legobuildingmanager.h @@ -72,12 +72,12 @@ public: MxResult Write(LegoStorage* p_storage); MxResult Read(LegoStorage* p_storage); LegoBuildingInfo* GetInfo(LegoEntity* p_entity); - MxBool IncrementVariant(LegoEntity* p_entity); + MxBool SwitchVariant(LegoEntity* p_entity); MxBool FUN_1002fe40(LegoEntity* p_entity); MxBool FUN_1002fe80(LegoEntity* p_entity); MxBool FUN_1002fed0(LegoEntity* p_entity); MxU32 GetBuildingEntityId(LegoEntity* p_entity); - MxU32 FUN_1002ff40(LegoEntity*, MxBool); + MxU32 FUN_1002ff40(LegoEntity* p_entity, MxBool); MxBool FUN_10030000(LegoEntity* p_entity); MxBool FUN_10030030(MxS32 p_index); MxBool FUN_10030110(LegoBuildingInfo* p_data); @@ -89,6 +89,7 @@ public: void FUN_100307b0(LegoEntity* p_entity, MxS32 p_adjust); static void FUN_10030800(); + static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; } // SYNTHETIC: LEGO1 0x1002f940 // LegoBuildingManager::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index 1032f8b3..e8d5abee 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -70,6 +70,7 @@ public: LegoActorInfo* GetActorInfo(const char* p_name); LegoActorInfo* GetActorInfo(LegoROI* p_roi); MxBool SwitchHat(LegoROI* p_roi); + MxU32 FUN_10085120(LegoROI* p_roi); MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und); MxU8 GetMood(LegoROI* p_roi); LegoROI* CreateAutoROI(const char* p_name, const char* p_lodName, MxBool p_createEntity); diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 5fcced29..4435ac19 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -64,9 +64,9 @@ public: // 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 ClickSound(MxBool p_und); // vtable+0x34 + virtual void ClickAnimation(); // vtable+0x38 + virtual void SwitchVariant(); // vtable+0x3c virtual void VTable0x40(); // vtable+0x40 virtual void VTable0x44(); // vtable+0x44 virtual void VTable0x48(LegoROI* p_roi); // vtable+0x48 diff --git a/LEGO1/lego/legoomni/include/legomain.h b/LEGO1/lego/legoomni/include/legomain.h index 4a2fad65..e3264e06 100644 --- a/LEGO1/lego/legoomni/include/legomain.h +++ b/LEGO1/lego/legoomni/include/legomain.h @@ -128,9 +128,9 @@ public: LegoWorld* GetCurrentWorld() { return m_currentWorld; } LegoNavController* GetNavController() { return m_navController; } LegoPathActor* GetCurrentActor() { return m_currentActor; } - LegoPlantManager* GetLegoPlantManager() { return m_plantManager; } + LegoPlantManager* GetPlantManager() { return m_plantManager; } LegoAnimationManager* GetAnimationManager() { return m_animationManager; } - LegoBuildingManager* GetLegoBuildingManager() { return m_buildingManager; } + LegoBuildingManager* GetBuildingManager() { return m_buildingManager; } LegoGameState* GetGameState() { return m_gameState; } MxBackgroundAudioManager* GetBackgroundAudioManager() { return m_bkgAudioManager; } MxTransitionManager* GetTransitionManager() { return m_transitionManager; } diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index e2eccd80..0c9e18eb 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -30,11 +30,13 @@ public: void Write(LegoStorage* p_storage); MxResult Read(LegoStorage* p_storage); MxBool FUN_100269e0(LegoEntity* p_entity); - MxU32 FUN_10026ba0(LegoEntity*, MxBool); + MxU32 FUN_10026b70(LegoEntity* p_entity); + MxU32 FUN_10026ba0(LegoEntity* p_entity, MxBool); void FUN_10026c50(LegoEntity* p_entity); void FUN_10027120(); static void SetCustomizeAnimFile(const char* p_value); + static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; } // SYNTHETIC: LEGO1 0x100262a0 // LegoPlantManager::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index 863520da..d6cc74d1 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -441,7 +441,7 @@ LegoBuildingInfo* LegoBuildingManager::GetInfo(LegoEntity* p_entity) // FUNCTION: LEGO1 0x1002fdb0 // FUNCTION: BETA10 0x10064101 -MxBool LegoBuildingManager::IncrementVariant(LegoEntity* p_entity) +MxBool LegoBuildingManager::SwitchVariant(LegoEntity* p_entity) { if (g_buildingManagerConfig <= 1) { return TRUE; diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index dc48d9b5..eca959d9 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 0x100fc4e0 +MxU32 g_unk0x100fc4e0 = 10; + // GLOBAL: LEGO1 0x100fc4e4 char* LegoCharacterManager::g_customizeAnimFile = NULL; @@ -753,6 +756,19 @@ MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi) return TRUE; } +// FUNCTION: LEGO1 0x10085120 +// FUNCTION: BETA10 0x1007680c +MxU32 LegoCharacterManager::FUN_10085120(LegoROI* p_roi) +{ + LegoActorInfo* info = GetActorInfo(p_roi); + + if (info != NULL) { + return info->m_unk0x10 + g_unk0x100fc4e0; + } + + return 0; +} + // FUNCTION: LEGO1 0x10085140 MxU32 LegoCharacterManager::FUN_10085140(LegoROI* p_roi, MxBool p_und) { diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index 3e7aeed8..bcda73cd 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -56,8 +56,15 @@ MxBool LegoPlantManager::FUN_100269e0(LegoEntity* p_entity) return FALSE; } +// STUB: LEGO1 0x10026b70 +MxU32 LegoPlantManager::FUN_10026b70(LegoEntity* p_entity) +{ + // TODO + return 0; +} + // STUB: LEGO1 0x10026ba0 -MxU32 LegoPlantManager::FUN_10026ba0(LegoEntity*, MxBool) +MxU32 LegoPlantManager::FUN_10026ba0(LegoEntity* p_entity, MxBool) { // TODO return 0; diff --git a/LEGO1/lego/legoomni/src/common/misc.cpp b/LEGO1/lego/legoomni/src/common/misc.cpp index 34060c5f..2427097c 100644 --- a/LEGO1/lego/legoomni/src/common/misc.cpp +++ b/LEGO1/lego/legoomni/src/common/misc.cpp @@ -93,13 +93,13 @@ ViewManager* GetViewManager() // FUNCTION: LEGO1 0x100157e0 LegoPlantManager* PlantManager() { - return LegoOmni::GetInstance()->GetLegoPlantManager(); + return LegoOmni::GetInstance()->GetPlantManager(); } // FUNCTION: LEGO1 0x100157f0 LegoBuildingManager* BuildingManager() { - return LegoOmni::GetInstance()->GetLegoBuildingManager(); + return LegoOmni::GetInstance()->GetBuildingManager(); } // FUNCTION: LEGO1 0x10015800 diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index cb426fac..48ec6d62 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -2,11 +2,13 @@ #include "3dmanager/lego3dmanager.h" #include "define.h" +#include "legoanimationmanager.h" #include "legobuildingmanager.h" #include "legocameracontroller.h" #include "legocharactermanager.h" #include "legoeventnotificationparam.h" #include "legogamestate.h" +#include "legomain.h" #include "legoplantmanager.h" #include "legoutils.h" #include "legovideomanager.h" @@ -245,11 +247,12 @@ void LegoEntity::ParseAction(char* p_extra) } // FUNCTION: LEGO1 0x10010f10 -void LegoEntity::VTable0x34(MxBool p_und) +// FUNCTION: BETA10 0x1007ee87 +void LegoEntity::ClickSound(MxBool p_und) { if (!GetUnknown0x10IsSet(c_altBit1)) { MxU32 objectId = 0; - const LegoChar* roiName = m_roi->GetName(); + const char* name = m_roi->GetName(); switch (m_type) { case e_actor: @@ -269,20 +272,56 @@ void LegoEntity::VTable0x34(MxBool p_und) MxDSAction action; action.SetAtomId(MxAtomId(CharacterManager()->GetCustomizeAnimFile(), e_lowerCase2)); action.SetObjectId(objectId); - action.AppendExtra(strlen(roiName) + 1, roiName); + action.AppendExtra(strlen(name) + 1, name); Start(&action); } } } -// STUB: LEGO1 0x10011070 -void LegoEntity::VTable0x38() +// FUNCTION: LEGO1 0x10011070 +// FUNCTION: BETA10 0x1007f062 +void LegoEntity::ClickAnimation() { - // TODO + if (!GetUnknown0x10IsSet(c_altBit1)) { + MxU32 objectId = 0; + MxDSAction action; + const char* name = m_roi->GetName(); + char extra[1024]; + + switch (m_type) { + case e_actor: + objectId = LegoOmni::GetInstance()->GetCharacterManager()->FUN_10085120(m_roi); + action.SetAtomId(MxAtomId(LegoCharacterManager::GetCustomizeAnimFile(), e_lowerCase2)); + sprintf(extra, "SUBST:actor_01:%s", name); + break; + case e_unk1: + break; + case e_plant: + objectId = LegoOmni::GetInstance()->GetPlantManager()->FUN_10026b70(this); + action.SetAtomId(MxAtomId(LegoPlantManager::GetCustomizeAnimFile(), e_lowerCase2)); + sprintf(extra, "SUBST:bush:%s:tree:%s:flwrred:%s:palm:%s", name, name, name, name); + break; + case e_building: + objectId = LegoOmni::GetInstance()->GetBuildingManager()->GetBuildingEntityId(this); + action.SetAtomId(MxAtomId(BuildingManager()->GetCustomizeAnimFile(), e_lowerCase2)); + sprintf(extra, "SUBST:haus1:%s", name); + break; + case e_autoROI: + break; + } + + if (objectId) { + action.SetObjectId(objectId); + action.AppendExtra(strlen(extra) + 1, extra); + LegoOmni::GetInstance()->GetAnimationManager()->StartEntityAction(action, this); + m_unk0x10 |= c_altBit1; + } + } } // FUNCTION: LEGO1 0x10011300 -void LegoEntity::VTable0x3c() +// FUNCTION: BETA10 0x1007f35a +void LegoEntity::SwitchVariant() { switch (m_type) { case e_actor: @@ -294,45 +333,51 @@ void LegoEntity::VTable0x3c() PlantManager()->FUN_100269e0(this); break; case e_building: - BuildingManager()->IncrementVariant(this); + BuildingManager()->SwitchVariant(this); break; } - VTable0x34(FALSE); - VTable0x38(); + ClickSound(FALSE); + ClickAnimation(); } // STUB: LEGO1 0x10011360 +// FUNCTION: BETA10 0x1007f411 void LegoEntity::VTable0x40() { // TODO } // STUB: LEGO1 0x100113c0 +// FUNCTION: BETA10 0x1007f4c8 void LegoEntity::VTable0x44() { // TODO } // STUB: LEGO1 0x10011420 +// FUNCTION: BETA10 0x1007f57f void LegoEntity::VTable0x48(LegoROI* p_roi) { // TODO } // STUB: LEGO1 0x10011470 +// FUNCTION: BETA10 0x1007f62c void LegoEntity::VTable0x4c() { // TODO } // FUNCTION: LEGO1 0x100114e0 +// FUNCTION: BETA10 0x1007f6f0 void LegoEntity::SetType(MxU8 p_type) { m_type = p_type; } // FUNCTION: LEGO1 0x100114f0 +// FUNCTION: BETA10 0x1007f711 MxLong LegoEntity::Notify(MxParam& p_param) { LegoEventNotificationParam& param = (LegoEventNotificationParam&) p_param; @@ -349,7 +394,7 @@ MxLong LegoEntity::Notify(MxParam& p_param) case LegoActor::c_pepper: if (GameState()->GetCurrentAct() != LegoGameState::e_act2 && GameState()->GetCurrentAct() != LegoGameState::e_act3) { - VTable0x3c(); + SwitchVariant(); } break; case LegoActor::c_mama: