Implement/match Act1State::RemoveActors (#1132)

* Implement/match Act1State::RemoveActors

* Fix annotation
This commit is contained in:
Christian Semmler 2024-11-03 11:06:09 -07:00 committed by GitHub
parent 040c97d92a
commit d8412a4697
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 163 additions and 99 deletions

View file

@ -28,7 +28,7 @@ class HelicopterState : public LegoState {
MxBool IsSerializable() override { return FALSE; } // vtable+0x14
// FUNCTION: LEGO1 0x1000e0c0
MxBool SetFlag() override
MxBool Reset() override
{
m_unk0x08 = 0;
return TRUE;

View file

@ -3,6 +3,7 @@
#include "actionsfwd.h"
#include "legogamestate.h"
#include "legonamedplane.h"
#include "legostate.h"
#include "legoworld.h"
#include "radio.h"
@ -32,41 +33,6 @@ class Act1State : public LegoState {
c_floor3
};
// SIZE 0x4c
class NamedPlane {
public:
// FUNCTION: LEGO1 0x10033800
NamedPlane() {}
void SetName(const char* p_name) { m_name = p_name; }
const MxString* GetName() const { return &m_name; }
// FUNCTION: LEGO1 0x100344d0
MxResult Serialize(LegoFile* p_file)
{
if (p_file->IsWriteMode()) {
p_file->WriteString(m_name);
p_file->WriteVector3(m_point1);
p_file->WriteVector3(m_point2);
p_file->WriteVector3(m_point3);
}
else if (p_file->IsReadMode()) {
p_file->ReadString(m_name);
p_file->ReadVector3(m_point1);
p_file->ReadVector3(m_point2);
p_file->ReadVector3(m_point3);
}
return SUCCESS;
}
private:
MxString m_name; // 0x00
Mx3DPointFloat m_point1; // 0x10
Mx3DPointFloat m_point2; // 0x24
Mx3DPointFloat m_point3; // 0x38
};
Act1State();
// FUNCTION: LEGO1 0x100338a0
@ -82,12 +48,12 @@ class Act1State : public LegoState {
return !strcmp(p_name, Act1State::ClassName()) || LegoState::IsA(p_name);
}
MxBool SetFlag() override; // vtable+0x18
MxBool Reset() override; // vtable+0x18
MxResult Serialize(LegoFile* p_file) override; // vtable+0x1c
void PlayCptClickDialogue();
void StopCptClickDialogue();
void FUN_10034b60();
void RemoveActors();
void FUN_10034d00();
MxU32 GetUnknown18() { return m_unk0x018; }
@ -113,31 +79,28 @@ class Act1State : public LegoState {
undefined m_unk0x021; // 0x021
MxBool m_unk0x022; // 0x022
undefined m_unk0x023; // 0x023
NamedPlane m_unk0x024; // 0x024
NamedPlane m_unk0x070; // 0x070
NamedPlane m_unk0x0bc; // 0x0bc
NamedPlane m_unk0x108; // 0x108
LegoNamedPlane m_motocyclePlane; // 0x024
LegoNamedPlane m_bikePlane; // 0x070
LegoNamedPlane m_skateboardPlane; // 0x0bc
LegoNamedPlane m_helicopterPlane; // 0x108
LegoNamedTexture* m_unk0x154; // 0x154
LegoNamedTexture* m_unk0x158; // 0x158
LegoNamedTexture* m_unk0x15c; // 0x15c
Helicopter* m_helicopter; // 0x160
NamedPlane m_unk0x164; // 0x164
LegoNamedPlane m_jetskiPlane; // 0x164
LegoNamedTexture* m_unk0x1b0; // 0x1b0
LegoNamedTexture* m_unk0x1b4; // 0x1b4
Jetski* m_jetski; // 0x1b8
NamedPlane m_unk0x1bc; // 0x1bc
LegoNamedPlane m_dunebuggyPlane; // 0x1bc
LegoNamedTexture* m_unk0x208; // 0x208
DuneBuggy* m_dunebuggy; // 0x20c
NamedPlane m_unk0x210; // 0x210
LegoNamedPlane m_racecarPlane; // 0x210
LegoNamedTexture* m_unk0x25c; // 0x25c
LegoNamedTexture* m_unk0x260; // 0x260
LegoNamedTexture* m_unk0x264; // 0x264
RaceCar* m_racecar; // 0x268
};
// FUNCTION: LEGO1 0x10033a70
// Act1State::NamedPlane::~NamedPlane
// VTABLE: LEGO1 0x100d6fb8
// SIZE 0x140
class Isle : public LegoWorld {
@ -184,6 +147,8 @@ class Isle : public LegoWorld {
void FUN_10033350();
friend class Act1State;
// SYNTHETIC: LEGO1 0x10030a30
// Isle::`scalar deleting destructor'

View file

@ -67,7 +67,7 @@ class AnimState : public LegoState {
return !strcmp(p_name, AnimState::ClassName()) || LegoState::IsA(p_name);
}
MxBool SetFlag() override; // vtable+0x18
MxBool Reset() override; // vtable+0x18
MxResult Serialize(LegoFile* p_file) override; // vtable+0x1c
void CopyToAnims(MxU32, AnimInfo* p_anims, MxU32& p_outExtraCharacterId);

View file

@ -0,0 +1,46 @@
#ifndef LEGONAMEDPLANE_H
#define LEGONAMEDPLANE_H
#include "misc/legostorage.h"
#include "mxgeometry/mxgeometry3d.h"
#include "mxstring.h"
// SIZE 0x4c
class LegoNamedPlane {
public:
// FUNCTION: LEGO1 0x10033800
LegoNamedPlane() {}
// FUNCTION: LEGO1 0x10033a70
// LegoNamedPlane::~LegoNamedPlane
void SetName(const char* p_name) { m_name = p_name; }
const MxString* GetName() const { return &m_name; }
// FUNCTION: LEGO1 0x100344d0
MxResult Serialize(LegoFile* p_file)
{
if (p_file->IsWriteMode()) {
p_file->WriteString(m_name);
p_file->WriteVector3(m_position);
p_file->WriteVector3(m_direction);
p_file->WriteVector3(m_up);
}
else if (p_file->IsReadMode()) {
p_file->ReadString(m_name);
p_file->ReadVector3(m_position);
p_file->ReadVector3(m_direction);
p_file->ReadVector3(m_up);
}
return SUCCESS;
}
private:
MxString m_name; // 0x00
Mx3DPointFloat m_position; // 0x10
Mx3DPointFloat m_direction; // 0x24
Mx3DPointFloat m_up; // 0x38
};
#endif // LEGONAMEDPLANE_H

View file

@ -7,6 +7,7 @@
#include "mxtypes.h"
struct LegoEdge;
class LegoNamedPlane;
class LegoPathBoundary;
class LegoPathController;
struct LegoPathEdgeContainer;
@ -140,6 +141,8 @@ class LegoPathActor : public LegoActor {
void SetController(LegoPathController* p_controller) { m_controller = p_controller; }
void UpdatePlane(LegoNamedPlane& p_namedPlane);
// SYNTHETIC: LEGO1 0x1002d800
// LegoPathActor::`scalar deleting destructor'

View file

@ -99,7 +99,7 @@ class LegoState : public MxCore {
virtual MxBool IsSerializable() { return TRUE; } // vtable+0x14
// FUNCTION: LEGO1 0x10005fa0
virtual MxBool SetFlag() { return FALSE; } // vtable+0x18
virtual MxBool Reset() { return FALSE; } // vtable+0x18
// FUNCTION: LEGO1 0x10005fb0
virtual MxResult Serialize(LegoFile* p_file)

View file

@ -31,7 +31,7 @@ class ScoreState : public LegoState {
MxBool IsSerializable() override { return FALSE; } // vtable+0x14
// FUNCTION: LEGO1 0x1000de30
MxBool SetFlag() override
MxBool Reset() override
{
m_playCubeTutorial = TRUE;
return TRUE;

View file

@ -1,6 +1,7 @@
#include "bumpbouy.h"
#include "isle.h"
#include "isle_actions.h"
#include "islepathactor.h"
#include "legogamestate.h"
#include "legovideomanager.h"
@ -44,7 +45,7 @@ MxLong BumpBouy::Notify(MxParam& p_param)
assert(isleState);
isleState->m_unk0x018 = 5;
Isle* isle = (Isle*) FindWorld(*g_isleScript, 0);
Isle* isle = (Isle*) FindWorld(*g_isleScript, IsleScript::c__Isle);
assert(isle);
isle->SetDestLocation(LegoGameState::e_jetrace);

View file

@ -41,7 +41,7 @@ MxLong JukeBoxEntity::Notify(MxParam& p_param)
((IslePathActor*) UserActor())->Exit();
}
((Isle*) FindWorld(*g_isleScript, 0))->SetDestLocation(LegoGameState::e_jukeboxw);
((Isle*) FindWorld(*g_isleScript, IsleScript::c__Isle))->SetDestLocation(LegoGameState::e_jukeboxw);
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
return 1;
}

View file

@ -4,6 +4,7 @@
#include "dunebuggy.h"
#include "dunecar_actions.h"
#include "helicopter.h"
#include "isle_actions.h"
#include "jetski.h"
#include "jetski_actions.h"
#include "jukebox_actions.h"
@ -1014,7 +1015,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
// This function was changed between BETA10 and LEGO1.
// These lines looks like a relic from older code.
LegoWorld* destWorld = NULL;
destWorld = FindWorld(*g_isleScript, 0);
destWorld = FindWorld(*g_isleScript, IsleScript::c__Isle);
Act1State* gameState = (Act1State*) GameState()->GetState("Act1State");
@ -1025,7 +1026,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
}
gameState->m_helicopter = (Helicopter*) entity;
gameState->m_unk0x108.SetName("");
gameState->m_helicopterPlane.SetName("");
break;
case LegoGameState::e_dunecarbuild:
if (gameState->m_dunebuggy) {
@ -1033,7 +1034,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
}
gameState->m_dunebuggy = (DuneBuggy*) entity;
gameState->m_unk0x1bc.SetName("");
gameState->m_dunebuggyPlane.SetName("");
break;
case LegoGameState::e_jetskibuild:
if (gameState->m_jetski) {
@ -1041,7 +1042,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
}
gameState->m_jetski = (Jetski*) entity;
gameState->m_unk0x164.SetName("");
gameState->m_jetskiPlane.SetName("");
break;
case LegoGameState::e_racecarbuild:
if (gameState->m_racecar) {
@ -1049,7 +1050,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
}
gameState->m_racecar = (RaceCar*) entity;
gameState->m_unk0x210.SetName("");
gameState->m_racecarPlane.SetName("");
break;
}

View file

@ -383,7 +383,7 @@ void LegoAnimationManager::Reset(MxBool p_und)
m_unk0x402 = FALSE;
if (p_und && m_animState != NULL) {
m_animState->SetFlag();
m_animState->Reset();
}
MxBool suspended = m_suspended;
@ -2951,7 +2951,7 @@ MxResult AnimState::Serialize(LegoFile* p_file)
}
// FUNCTION: LEGO1 0x100654f0
MxBool AnimState::SetFlag()
MxBool AnimState::Reset()
{
if (m_unk0x10 != NULL) {
m_extraCharacterId = 0;

View file

@ -302,7 +302,7 @@ MxResult LegoGameState::DeleteState()
m_stateArray = NULL;
for (MxS32 count = 0; count < stateCount; count++) {
if (!stateArray[count]->SetFlag() && stateArray[count]->IsSerializable()) {
if (!stateArray[count]->Reset() && stateArray[count]->IsSerializable()) {
delete stateArray[count];
}
else {
@ -780,7 +780,7 @@ void LegoGameState::StopArea(Area p_area)
inline void LoadIsle()
{
LegoWorld* world = FindWorld(*g_isleScript, 0);
LegoWorld* world = FindWorld(*g_isleScript, IsleScript::c__Isle);
if (world != NULL) {
if (!world->GetUnknown0xd0Empty()) {
NotificationManager()->Send(world, MxNotificationParam(c_notificationType20, NULL));
@ -957,7 +957,7 @@ void LegoGameState::SwitchArea(Area p_area)
InvokeAction(Extra::ActionType::e_opendisk, *g_racecarScript, RacecarScript::c__StartUp, NULL);
break;
case e_act2main: {
LegoWorld* act2main = FindWorld(*g_act2mainScript, 0);
LegoWorld* act2main = FindWorld(*g_act2mainScript, Act2mainScript::c__Act2Main);
if (act2main == NULL) {
InvokeAction(Extra::ActionType::e_opendisk, *g_act2mainScript, Act2mainScript::c__Act2Main, NULL);
@ -969,7 +969,7 @@ void LegoGameState::SwitchArea(Area p_area)
break;
}
case e_act3script: {
LegoWorld* act3 = FindWorld(*g_act3Script, 0);
LegoWorld* act3 = FindWorld(*g_act3Script, Act3Script::c__Act3);
if (act3 == NULL) {
InvokeAction(Extra::ActionType::e_opendisk, *g_act3Script, Act3Script::c__Act3, NULL);
@ -1105,7 +1105,7 @@ void LegoGameState::Init()
SetCurrentAct(e_act1);
if (m_loadedAct == e_act1) {
Isle* isle = (Isle*) FindWorld(*g_isleScript, 0);
Isle* isle = (Isle*) FindWorld(*g_isleScript, IsleScript::c__Isle);
Helicopter* copter = (Helicopter*) isle->Find(*g_copterScript, CopterScript::c_Helicopter_Actor);
if (copter) {
@ -1215,13 +1215,13 @@ void LegoGameState::SetCurrentAct(Act p_currentAct)
// FUNCTION: LEGO1 0x1003ceb0
void LegoGameState::FindLoadedAct()
{
if (FindWorld(*g_isleScript, 0)) {
if (FindWorld(*g_isleScript, IsleScript::c__Isle)) {
m_loadedAct = e_act1;
}
else if (FindWorld(*g_act2mainScript, 0)) {
else if (FindWorld(*g_act2mainScript, Act2mainScript::c__Act2Main)) {
m_loadedAct = e_act2;
}
else if (FindWorld(*g_act3Script, 0)) {
else if (FindWorld(*g_act3Script, Act3Script::c__Act3)) {
m_loadedAct = e_act3;
}
else {

View file

@ -3,6 +3,7 @@
#include "3dmanager/lego3dmanager.h"
#include "anim/legoanim.h"
#include "isle.h"
#include "isle_actions.h"
#include "islepathactor.h"
#include "legoanimationmanager.h"
#include "legoanimpresenter.h"
@ -333,7 +334,7 @@ void NotifyEntity(const char* p_filename, MxS32 p_entityId, LegoEntity* p_sender
// FUNCTION: LEGO1 0x1003eab0
void SetCameraControllerFromIsle()
{
InputManager()->SetCamera(FindWorld(*g_isleScript, 0)->GetCamera());
InputManager()->SetCamera(FindWorld(*g_isleScript, IsleScript::c__Isle)->GetCamera());
}
// FUNCTION: LEGO1 0x1003eae0

View file

@ -718,3 +718,9 @@ void LegoPathActor::VTable0xa8()
FUN_10010c30();
}
}
// STUB: LEGO1 0x1002f770
void LegoPathActor::UpdatePlane(LegoNamedPlane& p_namedPlane)
{
// TODO
}

View file

@ -1404,7 +1404,7 @@ void Infocenter::Reset()
HelicopterState* state = (HelicopterState*) GameState()->GetState("HelicopterState");
if (state) {
state->SetFlag();
state->Reset();
}
}

View file

@ -39,7 +39,7 @@
#include "towtrack.h"
DECOMP_SIZE_ASSERT(Act1State, 0x26c)
DECOMP_SIZE_ASSERT(Act1State::NamedPlane, 0x4c)
DECOMP_SIZE_ASSERT(LegoNamedPlane, 0x4c)
DECOMP_SIZE_ASSERT(Isle, 0x140)
// GLOBAL: LEGO1 0x100f1198
@ -851,7 +851,7 @@ void Isle::Enable(MxBool p_enable)
InputManager()->ClearWorld();
}
m_act1state->FUN_10034b60();
m_act1state->RemoveActors();
}
}
@ -1306,24 +1306,25 @@ Act1State::Act1State()
m_unk0x260 = NULL;
m_unk0x264 = NULL;
m_racecar = NULL;
SetFlag();
Reset();
}
// FUNCTION: LEGO1 0x10033ac0
// FUNCTION: BETA10 0x1003524f
MxResult Act1State::Serialize(LegoFile* p_file)
{
LegoState::Serialize(p_file);
m_unk0x024.Serialize(p_file);
m_unk0x070.Serialize(p_file);
m_unk0x0bc.Serialize(p_file);
m_unk0x108.Serialize(p_file);
m_unk0x164.Serialize(p_file);
m_unk0x1bc.Serialize(p_file);
m_unk0x210.Serialize(p_file);
m_motocyclePlane.Serialize(p_file);
m_bikePlane.Serialize(p_file);
m_skateboardPlane.Serialize(p_file);
m_helicopterPlane.Serialize(p_file);
m_jetskiPlane.Serialize(p_file);
m_dunebuggyPlane.Serialize(p_file);
m_racecarPlane.Serialize(p_file);
if (p_file->IsWriteMode()) {
if (m_unk0x108.GetName()->Compare("") != 0) {
if (m_helicopterPlane.GetName()->Compare("") != 0) {
if (m_unk0x154) {
WriteNamedTexture(p_file, m_unk0x154);
}
@ -1343,7 +1344,7 @@ MxResult Act1State::Serialize(LegoFile* p_file)
FUN_1003f540(p_file, "chjetr.gif");
}
}
if (m_unk0x164.GetName()->Compare("") != 0) {
if (m_jetskiPlane.GetName()->Compare("") != 0) {
if (m_unk0x1b0) {
WriteNamedTexture(p_file, m_unk0x1b0);
}
@ -1357,7 +1358,7 @@ MxResult Act1State::Serialize(LegoFile* p_file)
FUN_1003f540(p_file, "jswnsh.gif");
}
}
if (m_unk0x1bc.GetName()->Compare("") != 0) {
if (m_dunebuggyPlane.GetName()->Compare("") != 0) {
if (m_unk0x208) {
WriteNamedTexture(p_file, m_unk0x208);
}
@ -1365,7 +1366,7 @@ MxResult Act1State::Serialize(LegoFile* p_file)
FUN_1003f540(p_file, "dbfrfn.gif");
}
}
if (m_unk0x210.GetName()->Compare("") != 0) {
if (m_racecarPlane.GetName()->Compare("") != 0) {
if (m_unk0x25c) {
WriteNamedTexture(p_file, m_unk0x25c);
}
@ -1390,7 +1391,7 @@ MxResult Act1State::Serialize(LegoFile* p_file)
Write(p_file, m_unk0x022);
}
else if (p_file->IsReadMode()) {
if (m_unk0x108.GetName()->Compare("") != 0) {
if (m_helicopterPlane.GetName()->Compare("") != 0) {
m_unk0x154 = ReadNamedTexture(p_file);
if (m_unk0x154 == NULL) {
return FAILURE;
@ -1406,7 +1407,7 @@ MxResult Act1State::Serialize(LegoFile* p_file)
return FAILURE;
}
}
if (m_unk0x164.GetName()->Compare("") != 0) {
if (m_jetskiPlane.GetName()->Compare("") != 0) {
m_unk0x1b0 = ReadNamedTexture(p_file);
if (m_unk0x1b0 == NULL) {
return FAILURE;
@ -1417,13 +1418,13 @@ MxResult Act1State::Serialize(LegoFile* p_file)
return FAILURE;
}
}
if (m_unk0x1bc.GetName()->Compare("") != 0) {
if (m_dunebuggyPlane.GetName()->Compare("") != 0) {
m_unk0x208 = ReadNamedTexture(p_file);
if (m_unk0x208 == NULL) {
return FAILURE;
}
}
if (m_unk0x210.GetName()->Compare("") != 0) {
if (m_racecarPlane.GetName()->Compare("") != 0) {
m_unk0x25c = ReadNamedTexture(p_file);
if (m_unk0x25c == NULL) {
return FAILURE;
@ -1470,13 +1471,13 @@ void Act1State::StopCptClickDialogue()
}
// FUNCTION: LEGO1 0x100346d0
MxBool Act1State::SetFlag()
MxBool Act1State::Reset()
{
m_unk0x024.SetName("");
m_unk0x070.SetName("");
m_unk0x0bc.SetName("");
m_motocyclePlane.SetName("");
m_bikePlane.SetName("");
m_skateboardPlane.SetName("");
m_unk0x022 = FALSE;
m_unk0x108.SetName("");
m_helicopterPlane.SetName("");
if (m_unk0x154) {
delete m_unk0x154;
@ -1498,7 +1499,7 @@ MxBool Act1State::SetFlag()
m_helicopter = NULL;
}
m_unk0x164.SetName("");
m_jetskiPlane.SetName("");
if (m_unk0x1b0) {
delete m_unk0x1b0;
@ -1515,7 +1516,7 @@ MxBool Act1State::SetFlag()
m_jetski = NULL;
}
m_unk0x1bc.SetName("");
m_dunebuggyPlane.SetName("");
if (m_unk0x208) {
delete m_unk0x208;
@ -1527,7 +1528,7 @@ MxBool Act1State::SetFlag()
m_dunebuggy = NULL;
}
m_unk0x210.SetName("");
m_racecarPlane.SetName("");
if (m_unk0x25c) {
delete m_unk0x25c;
@ -1552,10 +1553,50 @@ MxBool Act1State::SetFlag()
return TRUE;
}
// STUB: LEGO1 0x10034b60
void Act1State::FUN_10034b60()
// FUNCTION: LEGO1 0x10034b60
void Act1State::RemoveActors()
{
// TODO
Isle* isle = (Isle*) FindWorld(*g_isleScript, IsleScript::c__Isle);
isle->m_motocycle->UpdatePlane(m_motocyclePlane);
isle->m_bike->UpdatePlane(m_bikePlane);
isle->m_skateboard->UpdatePlane(m_skateboardPlane);
if (isle->m_helicopter != NULL) {
isle->m_helicopter->UpdatePlane(m_helicopterPlane);
m_helicopter = isle->m_helicopter;
isle->RemoveActor(m_helicopter);
isle->VTable0x6c(m_helicopter);
m_helicopter->SetBoundary(NULL);
m_helicopter->SetController(NULL);
}
if (isle->m_jetski != NULL) {
isle->m_jetski->UpdatePlane(m_jetskiPlane);
m_jetski = isle->m_jetski;
isle->RemoveActor(m_jetski);
isle->VTable0x6c(m_jetski);
m_jetski->SetBoundary(NULL);
m_jetski->SetController(NULL);
}
if (isle->m_dunebuggy != NULL) {
isle->m_dunebuggy->UpdatePlane(m_dunebuggyPlane);
m_dunebuggy = isle->m_dunebuggy;
isle->RemoveActor(m_dunebuggy);
isle->VTable0x6c(m_dunebuggy);
m_dunebuggy->SetBoundary(NULL);
m_dunebuggy->SetController(NULL);
}
if (isle->m_racecar != NULL) {
isle->m_racecar->UpdatePlane(m_racecarPlane);
m_racecar = isle->m_racecar;
isle->RemoveActor(m_racecar);
isle->VTable0x6c(m_racecar);
m_racecar->SetBoundary(NULL);
m_racecar->SetController(NULL);
}
}
// STUB: LEGO1 0x10034d00