From cd39e71597b4e989157251e9bf6afc607d640831 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 1 May 2024 09:00:42 -0400 Subject: [PATCH] Implement/match LegoAnimationManager::Notify (#875) * Implement/match LegoAnimationManager::Notify * Rename notification type --- LEGO1/lego/legoomni/include/helicopter.h | 14 ++-- LEGO1/lego/legoomni/include/islepathactor.h | 4 +- .../legoomni/include/legoanimationmanager.h | 7 +- .../include/legoendanimnotificationparam.h | 34 ++++++++ LEGO1/lego/legoomni/include/legotraninfo.h | 2 + LEGO1/lego/legoomni/include/towtrack.h | 16 ++-- LEGO1/lego/legoomni/src/actors/helicopter.cpp | 2 +- LEGO1/lego/legoomni/src/actors/isleactor.cpp | 2 +- .../legoomni/src/actors/islepathactor.cpp | 4 +- LEGO1/lego/legoomni/src/actors/towtrack.cpp | 2 +- .../src/common/legoanimationmanager.cpp | 81 +++++++++++++++++-- .../src/common/legoanimmmpresenter.cpp | 4 +- .../legoomni/src/video/legoanimpresenter.cpp | 4 +- LEGO1/lego/legoomni/src/worlds/isle.cpp | 2 +- LEGO1/omni/include/mxnotificationparam.h | 5 +- .../omni/include/mxtype18notificationparam.h | 32 -------- 16 files changed, 143 insertions(+), 72 deletions(-) create mode 100644 LEGO1/lego/legoomni/include/legoendanimnotificationparam.h delete mode 100644 LEGO1/omni/include/mxtype18notificationparam.h diff --git a/LEGO1/lego/legoomni/include/helicopter.h b/LEGO1/lego/legoomni/include/helicopter.h index 3876d9a7..3c7e8b5d 100644 --- a/LEGO1/lego/legoomni/include/helicopter.h +++ b/LEGO1/lego/legoomni/include/helicopter.h @@ -25,13 +25,13 @@ class Helicopter : public IslePathActor { return !strcmp(p_name, Helicopter::ClassName()) || IslePathActor::IsA(p_name); } - MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 - void VTable0x70(float p_float) override; // vtable+0x70 - void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 - MxU32 VTable0xcc() override; // vtable+0xcc - MxU32 VTable0xd4(LegoControlManagerEvent& p_param) override; // vtable+0xd4 - MxU32 VTable0xd8(MxType18NotificationParam& p_param) override; // vtable+0xd8 - void VTable0xe4() override; // vtable+0xe4 + MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 + void VTable0x70(float p_float) override; // vtable+0x70 + void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 + MxU32 VTable0xcc() override; // vtable+0xcc + MxU32 VTable0xd4(LegoControlManagerEvent& p_param) override; // vtable+0xd4 + MxU32 VTable0xd8(LegoEndAnimNotificationParam& p_param) override; // vtable+0xd8 + void VTable0xe4() override; // vtable+0xe4 // SYNTHETIC: LEGO1 0x10003210 // Helicopter::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/islepathactor.h b/LEGO1/lego/legoomni/include/islepathactor.h index 67b1b320..bb6f515b 100644 --- a/LEGO1/lego/legoomni/include/islepathactor.h +++ b/LEGO1/lego/legoomni/include/islepathactor.h @@ -2,10 +2,10 @@ #define ISLEPATHACTOR_H #include "legocontrolmanager.h" +#include "legoendanimnotificationparam.h" #include "legogamestate.h" #include "legopathactor.h" #include "legoworld.h" -#include "mxtype18notificationparam.h" #include "mxtype19notificationparam.h" #include "mxtypes.h" @@ -46,7 +46,7 @@ class IslePathActor : public LegoPathActor { virtual MxU32 VTable0xd4(LegoControlManagerEvent&) { return 0; } // vtable+0xd4 // FUNCTION: LEGO1 0x10002e90 - virtual MxU32 VTable0xd8(MxType18NotificationParam&) { return 0; } // vtable+0xd8 + virtual MxU32 VTable0xd8(LegoEndAnimNotificationParam&) { return 0; } // vtable+0xd8 // FUNCTION: LEGO1 0x10002e00 virtual MxU32 VTable0xdc(MxType19NotificationParam&) { return 0; } // vtable+0xdc diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index 62aa66eb..148b3750 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -125,6 +125,7 @@ class LegoAnimationManager : public MxCore { MxBool FUN_10062710(AnimInfo& p_info); void FUN_10063aa0(); void FUN_100648f0(LegoTranInfo*, MxLong); + void FUN_10064b50(undefined4); MxS32 m_scriptIndex; // 0x08 MxU16 m_animCount; // 0x0c @@ -132,7 +133,7 @@ class LegoAnimationManager : public MxCore { MxU16 m_unk0x10; // 0x10 AnimInfo* m_anims; // 0x14 undefined2 m_unk0x18; // 0x18 - undefined m_unk0x1a; // 0x1a + MxBool m_unk0x1a; // 0x1a MxU32 m_unk0x1c; // 0x1c LegoTranInfoList* m_tranInfoList; // 0x20 LegoTranInfoList* m_tranInfoList2; // 0x24 @@ -159,8 +160,8 @@ class LegoAnimationManager : public MxCore { MxBool m_unk0x429; // 0x429 undefined m_unk0x42a; // 0x42a MxBool m_suspended; // 0x42b - undefined4 m_unk0x42c; // 0x42c - undefined m_unk0x430; // 0x430 + LegoTranInfo* m_unk0x42c; // 0x42c + MxBool m_unk0x430; // 0x430 undefined4 m_unk0x434[2]; // 0x434 MxMatrix m_unk0x43c; // 0x43c MxMatrix m_unk0x484; // 0x484 diff --git a/LEGO1/lego/legoomni/include/legoendanimnotificationparam.h b/LEGO1/lego/legoomni/include/legoendanimnotificationparam.h new file mode 100644 index 00000000..be7e9315 --- /dev/null +++ b/LEGO1/lego/legoomni/include/legoendanimnotificationparam.h @@ -0,0 +1,34 @@ +#ifndef LEGOENDANIMNOTIFICATIONPARAM_H +#define LEGOENDANIMNOTIFICATIONPARAM_H + +#include "decomp.h" +#include "mxnotificationparam.h" + +// VTABLE: LEGO1 0x100d7e80 +// SIZE 0x10 +class LegoEndAnimNotificationParam : public MxNotificationParam { +public: + LegoEndAnimNotificationParam(NotificationId p_type, MxCore* p_sender, MxU32 p_index) + : MxNotificationParam(p_type, p_sender), m_index(p_index) + { + } + + // FUNCTION: LEGO1 0x1004afd0 + MxNotificationParam* Clone() const override + { + return new LegoEndAnimNotificationParam(m_type, m_sender, m_index); + } // vtable+0x04 + + inline MxU32 GetIndex() { return m_index; } + +protected: + MxU32 m_index; // 0x0c +}; + +// SYNTHETIC: LEGO1 0x1004b080 +// LegoEndAnimNotificationParam::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1004b0f0 +// LegoEndAnimNotificationParam::~LegoEndAnimNotificationParam + +#endif // LEGOENDANIMNOTIFICATIONPARAM_H diff --git a/LEGO1/lego/legoomni/include/legotraninfo.h b/LEGO1/lego/legoomni/include/legotraninfo.h index c15617e8..93a56e2c 100644 --- a/LEGO1/lego/legoomni/include/legotraninfo.h +++ b/LEGO1/lego/legoomni/include/legotraninfo.h @@ -31,6 +31,8 @@ struct LegoTranInfo { m_unk0x2c.SetIdentity(); } + ~LegoTranInfo() { delete m_unk0x0c; } + AnimInfo* m_animInfo; // 0x00 MxU32 m_index; // 0x04 LegoROI* m_unk0x08; // 0x08 diff --git a/LEGO1/lego/legoomni/include/towtrack.h b/LEGO1/lego/legoomni/include/towtrack.h index 2d1146ef..056f0793 100644 --- a/LEGO1/lego/legoomni/include/towtrack.h +++ b/LEGO1/lego/legoomni/include/towtrack.h @@ -23,14 +23,14 @@ class TowTrack : public IslePathActor { return !strcmp(p_name, TowTrack::ClassName()) || IslePathActor::IsA(p_name); } - MxLong Notify(MxParam& p_param) override; // vtable+0x04 - MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 - void VTable0x70(float p_float) override; // vtable+0x70 - MxU32 VTable0xcc() override; // vtable+0xcc - MxU32 VTable0xd4(LegoControlManagerEvent& p_param) override; // vtable+0xd4 - MxU32 VTable0xd8(MxType18NotificationParam& p_param) override; // vtable+0xd8 - MxU32 VTable0xdc(MxType19NotificationParam& p_param) override; // vtable+0xdc - void VTable0xe4() override; // vtable+0xe4 + MxLong Notify(MxParam& p_param) override; // vtable+0x04 + MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 + void VTable0x70(float p_float) override; // vtable+0x70 + MxU32 VTable0xcc() override; // vtable+0xcc + MxU32 VTable0xd4(LegoControlManagerEvent& p_param) override; // vtable+0xd4 + MxU32 VTable0xd8(LegoEndAnimNotificationParam& p_param) override; // vtable+0xd8 + MxU32 VTable0xdc(MxType19NotificationParam& p_param) override; // vtable+0xdc + void VTable0xe4() override; // vtable+0xe4 void FUN_1004dab0(); void FUN_1004dad0(); diff --git a/LEGO1/lego/legoomni/src/actors/helicopter.cpp b/LEGO1/lego/legoomni/src/actors/helicopter.cpp index fc166d2c..54064290 100644 --- a/LEGO1/lego/legoomni/src/actors/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/actors/helicopter.cpp @@ -248,7 +248,7 @@ MxU32 Helicopter::VTable0xd4(LegoControlManagerEvent& p_param) } // FUNCTION: LEGO1 0x10003c20 -MxU32 Helicopter::VTable0xd8(MxType18NotificationParam& p_param) +MxU32 Helicopter::VTable0xd8(LegoEndAnimNotificationParam& p_param) { MxU32 ret = 0; diff --git a/LEGO1/lego/legoomni/src/actors/isleactor.cpp b/LEGO1/lego/legoomni/src/actors/isleactor.cpp index 9281a443..5653be65 100644 --- a/LEGO1/lego/legoomni/src/actors/isleactor.cpp +++ b/LEGO1/lego/legoomni/src/actors/isleactor.cpp @@ -45,7 +45,7 @@ MxLong IsleActor::Notify(MxParam& p_param) case c_notificationType11: result = VTable0x68(); break; - case c_notificationType18: + case c_notificationEndAnim: result = VTable0x70(); break; case c_notificationType19: diff --git a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp index 46dce944..e5933f67 100644 --- a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp +++ b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp @@ -47,8 +47,8 @@ MxLong IslePathActor::Notify(MxParam& p_param) case c_notificationClick: ret = VTable0xd4((LegoControlManagerEvent&) p_param); break; - case c_notificationType18: - ret = VTable0xd8((MxType18NotificationParam&) p_param); + case c_notificationEndAnim: + ret = VTable0xd8((LegoEndAnimNotificationParam&) p_param); break; case c_notificationType19: ret = VTable0xdc((MxType19NotificationParam&) p_param); diff --git a/LEGO1/lego/legoomni/src/actors/towtrack.cpp b/LEGO1/lego/legoomni/src/actors/towtrack.cpp index c99c4f11..2b087966 100644 --- a/LEGO1/lego/legoomni/src/actors/towtrack.cpp +++ b/LEGO1/lego/legoomni/src/actors/towtrack.cpp @@ -37,7 +37,7 @@ MxLong TowTrack::Notify(MxParam& p_param) } // STUB: LEGO1 0x1004cd30 -MxU32 TowTrack::VTable0xd8(MxType18NotificationParam& p_param) +MxU32 TowTrack::VTable0xd8(LegoEndAnimNotificationParam& p_param) { // TODO return 0; diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 52f71ef9..6ade51a6 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -235,7 +235,7 @@ void LegoAnimationManager::Suspend() } m_unk0x18 = 0; - m_unk0x1a = 0; + m_unk0x1a = FALSE; m_unk0x3a = FALSE; m_unk0x400 = FALSE; m_unk0x414 = 0; @@ -270,7 +270,7 @@ void LegoAnimationManager::Init() m_animCount = 0; m_anims = NULL; m_unk0x18 = 0; - m_unk0x1a = 0; + m_unk0x1a = FALSE; m_tranInfoList = NULL; m_tranInfoList2 = NULL; m_unk0x41c = g_legoAnimationManagerConfig <= 1 ? 10 : 20; @@ -299,8 +299,8 @@ void LegoAnimationManager::Init() m_unk0x10 = 0; m_unk0x401 = 0; m_suspended = FALSE; - m_unk0x430 = 0; - m_unk0x42c = 0; + m_unk0x430 = FALSE; + m_unk0x42c = NULL; m_unk0x408 = m_unk0x40c = m_unk0x404 = Timer()->GetTime(); m_unk0x410 = 5000; @@ -374,8 +374,8 @@ MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex) m_unk0x38 = FALSE; m_unk0x39 = FALSE; - m_unk0x430 = 0; - m_unk0x42c = 0; + m_unk0x430 = FALSE; + m_unk0x42c = NULL; for (j = 0; j < (MxS32) _countof(g_characters); j++) { g_characters[j].m_active = FALSE; @@ -923,10 +923,68 @@ LegoTranInfo* LegoAnimationManager::GetTranInfo(MxU32 p_index) return NULL; } -// STUB: LEGO1 0x100619f0 +// FUNCTION: LEGO1 0x100619f0 +// FUNCTION: BETA10 0x100426b1 MxLong LegoAnimationManager::Notify(MxParam& p_param) { - // TODO + if (((MxNotificationParam&) p_param).GetSender() == this) { + if (((MxNotificationParam&) p_param).GetType() == c_notificationEndAnim) { + FUN_100605e0(m_unk0x18, TRUE, NULL, TRUE, NULL, FALSE, TRUE, TRUE, TRUE); + } + } + else if (((MxNotificationParam&) p_param).GetType() == c_notificationEndAnim && m_tranInfoList != NULL) { + LegoTranInfoListCursor cursor(m_tranInfoList); + LegoTranInfo* tranInfo; + + MxU32 index = ((LegoEndAnimNotificationParam&) p_param).GetIndex(); + MxBool found = FALSE; + + while (cursor.Next(tranInfo)) { + if (tranInfo->m_index == index) { + if (m_unk0x430 && m_unk0x42c == tranInfo) { + FUN_10064b50(-1); + } + + if (tranInfo->m_flags & LegoTranInfo::c_bit2) { + BackgroundAudioManager()->RaiseVolume(); + } + + m_unk0x39 = FALSE; + m_unk0x404 = Timer()->GetTime(); + + found = TRUE; + cursor.Detach(); + delete tranInfo; + + for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) { + LegoROI* roi = m_unk0x3c[i].m_roi; + + if (roi != NULL) { + LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName()); + + if (actor != NULL) { + actor->Restart(); + } + } + } + + break; + } + } + + if (m_unk0x1a && found) { + m_unk0x18++; + + if (m_animCount <= m_unk0x18) { + m_unk0x1a = FALSE; + } + else { + LegoEndAnimNotificationParam param(c_notificationEndAnim, this, 0); + NotificationManager()->Send(this, param); + } + } + } + return 0; } @@ -1057,3 +1115,10 @@ void LegoAnimationManager::FUN_100648f0(LegoTranInfo*, MxLong) { // TODO } + +// STUB: LEGO1 0x10064b50 +// FUNCTION: BETA10 0x10045f14 +void LegoAnimationManager::FUN_10064b50(undefined4) +{ + // TODO +} diff --git a/LEGO1/lego/legoomni/src/common/legoanimmmpresenter.cpp b/LEGO1/lego/legoomni/src/common/legoanimmmpresenter.cpp index e93e9a60..d2b2632a 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimmmpresenter.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimmmpresenter.cpp @@ -5,6 +5,7 @@ #include "islepathactor.h" #include "legoanimationmanager.h" #include "legoanimpresenter.h" +#include "legoendanimnotificationparam.h" #include "legotraninfo.h" #include "legovideomanager.h" #include "legoworld.h" @@ -15,7 +16,6 @@ #include "mxnotificationmanager.h" #include "mxobjectfactory.h" #include "mxtimer.h" -#include "mxtype18notificationparam.h" #include "mxutilities.h" DECOMP_SIZE_ASSERT(LegoAnimMMPresenter, 0x74) @@ -123,7 +123,7 @@ void LegoAnimMMPresenter::EndAction() m_tranInfo = NULL; - MxType18NotificationParam param(c_notificationType18, NULL, m_animmanId); + LegoEndAnimNotificationParam param(c_notificationEndAnim, NULL, m_animmanId); if (m_animmanId != 0) { NotificationManager()->Send(AnimationManager(), param); } diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index c5aa1e1c..e8f887f6 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -4,6 +4,7 @@ #include "legoanimationmanager.h" #include "legoanimmmpresenter.h" #include "legocharactermanager.h" +#include "legoendanimnotificationparam.h" #include "legopathboundary.h" #include "legovideomanager.h" #include "legoworld.h" @@ -15,7 +16,6 @@ #include "mxnotificationmanager.h" #include "mxstreamchunk.h" #include "mxtimer.h" -#include "mxtype18notificationparam.h" #include "mxutilities.h" #include "mxvideomanager.h" #include "realtime/realtime.h" @@ -1021,7 +1021,7 @@ void LegoAnimPresenter::EndAction() LegoWorld* world = CurrentWorld(); if (world != NULL) { - MxType18NotificationParam param(c_notificationType18, NULL, 0); + LegoEndAnimNotificationParam param(c_notificationEndAnim, NULL, 0); NotificationManager()->Send(world, param); } diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index 3ebd9807..0ab1797f 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -138,7 +138,7 @@ MxLong Isle::Notify(MxParam& p_param) case c_notificationClick: result = HandleClick((LegoControlManagerEvent&) p_param); break; - case c_notificationType18: + case c_notificationEndAnim: switch (m_act1state->m_unk0x018) { case 4: result = CurrentActor()->Notify(p_param); diff --git a/LEGO1/omni/include/mxnotificationparam.h b/LEGO1/omni/include/mxnotificationparam.h index 1443d07b..afe2282b 100644 --- a/LEGO1/omni/include/mxnotificationparam.h +++ b/LEGO1/omni/include/mxnotificationparam.h @@ -7,6 +7,7 @@ class MxCore; +// Several of those should be defined in LegoOmni enum NotificationId { c_notificationType0 = 0, c_notificationStartAction = 1, // 100dc210:100d8350 @@ -24,8 +25,8 @@ enum NotificationId { c_notificationDrag = 14, c_notificationTimer = 15, // 100d6aa0 c_notificationClick = 17, - c_notificationType18 = 18, // 100d7e80 - c_notificationType19 = 19, // 100d6230 + c_notificationEndAnim = 18, // 100d7e80 + c_notificationType19 = 19, // 100d6230 c_notificationType20 = 20, c_notificationNewPresenter = 21, c_notificationType22 = 22, diff --git a/LEGO1/omni/include/mxtype18notificationparam.h b/LEGO1/omni/include/mxtype18notificationparam.h deleted file mode 100644 index 77d3ecb9..00000000 --- a/LEGO1/omni/include/mxtype18notificationparam.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MXTYPE18NOTIFICATIONPARAM_H -#define MXTYPE18NOTIFICATIONPARAM_H - -#include "decomp.h" -#include "mxnotificationparam.h" - -// VTABLE: LEGO1 0x100d7e80 -// SIZE 0x10 -class MxType18NotificationParam : public MxNotificationParam { -public: - MxType18NotificationParam(NotificationId p_type, MxCore* p_sender, undefined4 p_unk0x0c) - : MxNotificationParam(p_type, p_sender), m_unk0x0c(p_unk0x0c) - { - } - - // FUNCTION: LEGO1 0x1004afd0 - MxNotificationParam* Clone() const override - { - return new MxType18NotificationParam(m_type, m_sender, m_unk0x0c); - } // vtable+0x04 - -protected: - undefined4 m_unk0x0c; // 0x0c -}; - -// SYNTHETIC: LEGO1 0x1004b080 -// MxType18NotificationParam::`scalar deleting destructor' - -// SYNTHETIC: LEGO1 0x1004b0f0 -// MxType18NotificationParam::~MxType18NotificationParam - -#endif // MXTYPE18NOTIFICATIONPARAM_H