From 5a6415e0cf37987d3ebdf7b82b72a56234dc3211 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:19:55 +0100 Subject: [PATCH] Implement/match `Act2Actor::FUN_10019b90` (#1222) Co-authored-by: jonschz --- .../lego/legoomni/include/legoplantmanager.h | 2 + LEGO1/lego/legoomni/src/actors/act2actor.cpp | 210 +++++++++++++++++- .../src/common/legobuildingmanager.cpp | 1 + .../legoomni/src/common/legoplantmanager.cpp | 21 ++ 4 files changed, 230 insertions(+), 4 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index 8c23fd84..dcb87ffb 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -46,8 +46,10 @@ class LegoPlantManager : public MxCore { MxBool SwitchMood(LegoEntity* p_entity); MxU32 GetAnimationId(LegoEntity* p_entity); MxU32 GetSoundId(LegoEntity* p_entity, MxBool p_state); + LegoPlantInfo* GetInfoArray(MxS32& p_length); MxBool FUN_10026c50(LegoEntity* p_entity); void ScheduleAnimation(LegoEntity* p_entity, MxLong p_length); + MxResult FUN_10026410(); void FUN_10027120(); void FUN_10027200(); diff --git a/LEGO1/lego/legoomni/src/actors/act2actor.cpp b/LEGO1/lego/legoomni/src/actors/act2actor.cpp index e2889d1f..1c1becc3 100644 --- a/LEGO1/lego/legoomni/src/actors/act2actor.cpp +++ b/LEGO1/lego/legoomni/src/actors/act2actor.cpp @@ -9,6 +9,7 @@ #include "legopathcontroller.h" #include "legopathedgecontainer.h" #include "legoplantmanager.h" +#include "legoplants.h" #include "legosoundmanager.h" #include "legovideomanager.h" #include "legoworld.h" @@ -52,6 +53,46 @@ MxBool g_unk0x100f0f24 = FALSE; // GLOBAL: BETA10 0x101dbe44 MxBool g_unk0x100f0f28 = FALSE; +// --- All of these are indices into g_plantInfo (0x10103180) --- + +// GLOBAL: LEGO1 0x100f0f30 +// GLOBAL: BETA10 0x101dbe48 +MxS32 g_unk0x100f0f30[] = {2, 23, 32, 66, 71, 72, 73, -1}; + +// GLOBAL: LEGO1 0x100f0f50 +// GLOBAL: BETA10 0x101dbe68 +MxS32 g_unk0x100f0f50[] = {0, 7, 16, 18, 20, 21, 34, 49, 58, 59, 63, 65, 69, 74, -1}; + +// GLOBAL: LEGO1 0x100f0f90 +// GLOBAL: BETA10 0x101dbea8 +MxS32 g_unk0x100f0f90[] = {12, 19, 24, 48, 60, -1}; + +// GLOBAL: LEGO1 0x100f0fa8 +// GLOBAL: BETA10 0x101dbec0 +MxS32 g_unk0x100f0fa8[] = {8, 15, 46, -1}; + +// GLOBAL: LEGO1 0x100f0fb8 +// GLOBAL: BETA10 0x101dbed0 +MxS32 g_unk0x100f0fb8[] = {25, 26, 28, 29, 38, 39, 42, 50, 51, 56, -1}; + +// GLOBAL: LEGO1 0x100f0fe8 +// GLOBAL: BETA10 0x101dbf00 +MxS32 g_unk0x100f0fe8[] = {3, 40, 53, 55, -1}; + +// GLOBAL: LEGO1 0x100f1000 +// GLOBAL: BETA10 0x101dbf18 +MxS32 g_unk0x100f1000[] = {22, 33, 41, 45, 67, -1}; + +// GLOBAL: LEGO1 0x100f1018 +// GLOBAL: BETA10 0x101dbf30 +MxS32 g_unk0x100f1018[] = {13, 30, 31, 62, -1}; + +// GLOBAL: LEGO1 0x100f1030 +// GLOBAL: BETA10 0x101dbf48 +MxS32 g_unk0x100f1030[] = {1, 27, 37, 44, 47, 54, 61, 64, -1}; + +// --- End of indices into g_plantInfo --- + // GLOBAL: LEGO1 0x10102b1c // GLOBAL: BETA10 0x10209f60 undefined4 g_nextHeadWavIndex = 0; @@ -658,12 +699,173 @@ void Act2Actor::FUN_100199f0(MxS8 p_param) } } -// STUB: LEGO1 0x10019b90 -// STUB: BETA10 0x1000e374 +// FUNCTION: LEGO1 0x10019b90 +// FUNCTION: BETA10 0x1000e374 LegoEntity* Act2Actor::FUN_10019b90(undefined* p_param) { - // TODO - return 0; + MxS32 i; + LegoBuildingInfo* buildingInfo = BuildingManager()->GetInfoArray(i); + LegoPlantInfo* plantInfo = PlantManager()->GetInfoArray(i); + LegoEntity* result = 0; + + switch (m_unk0x1d) { + case 0: + if (buildingInfo[12].m_unk0x11) { + result = buildingInfo[12].m_entity; + *p_param = 1; + } + else if (buildingInfo[14].m_unk0x11) { + result = buildingInfo[14].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f0f30[i] != -1; i++) { + if (plantInfo[g_unk0x100f0f30[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f0f30[i]].m_entity; + break; + } + } + } + break; + case 1: + if (buildingInfo[13].m_unk0x11) { + result = buildingInfo[13].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f0f50[i] != -1; i++) { + if (plantInfo[g_unk0x100f0f50[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f0f50[i]].m_entity; + break; + } + } + } + break; + case 2: + if (buildingInfo[9].m_unk0x11) { + result = buildingInfo[9].m_entity; + *p_param = 1; + } + else if (buildingInfo[11].m_unk0x11) { + result = buildingInfo[11].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f0f90[i] != -1; i++) { + if (plantInfo[g_unk0x100f0f90[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f0f90[i]].m_entity; + break; + } + } + } + break; + case 3: + if (buildingInfo[7].m_unk0x11) { + result = buildingInfo[7].m_entity; + *p_param = 1; + } + else if (buildingInfo[8].m_unk0x11) { + result = buildingInfo[8].m_entity; + *p_param = 1; + } + else if (buildingInfo[3].m_unk0x11) { + result = buildingInfo[3].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f0fa8[i] != -1; i++) { + if (plantInfo[g_unk0x100f0fa8[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f0fa8[i]].m_entity; + break; + } + } + } + break; + case 4: + if (buildingInfo[5].m_unk0x11) { + result = buildingInfo[5].m_entity; + *p_param = 1; + } + else if (buildingInfo[10].m_unk0x11) { + result = buildingInfo[10].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f0fb8[i] != -1; i++) { + if (plantInfo[g_unk0x100f0fb8[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f0fb8[i]].m_entity; + break; + } + } + } + break; + case 5: + if (buildingInfo[4].m_unk0x11) { + result = buildingInfo[4].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f0fe8[i] != -1; i++) { + if (plantInfo[g_unk0x100f0fe8[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f0fe8[i]].m_entity; + break; + } + } + } + break; + case 6: + if (buildingInfo[2].m_unk0x11) { + result = buildingInfo[2].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f1000[i] != -1; i++) { + if (plantInfo[g_unk0x100f1000[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f1000[i]].m_entity; + break; + } + } + } + break; + case 7: + if (buildingInfo[6].m_unk0x11) { + result = buildingInfo[6].m_entity; + *p_param = 1; + } + else { + for (i = 0; g_unk0x100f1018[i] != -1; i++) { + if (plantInfo[g_unk0x100f1018[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f1018[i]].m_entity; + break; + } + } + } + break; + case 8: + for (i = 0; g_unk0x100f1030[i] != -1; i++) { + if (plantInfo[g_unk0x100f1030[i]].m_unk0x16) { + result = plantInfo[g_unk0x100f1030[i]].m_entity; + break; + } + } + + if (result) { + return result; + } + + if (buildingInfo[0xf].m_unk0x11) { + result = buildingInfo[0xf].m_entity; + *p_param = 1; + } + break; + } + + if (!result && !g_brickstrLocations[m_unk0x1d].m_unk0x1c) { + g_brickstrLocations[m_unk0x1d].m_unk0x1c = 1; + m_unk0x48++; + } + + return result; } // FUNCTION: LEGO1 0x1001a180 diff --git a/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp index d39ef601..c02a86b8 100644 --- a/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp @@ -858,6 +858,7 @@ MxResult LegoBuildingManager::FUN_10030630() } // FUNCTION: LEGO1 0x10030790 +// FUNCTION: BETA10 0x10064db9 LegoBuildingInfo* LegoBuildingManager::GetInfoArray(MxS32& p_length) { if (!m_unk0x09) { diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index c91fbdc8..57648063 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -115,6 +115,27 @@ void LegoPlantManager::Reset(MxS32 p_worldId) m_unk0x0c = 0; } +// STUB: LEGO1 0x10026410 +// STUB: BETA10 0x100c50e9 +MxResult LegoPlantManager::FUN_10026410() +{ + // might be similar to LegoBuildingManager::FUN_10030630() + // TODO + return SUCCESS; +} + +// FUNCTION: LEGO1 0x10026570 +// FUNCTION: BETA10 0x100c55e0 +LegoPlantInfo* LegoPlantManager::GetInfoArray(MxS32& p_length) +{ + if (!m_unk0x0c) { + FUN_10026410(); + } + + p_length = sizeOfArray(g_plantInfo); + return g_plantInfo; +} + // FUNCTION: LEGO1 0x10026590 // FUNCTION: BETA10 0x100c561e LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, MxS32 p_worldId)