Implement/match LegoPathController::AddActor and RemoveActor (#915)

* Implement/match LegoPathController::AddActor and RemoveActor

* Fix types
This commit is contained in:
Christian Semmler 2024-05-13 06:46:59 -04:00 committed by GitHub
parent 91fe09af3c
commit 5f34d2e877
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 145 additions and 69 deletions

View file

@ -29,13 +29,14 @@ class LegoPathBoundary : public LegoWEGEdge {
~LegoPathBoundary() override;
MxResult AddActor(LegoPathActor* p_actor);
MxResult RemoveActor(LegoPathActor* p_actor);
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);
MxU32 FUN_10057fe0(LegoAnimPresenter* p_presenter);
MxU32 FUN_100586e0(LegoAnimPresenter* p_presenter);
inline LegoPathActorSet* GetActors() { return &m_actors; }
inline LegoAnimPresenterSet* GetPresenters() { return &m_presenters; }
inline LegoPathActorSet& GetActors() { return m_actors; }
inline LegoAnimPresenterSet& GetPresenters() { return m_presenters; }
// SYNTHETIC: LEGO1 0x10047a80
// LegoPathBoundary::`vector deleting destructor'

View file

@ -89,7 +89,14 @@ class LegoPathController : public MxCore {
MxS32 p_dest,
float p_destScale
);
undefined4 FUN_10046770(LegoPathActor* p_actor);
MxResult FUN_10046050(
LegoPathActor* p_actor,
LegoAnimPresenter* p_presenter,
Vector3& p_position,
Vector3& p_direction
);
MxResult AddActor(LegoPathActor* p_actor);
MxResult RemoveActor(LegoPathActor* p_actor);
void FUN_100468f0(LegoAnimPresenter* p_presenter);
void FUN_10046930(LegoAnimPresenter* p_presenter);
MxResult FUN_10046b30(LegoPathBoundary*& p_boundaries, MxS32& p_numL);
@ -120,6 +127,9 @@ class LegoPathController : public MxCore {
};
// clang-format off
// TEMPLATE: LEGO1 0x1001fd70
// _Tree<LegoPathActor *,LegoPathActor *,set<LegoPathActor *,LegoPathActorSetCompare,allocator<LegoPathActor *> >::_Kfn,LegoPathActorSetCompare,allocator<LegoPathActor *> >::_Lbound
// TEMPLATE: LEGO1 0x1002c4a0
// _Tree<LegoPathActor *,LegoPathActor *,set<LegoPathActor *,LegoPathActorSetCompare,allocator<LegoPathActor *> >::_Kfn,LegoPathActorSetCompare,allocator<LegoPathActor *> >::_Buynode
@ -132,6 +142,9 @@ class LegoPathController : public MxCore {
// TEMPLATE: LEGO1 0x10045830
// set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::~set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >
// TEMPLATE: LEGO1 0x100468c0
// _Tree<LegoPathActor *,LegoPathActor *,set<LegoPathActor *,LegoPathActorSetCompare,allocator<LegoPathActor *> >::_Kfn,LegoPathActorSetCompare,allocator<LegoPathActor *> >::_Ubound
// TEMPLATE: LEGO1 0x10047550
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Insert

View file

@ -73,14 +73,14 @@ class LegoWorld : public LegoEntity {
MxS32 p_dest,
float p_destScale
);
undefined4 FUN_1001fa70(IslePathActor* p_actor);
undefined4 FUN_1001fb70(
IslePathActor* p_actor,
MxResult AddPathActor(LegoPathActor* p_actor);
MxResult FUN_1001fb70(
LegoPathActor* p_actor,
LegoAnimPresenter* p_presenter,
Vector3& p_position,
Vector3& p_direction
);
void FUN_1001fc80(IslePathActor* p_actor);
void RemovePathActor(LegoPathActor* p_actor);
void FUN_1001fda0(LegoAnimPresenter* p_presenter);
void FUN_1001fe90(LegoAnimPresenter* p_presenter);
LegoPathBoundary* FindPathBoundary(const char* p_name);

View file

@ -190,7 +190,7 @@ MxU32 Helicopter::VTable0xd4(LegoControlManagerEvent& p_param)
if (m_state->GetUnkown8() == 0) {
state->SetUnknown18(4);
m_state->SetUnknown8(1);
m_world->FUN_1001fc80(this);
m_world->RemovePathActor(this);
InvokeAction(Extra::ActionType::e_start, script, 0x20, NULL);
SetState(0);
}
@ -203,7 +203,7 @@ MxU32 Helicopter::VTable0xd4(LegoControlManagerEvent& p_param)
}
if (m_state->GetUnkown8() == 2) {
m_state->SetUnknown8(3);
m_world->FUN_1001fc80(this);
m_world->RemovePathActor(this);
InvokeAction(Extra::ActionType::e_start, script, 0x21, NULL);
SetState(4);
}

View file

@ -471,7 +471,7 @@ void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p
assert(world);
if (m_world != NULL) {
m_world->FUN_1001fc80(this);
m_world->RemovePathActor(this);
m_world->Remove(this);
VideoManager()->Get3DManager()->Remove(*m_roi);
}
@ -556,7 +556,7 @@ void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p
void IslePathActor::VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundary, MxBool p_reset)
{
if (m_world) {
m_world->FUN_1001fc80(this);
m_world->RemovePathActor(this);
m_world->Remove(this);
VideoManager()->Get3DManager()->GetLego3DView()->Remove(*m_roi);
}
@ -566,7 +566,7 @@ void IslePathActor::VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundar
VTable0xe0();
}
m_world->FUN_1001fa70(this);
m_world->AddPathActor(this);
p_boundary->AddActor(this);
if (m_actorId != GameState()->GetActorId()) {
m_world->Add(this);

View file

@ -151,7 +151,7 @@ LegoAnimationManager::~LegoAnimationManager()
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
if (actor != NULL && actor->GetController() != NULL && CurrentWorld() != NULL) {
CurrentWorld()->FUN_1001fc80((IslePathActor*) actor);
CurrentWorld()->RemovePathActor(actor);
actor->SetController(NULL);
}
@ -237,7 +237,7 @@ void LegoAnimationManager::Suspend()
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
if (actor != NULL && actor->GetController() != NULL) {
actor->GetController()->FUN_10046770(actor);
actor->GetController()->RemoveActor(actor);
actor->SetController(NULL);
}
@ -862,7 +862,7 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt
LegoPathController* controller = actor->GetController();
if (controller) {
controller->FUN_10046770(actor);
controller->RemoveActor(actor);
actor->SetController(NULL);
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
@ -1191,7 +1191,7 @@ MxResult LegoAnimationManager::Tickle()
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
if (actor != NULL && actor->GetController() != NULL) {
actor->GetController()->FUN_10046770(actor);
actor->GetController()->RemoveActor(actor);
actor->SetController(NULL);
}
@ -1451,7 +1451,7 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info)
LegoPathController* controller = actor->GetController();
if (controller) {
controller->FUN_10046770(actor);
controller->RemoveActor(actor);
actor->SetController(NULL);
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
@ -1560,7 +1560,7 @@ void LegoAnimationManager::PurgeExtra(MxBool p_und)
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
if (actor != NULL && actor->GetController() != NULL) {
actor->GetController()->FUN_10046770(actor);
actor->GetController()->RemoveActor(actor);
actor->SetController(NULL);
}

View file

@ -432,7 +432,7 @@ MxBool LegoAnimMMPresenter::FUN_1004b6d0(MxLong p_time)
undefined4 und = 1;
if (m_presenter != NULL) {
m_unk0x64->FUN_1001fc80(actor);
m_unk0x64->RemovePathActor(actor);
if (m_tranInfo->m_unk0x29) {
Mx3DPointFloat position, direction;
@ -451,7 +451,7 @@ MxBool LegoAnimMMPresenter::FUN_1004b6d0(MxLong p_time)
if (und != 0) {
viewROI->WrappedSetLocalTransform(m_tranInfo->m_unk0x2c);
VideoManager()->Get3DManager()->Moved(*viewROI);
m_unk0x64->FUN_1001fa70(actor);
m_unk0x64->AddPathActor(actor);
}
if (m_tranInfo->m_unk0x29) {

View file

@ -1100,28 +1100,28 @@ void LegoGameState::Init()
Helicopter* copter = (Helicopter*) isle->Find(*g_copterScript, CopterScript::c_Helicopter_Actor);
if (copter) {
isle->FUN_1001fc80(copter);
isle->RemovePathActor(copter);
isle->VTable0x6c(copter);
delete copter;
}
DuneBuggy* dunebuggy = (DuneBuggy*) isle->Find(*g_dunecarScript, DunecarScript::c_DuneBugy_Actor);
if (dunebuggy) {
isle->FUN_1001fc80(dunebuggy);
isle->RemovePathActor(dunebuggy);
isle->VTable0x6c(dunebuggy);
delete dunebuggy;
}
Jetski* jetski = (Jetski*) isle->Find(*g_jetskiScript, JetskiScript::c_Jetski_Actor);
if (jetski) {
isle->FUN_1001fc80(jetski);
isle->RemovePathActor(jetski);
isle->VTable0x6c(jetski);
delete jetski;
}
RaceCar* racecar = (RaceCar*) isle->Find(*g_racecarScript, RacecarScript::c_RaceCar_Actor);
if (racecar) {
isle->FUN_1001fc80(racecar);
isle->RemovePathActor(racecar);
isle->VTable0x6c(racecar);
delete racecar;
}

View file

@ -295,33 +295,49 @@ MxResult LegoWorld::PlaceActor(
return FAILURE;
}
// STUB: LEGO1 0x1001fa70
undefined4 LegoWorld::FUN_1001fa70(IslePathActor* p_actor)
{
// TODO
return 0;
}
// STUB: LEGO1 0x1001fb70
undefined4 LegoWorld::FUN_1001fb70(
IslePathActor* p_actor,
LegoAnimPresenter* p_presenter,
Vector3& p_position,
Vector3& p_direction
)
{
// TODO
return 0;
}
// FUNCTION: LEGO1 0x1001fc80
void LegoWorld::FUN_1001fc80(IslePathActor* p_actor)
// FUNCTION: LEGO1 0x1001fa70
MxResult LegoWorld::AddPathActor(LegoPathActor* p_actor)
{
LegoPathControllerListCursor cursor(&m_list0x68);
LegoPathController* controller;
while (cursor.Next(controller)) {
if (!controller->FUN_10046770(p_actor)) {
if (controller->AddActor(p_actor) == SUCCESS) {
return SUCCESS;
}
}
return FAILURE;
}
// FUNCTION: LEGO1 0x1001fb70
MxResult LegoWorld::FUN_1001fb70(
LegoPathActor* p_actor,
LegoAnimPresenter* p_presenter,
Vector3& p_position,
Vector3& p_direction
)
{
LegoPathControllerListCursor cursor(&m_list0x68);
LegoPathController* controller;
while (cursor.Next(controller)) {
if (controller->FUN_10046050(p_actor, p_presenter, p_position, p_direction) == SUCCESS) {
return SUCCESS;
}
}
return FAILURE;
}
// FUNCTION: LEGO1 0x1001fc80
void LegoWorld::RemovePathActor(LegoPathActor* p_actor)
{
LegoPathControllerListCursor cursor(&m_list0x68);
LegoPathController* controller;
while (cursor.Next(controller)) {
if (controller->RemoveActor(p_actor) == SUCCESS) {
break;
}
}
@ -487,7 +503,7 @@ void LegoWorld::Remove(MxCore* p_object)
}
else if (p_object->IsA("MxEntity")) {
if (p_object->IsA("LegoPathActor")) {
FUN_1001fc80((IslePathActor*) p_object);
RemovePathActor((LegoPathActor*) p_object);
}
if (m_entityList) {
@ -688,7 +704,7 @@ void LegoWorld::Enable(MxBool p_enable)
IslePathActor* actor = CurrentActor();
if (actor) {
FUN_1001fc80(actor);
RemovePathActor(actor);
}
AnimationManager()->Reset(FALSE);

View file

@ -287,9 +287,9 @@ MxResult LegoExtraActor::WaitForAnimation()
if (m_boundary != oldBoundary) {
MxU32 b = FALSE;
LegoAnimPresenterSet* set = m_boundary->GetPresenters();
LegoAnimPresenterSet& set = m_boundary->GetPresenters();
for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) {
for (LegoAnimPresenterSet::iterator it = set.begin(); it != set.end(); it++) {
MxU32 roiMapSize;
if ((*it)->GetROIMap(roiMapSize)) {
b = TRUE;
@ -312,9 +312,9 @@ void LegoExtraActor::Restart()
{
if (m_unk0x0e != 0) {
MxU32 b = FALSE;
LegoAnimPresenterSet* set = m_boundary->GetPresenters();
LegoAnimPresenterSet& set = m_boundary->GetPresenters();
for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) {
for (LegoAnimPresenterSet::iterator it = set.begin(); it != set.end(); it++) {
MxU32 roiMapSize;
if ((*it)->GetROIMap(roiMapSize)) {
b = TRUE;

View file

@ -431,19 +431,19 @@ MxU32 LegoPathActor::VTable0x6c(
Vector3& p_v3
)
{
LegoAnimPresenterSet* laps = p_boundary->GetPresenters();
LegoAnimPresenterSet& laps = p_boundary->GetPresenters();
for (LegoAnimPresenterSet::iterator itap = laps->begin(); itap != laps->end(); itap++) {
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);
LegoPathActorSet& plpas = p_boundary->GetActors();
LegoPathActorSet lpas(plpas);
for (LegoPathActorSet::iterator itpa = lpas.begin(); itpa != lpas.end(); itpa++) {
if (plpas->find(*itpa) != plpas->end()) {
if (plpas.find(*itpa) != plpas.end()) {
LegoPathActor* actor = *itpa;
if (this != actor && !(actor->GetState() & 0x100)) {

View file

@ -25,6 +25,14 @@ MxResult LegoPathBoundary::AddActor(LegoPathActor* p_actor)
return SUCCESS;
}
// FUNCTION: LEGO1 0x100574a0
// FUNCTION: BETA10 0x100b156f
MxResult LegoPathBoundary::RemoveActor(LegoPathActor* p_actor)
{
m_actors.erase(p_actor);
return SUCCESS;
}
// STUB: LEGO1 0x100575b0
void LegoPathBoundary::FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPathActor* p_actor)
{

View file

@ -207,7 +207,7 @@ MxResult LegoPathController::FUN_10045c20(
)
{
if (p_actor->GetController() != NULL) {
p_actor->GetController()->FUN_10046770(p_actor);
p_actor->GetController()->RemoveActor(p_actor);
p_actor->SetController(NULL);
}
@ -226,11 +226,49 @@ MxResult LegoPathController::FUN_10045c20(
return SUCCESS;
}
// STUB: LEGO1 0x10046770
// FUNCTION: BETA10 0x100b7264
undefined4 LegoPathController::FUN_10046770(LegoPathActor* p_actor)
// STUB: LEGO1 0x10046050
// FUNCTION: BETA10 0x100b6f35
MxResult LegoPathController::FUN_10046050(
LegoPathActor* p_actor,
LegoAnimPresenter* p_presenter,
Vector3& p_position,
Vector3& p_direction
)
{
return 0;
// TODO
return SUCCESS;
}
// FUNCTION: LEGO1 0x100466a0
// FUNCTION: BETA10 0x100b71fe
MxResult LegoPathController::AddActor(LegoPathActor* p_actor)
{
if (p_actor->GetController() != NULL) {
p_actor->GetController()->RemoveActor(p_actor);
p_actor->SetController(NULL);
}
m_actors.insert(p_actor);
p_actor->SetController(this);
return SUCCESS;
}
// FUNCTION: LEGO1 0x10046770
// FUNCTION: BETA10 0x100b7264
MxResult LegoPathController::RemoveActor(LegoPathActor* p_actor)
{
MxResult result = FAILURE;
p_actor->VTable0xc4();
m_actors.erase(p_actor);
for (MxS32 i = 0; i < m_numL; i++) {
if (m_boundaries[i].RemoveActor(p_actor) == SUCCESS) {
result = SUCCESS;
}
}
return result;
}
// FUNCTION: LEGO1 0x100468f0

View file

@ -526,7 +526,7 @@ void Isle::Enable(MxBool p_enable)
m_act1state->m_unk0x018 = 5;
}
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE
@ -549,7 +549,7 @@ void Isle::Enable(MxBool p_enable)
SetIsWorldActive(FALSE);
break;
case LegoGameState::e_bike:
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE
@ -562,7 +562,7 @@ void Isle::Enable(MxBool p_enable)
#endif
break;
case LegoGameState::e_dunecar:
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE
@ -575,7 +575,7 @@ void Isle::Enable(MxBool p_enable)
#endif
break;
case LegoGameState::e_motocycle:
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE
@ -588,7 +588,7 @@ void Isle::Enable(MxBool p_enable)
#endif
break;
case LegoGameState::e_copter:
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE
@ -601,7 +601,7 @@ void Isle::Enable(MxBool p_enable)
#endif
break;
case LegoGameState::e_skateboard:
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE
@ -614,7 +614,7 @@ void Isle::Enable(MxBool p_enable)
#endif
break;
case LegoGameState::e_jetski:
FUN_1001fa70(CurrentActor());
AddPathActor(CurrentActor());
SetIsWorldActive(TRUE);
#ifdef COMPAT_MODE