From d639eb4c2b80145b88ca8805f87d4882cda37d04 Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Wed, 17 Apr 2024 06:34:21 -0400 Subject: [PATCH] Implement LegoPathActor::Vtable0x6c (#810) * Implement LegoPathActor::VTable0x6c * Update LEGO1/lego/legoomni/src/paths/legopathactor.cpp Co-authored-by: Anonymous Maarten * Fix logic / match * Add BETA annotation --------- Co-authored-by: Christian Semmler Co-authored-by: Anonymous Maarten --- .../lego/legoomni/include/legoanimpresenter.h | 2 +- .../lego/legoomni/include/legocarraceactor.h | 9 +++- LEGO1/lego/legoomni/include/legoentity.h | 1 + LEGO1/lego/legoomni/include/legoextraactor.h | 13 ++++-- LEGO1/lego/legoomni/include/legojetski.h | 13 ++++-- .../legoomni/include/legojetskiraceactor.h | 9 +++- LEGO1/lego/legoomni/include/legopathactor.h | 13 ++++-- .../lego/legoomni/include/legopathboundary.h | 37 ++++++++++++++-- LEGO1/lego/legoomni/include/legoracecar.h | 13 ++++-- .../legoomni/src/entity/legocarraceactor.cpp | 10 ++++- LEGO1/lego/legoomni/src/entity/legojetski.cpp | 10 ++++- .../src/entity/legojetskiraceactor.cpp | 10 ++++- .../legoomni/src/paths/legoextraactor.cpp | 14 ++++-- .../lego/legoomni/src/paths/legopathactor.cpp | 43 +++++++++++++++++-- .../legoomni/src/paths/legopathboundary.cpp | 2 +- LEGO1/lego/legoomni/src/race/legoracecar.cpp | 10 ++++- .../legoomni/src/video/legoanimpresenter.cpp | 3 +- LEGO1/lego/sources/roi/legoroi.cpp | 6 +++ LEGO1/lego/sources/roi/legoroi.h | 1 + 19 files changed, 189 insertions(+), 30 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 5e32e4fb..abc4a09d 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -59,7 +59,7 @@ class LegoAnimPresenter : public MxVideoPresenter { virtual MxResult CreateAnim(MxStreamChunk* p_chunk); // vtable+0x88 virtual void VTable0x8c(); // vtable+0x8c virtual void VTable0x90(); // vtable+0x90 - virtual void VTable0x94(); // vtable+0x94 + virtual MxResult VTable0x94(Vector3&, Vector3&, float, float, Vector3&); // vtable+0x94 virtual void VTable0x98(); // vtable+0x98 // FUNCTION: LEGO1 0x1000c990 diff --git a/LEGO1/lego/legoomni/include/legocarraceactor.h b/LEGO1/lego/legoomni/include/legocarraceactor.h index 5671418c..97e734cb 100644 --- a/LEGO1/lego/legoomni/include/legocarraceactor.h +++ b/LEGO1/lego/legoomni/include/legocarraceactor.h @@ -27,7 +27,14 @@ class LegoCarRaceActor : public virtual LegoRaceActor { return !strcmp(p_name, LegoCarRaceActor::ClassName()) || LegoRaceActor::IsA(p_name); } - void VTable0x6c() override; // vtable+0x6c + MxU32 VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 + ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 MxU32 VTable0x90(float, Matrix4&) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 53c6ab3d..c3b2bcf0 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -76,6 +76,7 @@ class LegoEntity : public MxEntity { inline MxFloat GetWorldSpeed() { return m_worldSpeed; } inline LegoROI* GetROI() { return m_roi; } inline MxU8 GetUnknown0x59() { return m_unk0x59; } + inline MxBool GetCameraFlag() { return m_cameraFlag; } inline void SetFlags(MxU8 p_flags) { m_flags = p_flags; } inline void SetFlag(MxU8 p_flag) { m_flags |= p_flag; } diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index 814b4414..c6ee0e61 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -33,9 +33,16 @@ class LegoExtraActor : public virtual LegoAnimActor { return !strcmp(p_name, LegoExtraActor::ClassName()) || LegoAnimActor::IsA(p_name); } - void SetWorldSpeed(MxFloat p_worldSpeed) override; // vtable+0x30 - MxS32 VTable0x68(Vector3&, Vector3&, Vector3&) override; // vtable+0x68 - void VTable0x6c() override; // vtable+0x6c + void SetWorldSpeed(MxFloat p_worldSpeed) override; // vtable+0x30 + MxS32 VTable0x68(Vector3&, Vector3&, Vector3&) override; // vtable+0x68 + MxU32 VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 + ) override; // vtable+0x6c void VTable0x70(float) override; // vtable+0x70 void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 MxU32 VTable0x90(float p_float, Matrix4& p_matrix) override; // vtable+0x90 diff --git a/LEGO1/lego/legoomni/include/legojetski.h b/LEGO1/lego/legoomni/include/legojetski.h index 9761a3a6..61fd0121 100644 --- a/LEGO1/lego/legoomni/include/legojetski.h +++ b/LEGO1/lego/legoomni/include/legojetski.h @@ -31,9 +31,16 @@ class LegoJetski : public LegoJetskiRaceActor, public LegoRaceMap { return !strcmp(p_name, LegoJetski::ClassName()) || LegoJetskiRaceActor::IsA(p_name); } - void ParseAction(char*) override; // vtable+0x20 - void SetWorldSpeed(MxFloat p_worldSpeed) override; // vtable+0x30 - void VTable0x6c() override; // vtable+0x6c + void ParseAction(char*) override; // vtable+0x20 + void SetWorldSpeed(MxFloat p_worldSpeed) override; // vtable+0x30 + MxU32 VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 + ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 diff --git a/LEGO1/lego/legoomni/include/legojetskiraceactor.h b/LEGO1/lego/legoomni/include/legojetskiraceactor.h index 20bbb545..388107d1 100644 --- a/LEGO1/lego/legoomni/include/legojetskiraceactor.h +++ b/LEGO1/lego/legoomni/include/legojetskiraceactor.h @@ -27,7 +27,14 @@ class LegoJetskiRaceActor : public virtual LegoCarRaceActor { return !strcmp(p_name, LegoJetskiRaceActor::ClassName()) || LegoCarRaceActor::IsA(p_name); } - void VTable0x6c() override; // vtable+0x6c + MxU32 VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 + ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 void VTable0x98() override; // vtable+0x98 MxResult WaitForAnimation() override; // vtable+0x9c diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index feb35c35..d1bbd0ef 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -32,9 +32,16 @@ class LegoPathActor : public LegoActor { void ParseAction(char* p_extra) override; // vtable+0x20 virtual MxS32 VTable0x68(Vector3&, Vector3&, Vector3&); // vtable+0x68 - virtual void VTable0x6c(); // vtable+0x6c - virtual void VTable0x70(float p_time); // vtable+0x70 - virtual void VTable0x74(Matrix4& p_transform); // vtable+0x74 + virtual MxU32 VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 + ); // vtable+0x6c + virtual void VTable0x70(float p_time); // vtable+0x70 + virtual void VTable0x74(Matrix4& p_transform); // vtable+0x74 // FUNCTION: LEGO1 0x10002d20 virtual void SetUserNavFlag(MxBool p_userNavFlag) { m_userNavFlag = p_userNavFlag; } // vtable+0x78 diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index ed400642..024e85d2 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -32,17 +32,48 @@ class LegoPathBoundary : public LegoWEGEdge { void FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPathActor* p_actor); MxU32 Intersect(float p_scale, Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, LegoEdge*& p_edge); - inline LegoAnimPresenterSet* GetUnknown0x64() { return &m_unk0x64; } + inline LegoPathActorSet* GetActors() { return &m_actors; } + inline LegoAnimPresenterSet* GetPresenters() { return &m_presenters; } // SYNTHETIC: LEGO1 0x10047a80 // LegoPathBoundary::`scalar deleting destructor' private: - LegoPathActorSet m_unk0x54; // 0x54 - LegoAnimPresenterSet m_unk0x64; // 0x64 + LegoPathActorSet m_actors; // 0x54 + LegoAnimPresenterSet m_presenters; // 0x64 }; // clang-format off +// TEMPLATE: LEGO1 0x1002bee0 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::~_Tree >::_Kfn,LegoPathActorSetCompare,allocator >::iterator::_Inc + +// TEMPLATE: LEGO1 0x1002bff0 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::erase + +// TEMPLATE: LEGO1 0x1002c440 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::find + +// TEMPLATE: LEGO1 0x1002c4c0 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::_Copy + +// TEMPLATE: LEGO1 0x1002c630 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::_Erase + +// TEMPLATE: LEGO1 0x1002c670 +// set >::~set > + +// TEMPLATE: LEGO1 0x1002c6c0 +// Set::~Set + +// TEMPLATE: LEGO1 0x1002eb10 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::_Init + +// TEMPLATE: LEGO1 0x1002ebc0 +// _Tree >::_Kfn,LegoAnimPresenterSetCompare,allocator >::_Min + // TEMPLATE: LEGO1 0x10045d80 // _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::iterator::_Dec diff --git a/LEGO1/lego/legoomni/include/legoracecar.h b/LEGO1/lego/legoomni/include/legoracecar.h index f6b21501..4c7db772 100644 --- a/LEGO1/lego/legoomni/include/legoracecar.h +++ b/LEGO1/lego/legoomni/include/legoracecar.h @@ -31,9 +31,16 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap { return !strcmp(p_name, LegoCarRaceActor::ClassName()) || LegoCarRaceActor::IsA(p_name); } - void ParseAction(char*) override; // vtable+0x20 - void SetWorldSpeed(MxFloat p_worldSpeed) override; // vtable+0x30 - void VTable0x6c() override; // vtable+0x6c + void ParseAction(char*) override; // vtable+0x20 + void SetWorldSpeed(MxFloat p_worldSpeed) override; // vtable+0x30 + MxU32 VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 + ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 diff --git a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp index 2e3524c7..d724f763 100644 --- a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp @@ -52,9 +52,17 @@ void LegoCarRaceActor::VTable0x1c() } // STUB: LEGO1 0x10081830 -void LegoCarRaceActor::VTable0x6c() +MxU32 LegoCarRaceActor::VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 +) { // TODO + return 0; } // STUB: LEGO1 0x10081d10 diff --git a/LEGO1/lego/legoomni/src/entity/legojetski.cpp b/LEGO1/lego/legoomni/src/entity/legojetski.cpp index c919276c..3656e1c7 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetski.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetski.cpp @@ -44,9 +44,17 @@ void LegoJetski::SetWorldSpeed(MxFloat p_worldSpeed) } // STUB: LEGO1 0x10014140 -void LegoJetski::VTable0x6c() +MxU32 LegoJetski::VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 +) { // TODO + return 0; } // STUB: LEGO1 0x10014180 diff --git a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp index f5e8c8a4..654c00b1 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp @@ -18,9 +18,17 @@ LegoJetskiRaceActor::LegoJetskiRaceActor() } // STUB: LEGO1 0x10081fc0 -void LegoJetskiRaceActor::VTable0x6c() +MxU32 LegoJetskiRaceActor::VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 +) { // TODO + return 0; } // STUB: LEGO1 0x100822c0 diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index 5a9dcaed..9fd85363 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -282,7 +282,7 @@ MxResult LegoExtraActor::WaitForAnimation() if (m_boundary != oldBoundary) { MxU32 b = FALSE; - LegoAnimPresenterSet* set = m_boundary->GetUnknown0x64(); + LegoAnimPresenterSet* set = m_boundary->GetPresenters(); for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) { undefined4 tmp; @@ -307,7 +307,7 @@ void LegoExtraActor::Restart() { if (m_unk0x0e != 0) { MxU32 b = FALSE; - LegoAnimPresenterSet* set = m_boundary->GetUnknown0x64(); + LegoAnimPresenterSet* set = m_boundary->GetPresenters(); for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) { undefined4 tmp; @@ -424,6 +424,14 @@ MxS32 LegoExtraActor::VTable0x68(Vector3& p_point1, Vector3& p_point2, Vector3& } // STUB: LEGO1 0x1002b980 -void LegoExtraActor::VTable0x6c() +MxU32 LegoExtraActor::VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 +) { + return 0; } diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index a28f4e74..945e5f27 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -413,10 +413,47 @@ void LegoPathActor::VTable0x98() // TODO } -// STUB: LEGO1 0x1002e8d0 -void LegoPathActor::VTable0x6c() +// FUNCTION: LEGO1 0x1002e8d0 +// FUNCTION: BETA10 0x100b1010 +MxU32 LegoPathActor::VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 +) { - // TODO + LegoAnimPresenterSet* laps = p_boundary->GetPresenters(); + + for (LegoAnimPresenterSet::iterator itap = laps->begin(); itap != laps->end(); itap++) { + if ((*itap)->VTable0x94(p_v1, p_v2, p_f1, p_f2, p_v3)) { + return 1; + } + } + + LegoPathActorSet* plpas = p_boundary->GetActors(); + LegoPathActorSet lpas(*plpas); + + for (LegoPathActorSet::iterator itpa = lpas.begin(); itpa != lpas.end(); itpa++) { + if (plpas->find(*itpa) != plpas->end()) { + LegoPathActor* actor = *itpa; + + if (this != actor && !(actor->GetState() & 0x100)) { + LegoROI* roi = actor->GetROI(); + + if (roi != NULL && (roi->GetVisibility() || actor->GetCameraFlag())) { + if (roi->FUN_100a9410(p_v1, p_v2, p_f1, p_f2, p_v3, m_unk0xe8 != 0 && actor->m_unk0xe8 != 0)) { + VTable0x94(actor, TRUE); + actor->VTable0x94(this, FALSE); + return 2; + } + } + } + } + } + + return 0; } // STUB: LEGO1 0x1002ebe0 diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index 49ecfeb4..0da8541d 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -13,7 +13,7 @@ LegoPathBoundary::LegoPathBoundary() // FUNCTION: LEGO1 0x100573f0 MxResult LegoPathBoundary::AddActor(LegoPathActor* p_actor) { - m_unk0x54.insert(p_actor); + m_actors.insert(p_actor); p_actor->SetBoundary(this); return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/race/legoracecar.cpp b/LEGO1/lego/legoomni/src/race/legoracecar.cpp index 0c7484a3..ccd28cd8 100644 --- a/LEGO1/lego/legoomni/src/race/legoracecar.cpp +++ b/LEGO1/lego/legoomni/src/race/legoracecar.cpp @@ -64,9 +64,17 @@ void LegoRaceCar::SetWorldSpeed(MxFloat p_worldSpeed) } // STUB: LEGO1 0x100144f0 -void LegoRaceCar::VTable0x6c() +MxU32 LegoRaceCar::VTable0x6c( + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3 +) { // TODO + return 0; } // STUB: LEGO1 0x10014530 diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 40a2939c..b66d96a4 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -805,9 +805,10 @@ void LegoAnimPresenter::FUN_1006c8a0(MxBool p_bool) } // STUB: LEGO1 0x1006c8f0 -void LegoAnimPresenter::VTable0x94() +MxResult LegoAnimPresenter::VTable0x94(Vector3&, Vector3&, float, float, Vector3&) { // TODO + return SUCCESS; } // STUB: LEGO1 0x1006ca50 diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index 9262dc6e..7885482f 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -505,6 +505,12 @@ LegoResult LegoROI::GetTexture(LegoTextureInfo*&) return FAILURE; } +// STUB: LEGO1 0x100a9410 +LegoU32 LegoROI::FUN_100a9410(Vector3&, Vector3&, float, float, Vector3&, LegoBool) +{ + return 0; +} + // FUNCTION: LEGO1 0x100a9a50 TimeROI::TimeROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList, LegoTime p_time) : LegoROI(p_renderer, p_lodList) { diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index 52206424..d71d8b47 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -37,6 +37,7 @@ class LegoROI : public ViewROI { LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo); LegoResult GetTexture(LegoTextureInfo*&); + LegoU32 FUN_100a9410(Vector3&, Vector3&, float, float, Vector3&, LegoBool); void SetName(const LegoChar* p_name); float IntrinsicImportance() const override; // vtable+0x04