From 2c10c8e34434dadcc24bfbbbf27647174d450386 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 9 Nov 2024 14:54:17 -0700 Subject: [PATCH] Implement/match Doors::VTable0x70 and Doors::ParseAction (#1137) * Implement/match Doors::VTable0x70 and Doors::ParseAction * Fix --- LEGO1/lego/legoomni/include/doors.h | 21 +++--- LEGO1/lego/legoomni/src/actors/doors.cpp | 95 ++++++++++++++++++++++-- LEGO1/lego/sources/geom/legowegedge.h | 1 + 3 files changed, 100 insertions(+), 17 deletions(-) diff --git a/LEGO1/lego/legoomni/include/doors.h b/LEGO1/lego/legoomni/include/doors.h index 83c551b0..7fb2c392 100644 --- a/LEGO1/lego/legoomni/include/doors.h +++ b/LEGO1/lego/legoomni/include/doors.h @@ -3,11 +3,13 @@ #include "legopathactor.h" +class LegoROI; + // VTABLE: LEGO1 0x100d4788 // SIZE 0x1f8 class Doors : public LegoPathActor { public: - Doors() : m_unk0x154(0), m_unk0x15c(NULL), m_unk0x160(NULL), m_unk0x1f4(0) {} + Doors() : m_unk0x154(0), m_ltDoor(NULL), m_rtDoor(NULL), m_unk0x1f4(0) {} // FUNCTION: LEGO1 0x1000e430 const char* ClassName() const override // vtable+0x0c @@ -22,21 +24,22 @@ class Doors : public LegoPathActor { return !strcmp(p_name, Doors::ClassName()) || LegoPathActor::IsA(p_name); } - void ParseAction(char*) override; // vtable+0x20 + void ParseAction(char* p_extra) override; // vtable+0x20 void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 + virtual double VTable0xcc(float p_float); // vtable+0xcc // SYNTHETIC: LEGO1 0x1000e580 // Doors::`scalar deleting destructor' private: - undefined4 m_unk0x154; // 0x154 - MxFloat m_unk0x158; // 0x158 - Matrix4* m_unk0x15c; // 0x15c - Matrix4* m_unk0x160; // 0x160 - MxMatrix m_unk0x164; // 0x164 - MxMatrix m_unk0x1ac; // 0x1ac - MxFloat m_unk0x1f4; // 0x1f4 + undefined4 m_unk0x154; // 0x154 + MxFloat m_unk0x158; // 0x158 + LegoROI* m_ltDoor; // 0x15c + LegoROI* m_rtDoor; // 0x160 + MxMatrix m_ltDoorLocal; // 0x164 + MxMatrix m_rtDoorLocal; // 0x1ac + MxFloat m_unk0x1f4; // 0x1f4 }; #endif // DOORS_H diff --git a/LEGO1/lego/legoomni/src/actors/doors.cpp b/LEGO1/lego/legoomni/src/actors/doors.cpp index 2ac676b3..f2eb68ee 100644 --- a/LEGO1/lego/legoomni/src/actors/doors.cpp +++ b/LEGO1/lego/legoomni/src/actors/doors.cpp @@ -1,31 +1,110 @@ #include "doors.h" +#include "legopathboundary.h" #include "mxmisc.h" #include "mxtimer.h" +#include "roi/legoroi.h" + +#include DECOMP_SIZE_ASSERT(Doors, 0x1f8) // FUNCTION: LEGO1 0x10066100 +// FUNCTION: BETA10 0x10026850 MxResult Doors::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) { + assert(m_ltDoor && m_rtDoor); + if (m_unk0x154 == 1) { m_unk0x154 = 2; m_unk0x158 = Timer()->GetTime(); - m_unk0x164 = m_unk0x15c[2]; - m_unk0x1ac = m_unk0x160[2]; + m_ltDoorLocal = m_ltDoor->GetLocal2World(); + m_rtDoorLocal = m_rtDoor->GetLocal2World(); } return m_unk0x1f4 < 0.001 ? SUCCESS : FAILURE; } -// STUB: LEGO1 0x10066250 -void Doors::VTable0x70(float p_float) +// STUB: LEGO1 0x10066190 +// FUNCTION: BETA10 0x1002696b +double Doors::VTable0xcc(float p_float) { - // TODO + return 0.0; } -// STUB: LEGO1 0x100664e0 -void Doors::ParseAction(char*) +// FUNCTION: LEGO1 0x10066250 +// FUNCTION: BETA10 0x10026a45 +void Doors::VTable0x70(float p_float) { - // TODO + assert(m_ltDoor && m_rtDoor); + + // TODO: Match + m_roi->SetVisibility(m_boundary->GetFlag0x10()); + + switch (m_unk0x154) { + case 0: + m_unk0x154 = 1; + m_state = 0; + break; + case 1: + break; + case 2: + float local8 = VTable0xcc(p_float); + + if (local8 > 0.0f) { + MxMatrix local58(m_ltDoorLocal); + Vector3 local10(local58[3]); + + local10.Clear(); + local58.RotateY(-local8); + local10 = m_ltDoorLocal[3]; + m_ltDoor->FUN_100a58f0(local58); + m_ltDoor->VTable0x14(); + + local58 = m_rtDoorLocal; + local10.Clear(); + local58.RotateY(local8); + local10 = m_rtDoorLocal[3]; + m_rtDoor->FUN_100a58f0(local58); + m_rtDoor->VTable0x14(); + + m_unk0x1f4 = local8; + } + + if (m_unk0x158 + 6000.0f < p_float) { + m_ltDoor->FUN_100a58f0(m_ltDoorLocal); + m_rtDoor->FUN_100a58f0(m_rtDoorLocal); + m_ltDoor->VTable0x14(); + m_rtDoor->VTable0x14(); + m_unk0x154 = 1; + m_state = 0; + m_unk0x1f4 = 0; + } + } +} + +// FUNCTION: LEGO1 0x100664e0 +// FUNCTION: BETA10 0x10026ceb +void Doors::ParseAction(char* p_extra) +{ + LegoPathActor::ParseAction(p_extra); + + assert(m_ltDoor == NULL && m_rtDoor == NULL); + assert(m_roi); + assert(!strncmp(m_roi->GetName(), "rcdor", 5)); + + const CompoundObject* comp = m_roi->GetComp(); + + for (CompoundObject::const_iterator it = comp->begin(); it != comp->end(); it++) { + LegoROI* roi = (LegoROI*) *it; + + if (roi && (!strnicmp(roi->GetName(), "dor-lt", 6) || !strnicmp(roi->GetName(), "dor-sl", 6))) { + m_ltDoor = roi; + } + else if (roi && (!strnicmp(roi->GetName(), "dor-rt", 6) || !strnicmp(roi->GetName(), "dor-sr", 6))) { + m_rtDoor = roi; + } + } + + assert(m_ltDoor && m_rtDoor); } diff --git a/LEGO1/lego/sources/geom/legowegedge.h b/LEGO1/lego/sources/geom/legowegedge.h index 1adbac27..98a41433 100644 --- a/LEGO1/lego/sources/geom/legowegedge.h +++ b/LEGO1/lego/sources/geom/legowegedge.h @@ -40,6 +40,7 @@ class LegoWEGEdge : public LegoWEEdge { LegoResult VTable0x04() override; // vtable+0x04 + // FUNCTION: BETA10 0x100270c0 LegoU32 GetFlag0x10() { return m_flags & c_bit5 ? FALSE : TRUE; } // FUNCTION: BETA10 0x1001ff80