From 15a906740732ae8b77babd7d81e859540f2bba9b Mon Sep 17 00:00:00 2001 From: jonschz Date: Sat, 30 Nov 2024 15:18:11 +0100 Subject: [PATCH] Implement `Act2Actor::VTable0xa0` --- LEGO1/lego/legoomni/include/act2actor.h | 6 +- LEGO1/lego/legoomni/src/actors/act2actor.cpp | 123 ++++++++++++++++++- 2 files changed, 122 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/act2actor.h b/LEGO1/lego/legoomni/include/act2actor.h index ec82cea2..18a795cd 100644 --- a/LEGO1/lego/legoomni/include/act2actor.h +++ b/LEGO1/lego/legoomni/include/act2actor.h @@ -2,6 +2,7 @@ #define ACT2ACTOR_H #include "legoanimactor.h" +#include "legopathedgecontainer.h" // VTABLE: LEGO1 0x100d6078 LegoPathActor // VTABLE: LEGO1 0x100d6148 LegoAnimActor @@ -27,6 +28,7 @@ class Act2Actor : public LegoAnimActor { MxS32 VTable0xa0() override; // vtable+0xa0 void FUN_10019520(); + void FUN_100192a0(undefined4 p_param); // SYNTHETIC: LEGO1 0x1001a0a0 // Act2Actor::`scalar deleting destructor' @@ -37,7 +39,7 @@ class Act2Actor : public LegoAnimActor { private: undefined m_unk0x1c; // 0x1c - undefined m_unk0x1d; // 0x1d + MxS8 m_unk0x1d; // 0x1d undefined m_unk0x1e; // 0x1e MxBool m_unk0x1f; // 0x1f undefined4 m_unk0x20; // 0x20 @@ -50,7 +52,7 @@ class Act2Actor : public LegoAnimActor { undefined4 m_unk0x3c; // 0x3c undefined m_unk0x40; // 0x40 undefined4 m_unk0x44; // 0x44 - undefined m_unk0x48; // 0x48 + MxS8 m_unk0x48; // 0x48 undefined4 m_unk0x4c; // 0x4c }; diff --git a/LEGO1/lego/legoomni/src/actors/act2actor.cpp b/LEGO1/lego/legoomni/src/actors/act2actor.cpp index d582db05..d958d785 100644 --- a/LEGO1/lego/legoomni/src/actors/act2actor.cpp +++ b/LEGO1/lego/legoomni/src/actors/act2actor.cpp @@ -9,7 +9,8 @@ DECOMP_SIZE_ASSERT(Act2Actor, 0x1a8) DECOMP_SIZE_ASSERT(Act2Actor::UnknownListStructure, 0x20) // TODO: Copy the data once we know more about its fields. Total: 10 entries -// // GLOBAL: LEGO1 0x100f0db8 +// GLOBAL: LEGO1 0x100f0db8 +// GLOBAL: BETA10 0x101dbd00 Act2Actor::UnknownListStructure g_unk0x100f0db8[] = {{{0}, 0, {0}}}; // FUNCTION: LEGO1 0x100187e0 @@ -82,6 +83,12 @@ void Act2Actor::SetWorldSpeed(MxFloat p_worldSpeed) m_unk0x44 = 0; } +// FUNCTION: LEGO1 0x100192a0 +void Act2Actor::FUN_100192a0(undefined4 p_param) +{ + // TODO +} + // STUB: LEGO1 0x10019520 // STUB: BETA10 0x1000d4d6 void Act2Actor::FUN_10019520() @@ -89,12 +96,118 @@ void Act2Actor::FUN_10019520() // TODO } -// STUB: LEGO1 0x100195a0 -// STUB: BETA10 0x1000d7d3 +// FUNCTION: LEGO1 0x100195a0 +// FUNCTION: BETA10 0x1000d7d3 MxS32 Act2Actor::VTable0xa0() { - // TODO - return 0; + undefined4 newLocation; + + CurrentWorld(); + MxU16 randomVal = rand() / (RAND_MAX / 2) + 1; + + if (m_unk0x48 == 8 && m_unk0x1d != 8) { + newLocation = 8; + } + else { + switch (m_unk0x1d) { + case 0: + if (randomVal == 1) { + newLocation = 3; + } + else { + newLocation = 7; + } + break; + case 1: + if (randomVal == 1) { + newLocation = 2; + } + else { + newLocation = 4; + } + break; + case 2: + if (randomVal == 1) { + newLocation = 3; + } + else { + newLocation = 6; + } + break; + case 3: + if (randomVal == 1) { + newLocation = 5; + } + else { + newLocation = 1; + } + break; + case 4: + if (randomVal == 1) { + newLocation = 7; + } + else { + newLocation = 0; + } + break; + case 5: + if (randomVal == 1) { + newLocation = 6; + } + else { + newLocation = 1; + } + break; + case 6: + if (randomVal == 1) { + newLocation = 0; + } + else { + newLocation = 4; + } + break; + case 7: + if (randomVal == 1) { + newLocation = 2; + } + else { + newLocation = 5; + } + break; + case 8: + if (randomVal == 1) { + newLocation = 0; + } + else { + newLocation = 4; + } + } + } + + undefined4 firstChoice = newLocation; + + if (m_unk0x48 < 7 || g_unk0x100f0db8[m_unk0x1d].m_unk0x1c) { + while (g_unk0x100f0db8[newLocation].m_unk0x1c || m_unk0x1d == newLocation) { + if (newLocation == 7) { + newLocation = 0; + } + else { + newLocation++; + } + + assert(newLocation != firstChoice); + } + } + + m_unk0x1d = newLocation; + FUN_100192a0(newLocation); + + if (m_grec) { + return SUCCESS; + } + else { + return FAILURE; + } } // FUNCTION: LEGO1 0x1001a180