Implement/match LegoPathController::FUN_10045c20 and LegoPathController ctor (#903)

* Implement/match LegoPathController::FUN_10045c20 and LegoPathController ctor

* Remove obsolete struct
This commit is contained in:
Christian Semmler 2024-05-11 09:32:11 -04:00 committed by GitHub
parent c77dd44105
commit 5df947dbb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 73 additions and 29 deletions

View file

@ -33,7 +33,7 @@ class IslePathActor : public LegoPathActor {
LegoGameState::Area p_area, LegoGameState::Area p_area,
MxAtomId* p_script, MxAtomId* p_script,
MxS32 p_entityId, MxS32 p_entityId,
const char* p_path, const char* p_name,
MxS16 p_src, MxS16 p_src,
float p_srcScale, float p_srcScale,
MxS16 p_dest, MxS16 p_dest,
@ -45,7 +45,7 @@ class IslePathActor : public LegoPathActor {
m_area = p_area; m_area = p_area;
m_script = p_script; m_script = p_script;
m_entityId = p_entityId; m_entityId = p_entityId;
strcpy(m_path, p_path); strcpy(m_name, p_name);
m_src = p_src; m_src = p_src;
m_srcScale = p_srcScale; m_srcScale = p_srcScale;
m_dest = p_dest; m_dest = p_dest;
@ -60,7 +60,7 @@ class IslePathActor : public LegoPathActor {
m_area = p_location.m_area; m_area = p_location.m_area;
m_script = p_location.m_script; m_script = p_location.m_script;
m_entityId = p_location.m_entityId; m_entityId = p_location.m_entityId;
strcpy(m_path, p_location.m_path); strcpy(m_name, p_location.m_name);
m_src = p_location.m_src; m_src = p_location.m_src;
m_srcScale = p_location.m_srcScale; m_srcScale = p_location.m_srcScale;
m_dest = p_location.m_dest; m_dest = p_location.m_dest;
@ -73,7 +73,7 @@ class IslePathActor : public LegoPathActor {
LegoGameState::Area m_area; // 0x00 LegoGameState::Area m_area; // 0x00
MxAtomId* m_script; // 0x04 MxAtomId* m_script; // 0x04
MxS32 m_entityId; // 0x08 MxS32 m_entityId; // 0x08
char m_path[20]; // 0x0c char m_name[20]; // 0x0c
MxS16 m_src; // 0x20 MxS16 m_src; // 0x20
float m_srcScale; // 0x24 float m_srcScale; // 0x24
MxS16 m_dest; // 0x28 MxS16 m_dest; // 0x28

View file

@ -119,7 +119,7 @@ class LegoPathActor : public LegoActor {
inline void SetBoundary(LegoPathBoundary* p_boundary) { m_boundary = p_boundary; } inline void SetBoundary(LegoPathBoundary* p_boundary) { m_boundary = p_boundary; }
inline void SetState(MxU32 p_state) { m_state = p_state; } inline void SetState(MxU32 p_state) { m_state = p_state; }
inline void ClearController() { m_controller = NULL; } inline void SetController(LegoPathController* p_controller) { m_controller = p_controller; }
// SYNTHETIC: LEGO1 0x1002d800 // SYNTHETIC: LEGO1 0x1002d800
// LegoPathActor::`scalar deleting destructor' // LegoPathActor::`scalar deleting destructor'

View file

@ -2,12 +2,12 @@
#define LEGOPATHCONTROLLER_H #define LEGOPATHCONTROLLER_H
#include "decomp.h" #include "decomp.h"
#include "legopathactor.h"
#include "legopathboundary.h"
#include "mxcore.h" #include "mxcore.h"
#include "mxstl/stlcompat.h" #include "mxstl/stlcompat.h"
class LegoAnimPresenter; class LegoAnimPresenter;
class LegoPathActor;
class LegoPathBoundary;
class LegoWorld; class LegoWorld;
class MxAtomId; class MxAtomId;
class Vector3; class Vector3;
@ -69,8 +69,22 @@ class LegoPathController : public MxCore {
MxU16 m_numE; // 0x1a MxU16 m_numE; // 0x1a
MxU16 m_numN; // 0x1c MxU16 m_numN; // 0x1c
MxU16 m_numT; // 0x1e MxU16 m_numT; // 0x1e
map<undefined*, undefined*, LegoPathControllerComparator> m_pfsE; // 0x20 set<undefined*, LegoPathControllerComparator> m_pfsE; // 0x20
map<undefined*, undefined*, LegoPathControllerComparator> m_unk0x30; // 0x30 LegoPathActorSet m_actors; // 0x30
}; };
// clang-format off
// TEMPLATE: LEGO1 0x100451a0
// _Tree<unsigned char *,unsigned char *,set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >::_Kfn,LegoPathControllerComparator,allocator<unsigned char *> >::~_Tree<unsigned char *,unsigned char *,set<unsigned char *,LegoPathControl
// TEMPLATE: LEGO1 0x100457e0
// Set<unsigned char *,LegoPathControllerComparator>::~Set<unsigned char *,LegoPathControllerComparator>
// TEMPLATE: LEGO1 0x10045830
// set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >::~set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >
// GLOBAL: LEGO1 0x100f4360
// _Tree<unsigned char *,unsigned char *,set<unsigned char *,LegoPathControllerComparator,allocator<unsigned char *> >::_Kfn,LegoPathControllerComparator,allocator<unsigned char *> >::_Nil
// clang-format on
#endif // LEGOPATHCONTROLLER_H #endif // LEGOPATHCONTROLLER_H

View file

@ -484,7 +484,7 @@ void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p
m_world->PlaceActor( m_world->PlaceActor(
this, this,
g_spawnLocations[i].m_path, g_spawnLocations[i].m_name,
g_spawnLocations[i].m_src, g_spawnLocations[i].m_src,
g_spawnLocations[i].m_srcScale, g_spawnLocations[i].m_srcScale,
g_spawnLocations[i].m_dest, g_spawnLocations[i].m_dest,

View file

@ -152,7 +152,7 @@ LegoAnimationManager::~LegoAnimationManager()
if (actor != NULL && actor->GetController() != NULL && CurrentWorld() != NULL) { if (actor != NULL && actor->GetController() != NULL && CurrentWorld() != NULL) {
CurrentWorld()->FUN_1001fc80((IslePathActor*) actor); CurrentWorld()->FUN_1001fc80((IslePathActor*) actor);
actor->ClearController(); actor->SetController(NULL);
} }
CharacterManager()->FUN_10083db0(roi); CharacterManager()->FUN_10083db0(roi);
@ -238,7 +238,7 @@ void LegoAnimationManager::Suspend()
if (actor != NULL && actor->GetController() != NULL) { if (actor != NULL && actor->GetController() != NULL) {
actor->GetController()->FUN_10046770(actor); actor->GetController()->FUN_10046770(actor);
actor->ClearController(); actor->SetController(NULL);
} }
CharacterManager()->FUN_10083db0(roi); CharacterManager()->FUN_10083db0(roi);
@ -863,7 +863,7 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt
if (controller) { if (controller) {
controller->FUN_10046770(actor); controller->FUN_10046770(actor);
actor->ClearController(); actor->SetController(NULL);
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
if (m_extras[i].m_roi == roi) { if (m_extras[i].m_roi == roi) {
@ -1192,7 +1192,7 @@ MxResult LegoAnimationManager::Tickle()
if (actor != NULL && actor->GetController() != NULL) { if (actor != NULL && actor->GetController() != NULL) {
actor->GetController()->FUN_10046770(actor); actor->GetController()->FUN_10046770(actor);
actor->ClearController(); actor->SetController(NULL);
} }
CharacterManager()->FUN_10083db0(roi); CharacterManager()->FUN_10083db0(roi);
@ -1452,7 +1452,7 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info)
if (controller) { if (controller) {
controller->FUN_10046770(actor); controller->FUN_10046770(actor);
actor->ClearController(); actor->SetController(NULL);
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
if (m_extras[i].m_roi == actor->GetROI()) { if (m_extras[i].m_roi == actor->GetROI()) {
@ -1561,7 +1561,7 @@ void LegoAnimationManager::PurgeExtra(MxBool p_und)
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
if (actor != NULL && actor->GetController() != NULL) { if (actor != NULL && actor->GetController() != NULL) {
actor->GetController()->FUN_10046770(actor); actor->GetController()->FUN_10046770(actor);
actor->ClearController(); actor->SetController(NULL);
} }
CharacterManager()->FUN_10083db0(roi); CharacterManager()->FUN_10083db0(roi);

View file

@ -80,6 +80,7 @@ MxResult LegoPathActor::VTable0x80(Vector3& p_point1, Vector3& p_point2, Vector3
} }
// FUNCTION: LEGO1 0x1002d9c0 // FUNCTION: LEGO1 0x1002d9c0
// FUNCTION: BETA10 0x100ae9da
MxResult LegoPathActor::VTable0x88( MxResult LegoPathActor::VTable0x88(
LegoPathBoundary* p_boundary, LegoPathBoundary* p_boundary,
float p_time, float p_time,

View file

@ -1,13 +1,22 @@
#include "legopathcontroller.h" #include "legopathcontroller.h"
#include "legopathboundary.h" #include "mxmisc.h"
#include "mxtimer.h"
DECOMP_SIZE_ASSERT(LegoPathController, 0x40) DECOMP_SIZE_ASSERT(LegoPathController, 0x40)
// STUB: LEGO1 0x10044f40 // FUNCTION: LEGO1 0x10044f40
// FUNCTION: BETA10 0x100b6860
LegoPathController::LegoPathController() LegoPathController::LegoPathController()
{ {
// TODO m_unk0x08 = NULL;
m_unk0x0c = 0;
m_unk0x10 = 0;
m_unk0x14 = 0;
m_numL = 0;
m_numE = 0;
m_numN = 0;
m_numT = 0;
} }
// STUB: LEGO1 0x10045880 // STUB: LEGO1 0x10045880
@ -29,7 +38,7 @@ MxResult LegoPathController::Tickle()
return SUCCESS; return SUCCESS;
} }
// STUB: LEGO1 0x10045c20 // FUNCTION: LEGO1 0x10045c20
// FUNCTION: BETA10 0x100b6d80 // FUNCTION: BETA10 0x100b6d80
MxResult LegoPathController::FUN_10045c20( MxResult LegoPathController::FUN_10045c20(
LegoPathActor* p_actor, LegoPathActor* p_actor,
@ -40,10 +49,28 @@ MxResult LegoPathController::FUN_10045c20(
float p_destScale float p_destScale
) )
{ {
if (p_actor->GetController() != NULL) {
p_actor->GetController()->FUN_10046770(p_actor);
p_actor->SetController(NULL);
}
LegoPathBoundary* pBoundary = GetPathBoundary(p_name);
LegoEdge* pSrcE = pBoundary->GetEdges()[p_src];
LegoEdge* pDestE = pBoundary->GetEdges()[p_dest];
float time = Timer()->GetTime();
if (p_actor->VTable0x88(pBoundary, time, *pSrcE, p_srcScale, (LegoUnknown100db7f4&) *pDestE, p_destScale) !=
SUCCESS) {
return FAILURE;
}
p_actor->SetController(this);
m_actors.insert(p_actor);
return SUCCESS; return SUCCESS;
} }
// STUB: LEGO1 0x10046770 // STUB: LEGO1 0x10046770
// FUNCTION: BETA10 0x100b7264
undefined4 LegoPathController::FUN_10046770(LegoPathActor* p_actor) undefined4 LegoPathController::FUN_10046770(LegoPathActor* p_actor)
{ {
return 0; return 0;
@ -72,7 +99,7 @@ MxResult LegoPathController::FUN_10046b30(LegoPathBoundary** p_path, MxS32& p_va
LegoPathBoundary* LegoPathController::GetPathBoundary(const char* p_name) LegoPathBoundary* LegoPathController::GetPathBoundary(const char* p_name)
{ {
for (MxS32 i = 0; i < m_numL; i++) { for (MxS32 i = 0; i < m_numL; i++) {
if (strcmpi(m_unk0x08[i].GetName(), p_name) == 0) { if (!strcmpi(m_unk0x08[i].GetName(), p_name)) {
return &m_unk0x08[i]; return &m_unk0x08[i];
} }
} }

View file

@ -10,6 +10,7 @@
class LegoUnknown100db7f4 : public LegoEdge { class LegoUnknown100db7f4 : public LegoEdge {
public: public:
// FUNCTION: LEGO1 0x1002ddc0 // FUNCTION: LEGO1 0x1002ddc0
// FUNCTION: BETA10 0x100372a0
LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point) LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point)
{ {
if (p_f.IsEqual(*m_faceA)) { if (p_f.IsEqual(*m_faceA)) {

View file

@ -15,6 +15,7 @@ class LegoWEEdge {
virtual LegoResult VTable0x04(); // vtable+0x04 virtual LegoResult VTable0x04(); // vtable+0x04
inline LegoU8 GetNumEdges() { return m_numEdges; } inline LegoU8 GetNumEdges() { return m_numEdges; }
inline LegoEdge** GetEdges() { return m_edges; }
inline LegoU32 IsEqual(LegoWEEdge& p_other) { return this == &p_other; } inline LegoU32 IsEqual(LegoWEEdge& p_other) { return this == &p_other; }
// SYNTHETIC: LEGO1 0x1009a570 // SYNTHETIC: LEGO1 0x1009a570