Refactor/improve matches in Act1State (#1143)

* Refactor/improve matches in Act1State

* Fix naming
This commit is contained in:
Christian Semmler 2024-11-10 14:47:12 -07:00 committed by GitHub
parent 5d3d66965d
commit cd261b9518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 200 additions and 193 deletions

View file

@ -83,21 +83,21 @@ class Act1State : public LegoState {
LegoNamedPlane m_bikePlane; // 0x070 LegoNamedPlane m_bikePlane; // 0x070
LegoNamedPlane m_skateboardPlane; // 0x0bc LegoNamedPlane m_skateboardPlane; // 0x0bc
LegoNamedPlane m_helicopterPlane; // 0x108 LegoNamedPlane m_helicopterPlane; // 0x108
LegoNamedTexture* m_unk0x154; // 0x154 LegoNamedTexture* m_helicopterWindshield; // 0x154
LegoNamedTexture* m_unk0x158; // 0x158 LegoNamedTexture* m_helicopterJetLeft; // 0x158
LegoNamedTexture* m_unk0x15c; // 0x15c LegoNamedTexture* m_helicopterJetRight; // 0x15c
Helicopter* m_helicopter; // 0x160 Helicopter* m_helicopter; // 0x160
LegoNamedPlane m_jetskiPlane; // 0x164 LegoNamedPlane m_jetskiPlane; // 0x164
LegoNamedTexture* m_unk0x1b0; // 0x1b0 LegoNamedTexture* m_jetskiFront; // 0x1b0
LegoNamedTexture* m_unk0x1b4; // 0x1b4 LegoNamedTexture* m_jetskiWindshield; // 0x1b4
Jetski* m_jetski; // 0x1b8 Jetski* m_jetski; // 0x1b8
LegoNamedPlane m_dunebuggyPlane; // 0x1bc LegoNamedPlane m_dunebuggyPlane; // 0x1bc
LegoNamedTexture* m_unk0x208; // 0x208 LegoNamedTexture* m_dunebuggyFront; // 0x208
DuneBuggy* m_dunebuggy; // 0x20c DuneBuggy* m_dunebuggy; // 0x20c
LegoNamedPlane m_racecarPlane; // 0x210 LegoNamedPlane m_racecarPlane; // 0x210
LegoNamedTexture* m_unk0x25c; // 0x25c LegoNamedTexture* m_racecarFront; // 0x25c
LegoNamedTexture* m_unk0x260; // 0x260 LegoNamedTexture* m_racecarBack; // 0x260
LegoNamedTexture* m_unk0x264; // 0x264 LegoNamedTexture* m_racecarTail; // 0x264
RaceCar* m_racecar; // 0x268 RaceCar* m_racecar; // 0x268
}; };

View file

@ -14,7 +14,7 @@ class LegoNamedPlane {
// FUNCTION: LEGO1 0x10033a70 // FUNCTION: LEGO1 0x10033a70
// LegoNamedPlane::~LegoNamedPlane // LegoNamedPlane::~LegoNamedPlane
const MxString* GetName() const { return &m_name; } const char* GetName() const { return m_name.GetData(); }
const Mx3DPointFloat& GetPosition() { return m_position; } const Mx3DPointFloat& GetPosition() { return m_position; }
const Mx3DPointFloat& GetDirection() { return m_direction; } const Mx3DPointFloat& GetDirection() { return m_direction; }
const Mx3DPointFloat& GetUp() { return m_up; } const Mx3DPointFloat& GetUp() { return m_up; }
@ -24,6 +24,9 @@ class LegoNamedPlane {
void SetDirection(const Mx3DPointFloat& p_direction) { m_direction = p_direction; } void SetDirection(const Mx3DPointFloat& p_direction) { m_direction = p_direction; }
void SetUp(const Mx3DPointFloat& p_up) { m_up = p_up; } void SetUp(const Mx3DPointFloat& p_up) { m_up = p_up; }
MxBool IsPresent() { return strcmp(m_name.GetData(), "") != 0; }
void Reset() { m_name = ""; }
// FUNCTION: LEGO1 0x100344d0 // FUNCTION: LEGO1 0x100344d0
MxResult Serialize(LegoFile* p_file) MxResult Serialize(LegoFile* p_file)
{ {

View file

@ -73,6 +73,7 @@ class LegoState : public MxCore {
return SUCCESS; return SUCCESS;
} }
private:
MxU32* m_objectIds; // 0x00 MxU32* m_objectIds; // 0x00
MxS16 m_length; // 0x04 MxS16 m_length; // 0x04
MxS16 m_mode; // 0x06 MxS16 m_mode; // 0x06

View file

@ -1048,7 +1048,6 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
entity = (LegoEntity*) Find(m_atomId, m_carId); entity = (LegoEntity*) Find(m_atomId, m_carId);
if (entity && entity->GetROI()) { if (entity && entity->GetROI()) {
// This function was changed between BETA10 and LEGO1. // This function was changed between BETA10 and LEGO1.
// These lines looks like a relic from older code. // These lines looks like a relic from older code.
LegoWorld* destWorld = NULL; LegoWorld* destWorld = NULL;
@ -1063,7 +1062,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
} }
gameState->m_helicopter = (Helicopter*) entity; gameState->m_helicopter = (Helicopter*) entity;
gameState->m_helicopterPlane.SetName(""); gameState->m_helicopterPlane.Reset();
break; break;
case LegoGameState::e_dunecarbuild: case LegoGameState::e_dunecarbuild:
if (gameState->m_dunebuggy) { if (gameState->m_dunebuggy) {
@ -1071,7 +1070,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
} }
gameState->m_dunebuggy = (DuneBuggy*) entity; gameState->m_dunebuggy = (DuneBuggy*) entity;
gameState->m_dunebuggyPlane.SetName(""); gameState->m_dunebuggyPlane.Reset();
break; break;
case LegoGameState::e_jetskibuild: case LegoGameState::e_jetskibuild:
if (gameState->m_jetski) { if (gameState->m_jetski) {
@ -1079,7 +1078,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
} }
gameState->m_jetski = (Jetski*) entity; gameState->m_jetski = (Jetski*) entity;
gameState->m_jetskiPlane.SetName(""); gameState->m_jetskiPlane.Reset();
break; break;
case LegoGameState::e_racecarbuild: case LegoGameState::e_racecarbuild:
if (gameState->m_racecar) { if (gameState->m_racecar) {
@ -1087,7 +1086,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
} }
gameState->m_racecar = (RaceCar*) entity; gameState->m_racecar = (RaceCar*) entity;
gameState->m_racecarPlane.SetName(""); gameState->m_racecarPlane.Reset();
break; break;
} }

View file

@ -732,9 +732,9 @@ void LegoPathActor::UpdatePlane(LegoNamedPlane& p_namedPlane)
// FUNCTION: LEGO1 0x1002f830 // FUNCTION: LEGO1 0x1002f830
void LegoPathActor::PlaceActor(LegoNamedPlane& p_namedPlane) void LegoPathActor::PlaceActor(LegoNamedPlane& p_namedPlane)
{ {
if (strcmp(p_namedPlane.GetName()->GetData(), "") != 0) { if (p_namedPlane.IsPresent()) {
LegoWorld* world = CurrentWorld(); LegoWorld* world = CurrentWorld();
world->PlaceActor(this, p_namedPlane.GetName()->GetData(), 0, 0.5f, 1, 0.5f); world->PlaceActor(this, p_namedPlane.GetName(), 0, 0.5f, 1, 0.5f);
SetLocation(p_namedPlane.GetPosition(), p_namedPlane.GetDirection(), p_namedPlane.GetUp(), TRUE); SetLocation(p_namedPlane.GetPosition(), p_namedPlane.GetDirection(), p_namedPlane.GetUp(), TRUE);
} }
} }

View file

@ -1293,19 +1293,19 @@ Act1State::Act1State()
m_planeActive = FALSE; m_planeActive = FALSE;
m_currentCptClickDialogue = IsleScript::c_noneIsle; m_currentCptClickDialogue = IsleScript::c_noneIsle;
m_unk0x022 = FALSE; m_unk0x022 = FALSE;
m_unk0x154 = NULL; m_helicopterWindshield = NULL;
m_unk0x158 = NULL; m_helicopterJetLeft = NULL;
m_unk0x15c = NULL; m_helicopterJetRight = NULL;
m_helicopter = NULL; m_helicopter = NULL;
m_unk0x1b0 = NULL; m_jetskiFront = NULL;
m_unk0x021 = 1; m_unk0x021 = 1;
m_unk0x1b4 = NULL; m_jetskiWindshield = NULL;
m_jetski = NULL; m_jetski = NULL;
m_unk0x208 = NULL; m_dunebuggyFront = NULL;
m_dunebuggy = NULL; m_dunebuggy = NULL;
m_unk0x25c = NULL; m_racecarFront = NULL;
m_unk0x260 = NULL; m_racecarBack = NULL;
m_unk0x264 = NULL; m_racecarTail = NULL;
m_racecar = NULL; m_racecar = NULL;
Reset(); Reset();
} }
@ -1325,124 +1325,135 @@ MxResult Act1State::Serialize(LegoFile* p_file)
m_racecarPlane.Serialize(p_file); m_racecarPlane.Serialize(p_file);
if (p_file->IsWriteMode()) { if (p_file->IsWriteMode()) {
if (m_helicopterPlane.GetName()->Compare("") != 0) { if (m_helicopterPlane.IsPresent()) {
if (m_unk0x154) { if (m_helicopterWindshield) {
WriteNamedTexture(p_file, m_unk0x154); WriteNamedTexture(p_file, m_helicopterWindshield);
} }
else { else {
FUN_1003f540(p_file, "chwind.gif"); FUN_1003f540(p_file, "chwind.gif");
} }
if (m_unk0x158) {
WriteNamedTexture(p_file, m_unk0x158); if (m_helicopterJetLeft) {
WriteNamedTexture(p_file, m_helicopterJetLeft);
} }
else { else {
FUN_1003f540(p_file, "chjetl.gif"); FUN_1003f540(p_file, "chjetl.gif");
} }
if (m_unk0x15c) {
WriteNamedTexture(p_file, m_unk0x15c); if (m_helicopterJetRight) {
WriteNamedTexture(p_file, m_helicopterJetRight);
} }
else { else {
FUN_1003f540(p_file, "chjetr.gif"); FUN_1003f540(p_file, "chjetr.gif");
} }
} }
if (m_jetskiPlane.GetName()->Compare("") != 0) {
if (m_unk0x1b0) { if (m_jetskiPlane.IsPresent()) {
WriteNamedTexture(p_file, m_unk0x1b0); if (m_jetskiFront) {
WriteNamedTexture(p_file, m_jetskiFront);
} }
else { else {
FUN_1003f540(p_file, "jsfrnt.gif"); FUN_1003f540(p_file, "jsfrnt.gif");
} }
if (m_unk0x1b4) {
WriteNamedTexture(p_file, m_unk0x1b4); if (m_jetskiWindshield) {
WriteNamedTexture(p_file, m_jetskiWindshield);
} }
else { else {
FUN_1003f540(p_file, "jswnsh.gif"); FUN_1003f540(p_file, "jswnsh.gif");
} }
} }
if (m_dunebuggyPlane.GetName()->Compare("") != 0) {
if (m_unk0x208) { if (m_dunebuggyPlane.IsPresent()) {
WriteNamedTexture(p_file, m_unk0x208); if (m_dunebuggyFront) {
WriteNamedTexture(p_file, m_dunebuggyFront);
} }
else { else {
FUN_1003f540(p_file, "dbfrfn.gif"); FUN_1003f540(p_file, "dbfrfn.gif");
} }
} }
if (m_racecarPlane.GetName()->Compare("") != 0) {
if (m_unk0x25c) { if (m_racecarPlane.IsPresent()) {
WriteNamedTexture(p_file, m_unk0x25c); if (m_racecarFront) {
WriteNamedTexture(p_file, m_racecarFront);
} }
else { else {
FUN_1003f540(p_file, "rcfrnt.gif"); FUN_1003f540(p_file, "rcfrnt.gif");
} }
if (m_unk0x260) {
WriteNamedTexture(p_file, m_unk0x260); if (m_racecarBack) {
WriteNamedTexture(p_file, m_racecarBack);
} }
else { else {
FUN_1003f540(p_file, "rcback.gif"); FUN_1003f540(p_file, "rcback.gif");
} }
if (m_unk0x264) {
WriteNamedTexture(p_file, m_unk0x264); if (m_racecarTail) {
WriteNamedTexture(p_file, m_racecarTail);
} }
else { else {
FUN_1003f540(p_file, "rctail.gif"); FUN_1003f540(p_file, "rctail.gif");
} }
} }
Write(p_file, m_cptClickDialogue.m_nextIndex); m_cptClickDialogue.WriteToFile(p_file);
Write(p_file, m_unk0x022); Write(p_file, m_unk0x022);
} }
else if (p_file->IsReadMode()) { else if (p_file->IsReadMode()) {
if (m_helicopterPlane.GetName()->Compare("") != 0) { if (m_helicopterPlane.IsPresent()) {
m_unk0x154 = ReadNamedTexture(p_file); m_helicopterWindshield = ReadNamedTexture(p_file);
if (m_unk0x154 == NULL) { if (m_helicopterWindshield == NULL) {
return FAILURE; return FAILURE;
} }
m_unk0x158 = ReadNamedTexture(p_file); m_helicopterJetLeft = ReadNamedTexture(p_file);
if (m_unk0x158 == NULL) { if (m_helicopterJetLeft == NULL) {
return FAILURE; return FAILURE;
} }
m_unk0x15c = ReadNamedTexture(p_file); m_helicopterJetRight = ReadNamedTexture(p_file);
if (m_unk0x15c == NULL) { if (m_helicopterJetRight == NULL) {
return FAILURE;
}
}
if (m_jetskiPlane.GetName()->Compare("") != 0) {
m_unk0x1b0 = ReadNamedTexture(p_file);
if (m_unk0x1b0 == NULL) {
return FAILURE;
}
m_unk0x1b4 = ReadNamedTexture(p_file);
if (m_unk0x1b4 == NULL) {
return FAILURE;
}
}
if (m_dunebuggyPlane.GetName()->Compare("") != 0) {
m_unk0x208 = ReadNamedTexture(p_file);
if (m_unk0x208 == NULL) {
return FAILURE;
}
}
if (m_racecarPlane.GetName()->Compare("") != 0) {
m_unk0x25c = ReadNamedTexture(p_file);
if (m_unk0x25c == NULL) {
return FAILURE;
}
m_unk0x260 = ReadNamedTexture(p_file);
if (m_unk0x260 == NULL) {
return FAILURE;
}
m_unk0x264 = ReadNamedTexture(p_file);
if (m_unk0x264 == NULL) {
return FAILURE; return FAILURE;
} }
} }
Read(p_file, &m_cptClickDialogue.m_nextIndex); if (m_jetskiPlane.IsPresent()) {
m_jetskiFront = ReadNamedTexture(p_file);
if (m_jetskiFront == NULL) {
return FAILURE;
}
m_jetskiWindshield = ReadNamedTexture(p_file);
if (m_jetskiWindshield == NULL) {
return FAILURE;
}
}
if (m_dunebuggyPlane.IsPresent()) {
m_dunebuggyFront = ReadNamedTexture(p_file);
if (m_dunebuggyFront == NULL) {
return FAILURE;
}
}
if (m_racecarPlane.IsPresent()) {
m_racecarFront = ReadNamedTexture(p_file);
if (m_racecarFront == NULL) {
return FAILURE;
}
m_racecarBack = ReadNamedTexture(p_file);
if (m_racecarBack == NULL) {
return FAILURE;
}
m_racecarTail = ReadNamedTexture(p_file);
if (m_racecarTail == NULL) {
return FAILURE;
}
}
m_cptClickDialogue.ReadFromFile(p_file);
Read(p_file, &m_unk0x022); Read(p_file, &m_unk0x022);
} }
@ -1474,25 +1485,25 @@ void Act1State::StopCptClickDialogue()
// FUNCTION: LEGO1 0x100346d0 // FUNCTION: LEGO1 0x100346d0
MxBool Act1State::Reset() MxBool Act1State::Reset()
{ {
m_motocyclePlane.SetName(""); m_motocyclePlane.Reset();
m_bikePlane.SetName(""); m_bikePlane.Reset();
m_skateboardPlane.SetName(""); m_skateboardPlane.Reset();
m_unk0x022 = FALSE; m_unk0x022 = FALSE;
m_helicopterPlane.SetName("");
if (m_unk0x154) { m_helicopterPlane.Reset();
delete m_unk0x154; if (m_helicopterWindshield) {
m_unk0x154 = NULL; delete m_helicopterWindshield;
m_helicopterWindshield = NULL;
} }
if (m_unk0x158) { if (m_helicopterJetLeft) {
delete m_unk0x158; delete m_helicopterJetLeft;
m_unk0x158 = NULL; m_helicopterJetLeft = NULL;
} }
if (m_unk0x15c) { if (m_helicopterJetRight) {
delete m_unk0x15c; delete m_helicopterJetRight;
m_unk0x15c = NULL; m_helicopterJetRight = NULL;
} }
if (m_helicopter) { if (m_helicopter) {
@ -1500,16 +1511,15 @@ MxBool Act1State::Reset()
m_helicopter = NULL; m_helicopter = NULL;
} }
m_jetskiPlane.SetName(""); m_jetskiPlane.Reset();
if (m_jetskiFront) {
if (m_unk0x1b0) { delete m_jetskiFront;
delete m_unk0x1b0; m_jetskiFront = NULL;
m_unk0x1b0 = NULL;
} }
if (m_unk0x1b4) { if (m_jetskiWindshield) {
delete m_unk0x1b4; delete m_jetskiWindshield;
m_unk0x1b4 = NULL; m_jetskiWindshield = NULL;
} }
if (m_jetski) { if (m_jetski) {
@ -1517,11 +1527,10 @@ MxBool Act1State::Reset()
m_jetski = NULL; m_jetski = NULL;
} }
m_dunebuggyPlane.SetName(""); m_dunebuggyPlane.Reset();
if (m_dunebuggyFront) {
if (m_unk0x208) { delete m_dunebuggyFront;
delete m_unk0x208; m_dunebuggyFront = NULL;
m_unk0x208 = NULL;
} }
if (m_dunebuggy) { if (m_dunebuggy) {
@ -1529,21 +1538,20 @@ MxBool Act1State::Reset()
m_dunebuggy = NULL; m_dunebuggy = NULL;
} }
m_racecarPlane.SetName(""); m_racecarPlane.Reset();
if (m_racecarFront) {
if (m_unk0x25c) { delete m_racecarFront;
delete m_unk0x25c; m_racecarFront = NULL;
m_unk0x25c = NULL;
} }
if (m_unk0x260) { if (m_racecarBack) {
delete m_unk0x260; delete m_racecarBack;
m_unk0x260 = NULL; m_racecarBack = NULL;
} }
if (m_unk0x264) { if (m_racecarTail) {
delete m_unk0x264; delete m_racecarTail;
m_unk0x264 = NULL; m_racecarTail = NULL;
} }
if (m_racecar) { if (m_racecar) {
@ -1605,21 +1613,21 @@ void Act1State::PlaceActors()
{ {
Isle* isle = (Isle*) FindWorld(*g_isleScript, IsleScript::c__Isle); Isle* isle = (Isle*) FindWorld(*g_isleScript, IsleScript::c__Isle);
if (strcmp(m_motocyclePlane.GetName()->GetData(), "") != 0) { if (m_motocyclePlane.IsPresent()) {
isle->m_motocycle->PlaceActor(m_motocyclePlane); isle->m_motocycle->PlaceActor(m_motocyclePlane);
} }
else { else {
isle->PlaceActor(isle->m_motocycle, "INT43", 4, 0.5f, 1, 0.5f); isle->PlaceActor(isle->m_motocycle, "INT43", 4, 0.5f, 1, 0.5f);
} }
if (strcmp(m_bikePlane.GetName()->GetData(), "") != 0) { if (m_bikePlane.IsPresent()) {
isle->m_bike->PlaceActor(m_bikePlane); isle->m_bike->PlaceActor(m_bikePlane);
} }
else { else {
isle->PlaceActor(isle->m_bike, "INT44", 2, 0.5f, 0, 0.5f); isle->PlaceActor(isle->m_bike, "INT44", 2, 0.5f, 0, 0.5f);
} }
if (strcmp(m_skateboardPlane.GetName()->GetData(), "") != 0) { if (m_skateboardPlane.IsPresent()) {
isle->m_skateboard->PlaceActor(m_skateboardPlane); isle->m_skateboard->PlaceActor(m_skateboardPlane);
} }
else { else {
@ -1627,11 +1635,11 @@ void Act1State::PlaceActors()
} }
if (m_helicopter != NULL) { if (m_helicopter != NULL) {
if (!strcmp(m_helicopterPlane.GetName()->GetData(), "")) { if (!m_helicopterPlane.IsPresent()) {
m_helicopter->SpawnPlayer(LegoGameState::e_unk40, FALSE, 0); m_helicopter->SpawnPlayer(LegoGameState::e_unk40, FALSE, 0);
} }
else { else {
isle->PlaceActor(m_helicopter, m_helicopterPlane.GetName()->GetData(), 0, 0.5f, 1, 0.5f); isle->PlaceActor(m_helicopter, m_helicopterPlane.GetName(), 0, 0.5f, 1, 0.5f);
m_helicopter->SetLocation( m_helicopter->SetLocation(
m_helicopterPlane.GetPosition(), m_helicopterPlane.GetPosition(),
m_helicopterPlane.GetDirection(), m_helicopterPlane.GetDirection(),
@ -1644,34 +1652,34 @@ void Act1State::PlaceActors()
GetViewManager()->Add(m_helicopter->GetROI()); GetViewManager()->Add(m_helicopter->GetROI());
m_helicopter->GetROI()->SetVisibility(TRUE); m_helicopter->GetROI()->SetVisibility(TRUE);
m_helicopterPlane.SetName(""); m_helicopterPlane.Reset();
m_helicopter = NULL; m_helicopter = NULL;
if (m_unk0x154 != NULL) { if (m_helicopterWindshield != NULL) {
FUN_1003f930(m_unk0x154); FUN_1003f930(m_helicopterWindshield);
delete m_unk0x154; delete m_helicopterWindshield;
m_unk0x154 = NULL; m_helicopterWindshield = NULL;
} }
if (m_unk0x158 != NULL) { if (m_helicopterJetLeft != NULL) {
FUN_1003f930(m_unk0x158); FUN_1003f930(m_helicopterJetLeft);
delete m_unk0x158; delete m_helicopterJetLeft;
m_unk0x158 = NULL; m_helicopterJetLeft = NULL;
} }
if (m_unk0x15c != NULL) { if (m_helicopterJetRight != NULL) {
FUN_1003f930(m_unk0x15c); FUN_1003f930(m_helicopterJetRight);
delete m_unk0x15c; delete m_helicopterJetRight;
m_unk0x15c = NULL; m_helicopterJetRight = NULL;
} }
} }
if (m_jetski != NULL) { if (m_jetski != NULL) {
if (!strcmp(m_jetskiPlane.GetName()->GetData(), "")) { if (!m_jetskiPlane.IsPresent()) {
m_jetski->SpawnPlayer(LegoGameState::e_unk45, FALSE, 0); m_jetski->SpawnPlayer(LegoGameState::e_unk45, FALSE, 0);
} }
else { else {
isle->PlaceActor(m_jetski, m_jetskiPlane.GetName()->GetData(), 0, 0.5f, 1, 0.5f); isle->PlaceActor(m_jetski, m_jetskiPlane.GetName(), 0, 0.5f, 1, 0.5f);
m_jetski m_jetski
->SetLocation(m_jetskiPlane.GetPosition(), m_jetskiPlane.GetDirection(), m_jetskiPlane.GetUp(), TRUE); ->SetLocation(m_jetskiPlane.GetPosition(), m_jetskiPlane.GetDirection(), m_jetskiPlane.GetUp(), TRUE);
isle->Add(m_jetski); isle->Add(m_jetski);
@ -1680,28 +1688,28 @@ void Act1State::PlaceActors()
GetViewManager()->Add(m_jetski->GetROI()); GetViewManager()->Add(m_jetski->GetROI());
m_jetski->GetROI()->SetVisibility(TRUE); m_jetski->GetROI()->SetVisibility(TRUE);
m_jetskiPlane.SetName(""); m_jetskiPlane.Reset();
m_jetski = NULL; m_jetski = NULL;
if (m_unk0x1b0 != NULL) { if (m_jetskiFront != NULL) {
FUN_1003f930(m_unk0x1b0); FUN_1003f930(m_jetskiFront);
delete m_unk0x1b0; delete m_jetskiFront;
m_unk0x1b0 = NULL; m_jetskiFront = NULL;
} }
if (m_unk0x1b4 != NULL) { if (m_jetskiWindshield != NULL) {
FUN_1003f930(m_unk0x1b4); FUN_1003f930(m_jetskiWindshield);
delete m_unk0x1b4; delete m_jetskiWindshield;
m_unk0x1b4 = NULL; m_jetskiWindshield = NULL;
} }
} }
if (m_dunebuggy != NULL) { if (m_dunebuggy != NULL) {
if (!strcmp(m_dunebuggyPlane.GetName()->GetData(), "")) { if (!m_dunebuggyPlane.IsPresent()) {
m_dunebuggy->SpawnPlayer(LegoGameState::e_unk43, FALSE, 0); m_dunebuggy->SpawnPlayer(LegoGameState::e_unk43, FALSE, 0);
} }
else { else {
isle->PlaceActor(m_dunebuggy, m_dunebuggyPlane.GetName()->GetData(), 0, 0.5f, 1, 0.5f); isle->PlaceActor(m_dunebuggy, m_dunebuggyPlane.GetName(), 0, 0.5f, 1, 0.5f);
m_dunebuggy->SetLocation( m_dunebuggy->SetLocation(
m_dunebuggyPlane.GetPosition(), m_dunebuggyPlane.GetPosition(),
m_dunebuggyPlane.GetDirection(), m_dunebuggyPlane.GetDirection(),
@ -1714,22 +1722,22 @@ void Act1State::PlaceActors()
GetViewManager()->Add(m_dunebuggy->GetROI()); GetViewManager()->Add(m_dunebuggy->GetROI());
m_dunebuggy->GetROI()->SetVisibility(TRUE); m_dunebuggy->GetROI()->SetVisibility(TRUE);
m_dunebuggyPlane.SetName(""); m_dunebuggyPlane.Reset();
m_dunebuggy = NULL; m_dunebuggy = NULL;
if (m_unk0x208 != NULL) { if (m_dunebuggyFront != NULL) {
FUN_1003f930(m_unk0x208); FUN_1003f930(m_dunebuggyFront);
delete m_unk0x208; delete m_dunebuggyFront;
m_unk0x208 = NULL; m_dunebuggyFront = NULL;
} }
} }
if (m_racecar != NULL) { if (m_racecar != NULL) {
if (!strcmp(m_racecarPlane.GetName()->GetData(), "")) { if (!m_racecarPlane.IsPresent()) {
m_racecar->SpawnPlayer(LegoGameState::e_unk44, FALSE, 0); m_racecar->SpawnPlayer(LegoGameState::e_unk44, FALSE, 0);
} }
else { else {
isle->PlaceActor(m_racecar, m_racecarPlane.GetName()->GetData(), 0, 0.5f, 1, 0.5f); isle->PlaceActor(m_racecar, m_racecarPlane.GetName(), 0, 0.5f, 1, 0.5f);
m_racecar->SetLocation( m_racecar->SetLocation(
m_racecarPlane.GetPosition(), m_racecarPlane.GetPosition(),
m_racecarPlane.GetDirection(), m_racecarPlane.GetDirection(),
@ -1742,25 +1750,25 @@ void Act1State::PlaceActors()
GetViewManager()->Add(m_racecar->GetROI()); GetViewManager()->Add(m_racecar->GetROI());
m_racecar->GetROI()->SetVisibility(TRUE); m_racecar->GetROI()->SetVisibility(TRUE);
m_racecarPlane.SetName(""); m_racecarPlane.Reset();
m_racecar = NULL; m_racecar = NULL;
if (m_unk0x25c != NULL) { if (m_racecarFront != NULL) {
FUN_1003f930(m_unk0x25c); FUN_1003f930(m_racecarFront);
delete m_unk0x25c; delete m_racecarFront;
m_unk0x25c = NULL; m_racecarFront = NULL;
} }
if (m_unk0x260 != NULL) { if (m_racecarBack != NULL) {
FUN_1003f930(m_unk0x260); FUN_1003f930(m_racecarBack);
delete m_unk0x260; delete m_racecarBack;
m_unk0x260 = NULL; m_racecarBack = NULL;
} }
if (m_unk0x264 != NULL) { if (m_racecarTail != NULL) {
FUN_1003f930(m_unk0x264); FUN_1003f930(m_racecarTail);
delete m_unk0x264; delete m_racecarTail;
m_unk0x264 = NULL; m_racecarTail = NULL;
} }
} }
} }

View file

@ -337,7 +337,7 @@ void RegistrationBook::FUN_100778c0()
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) { if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
Act1State* act1state = (Act1State*) GameState()->GetState("Act1State"); Act1State* act1state = (Act1State*) GameState()->GetState("Act1State");
if (strcmp(act1state->m_helicopterPlane.GetName()->GetData(), "") != 0) { if (act1state->m_helicopterPlane.IsPresent()) {
InvokeAction(Extra::e_start, m_atomId, CopterScript::c_Helicopter_Actor, NULL); InvokeAction(Extra::e_start, m_atomId, CopterScript::c_Helicopter_Actor, NULL);
NotificationManager()->Send( NotificationManager()->Send(
this, this,
@ -347,7 +347,7 @@ void RegistrationBook::FUN_100778c0()
m_unk0x2b8++; m_unk0x2b8++;
} }
if (strcmp(act1state->m_jetskiPlane.GetName()->GetData(), "") != 0) { if (act1state->m_jetskiPlane.IsPresent()) {
InvokeAction(Extra::e_start, m_atomId, JetskiScript::c_Jetski_Actor, NULL); InvokeAction(Extra::e_start, m_atomId, JetskiScript::c_Jetski_Actor, NULL);
NotificationManager()->Send( NotificationManager()->Send(
this, this,
@ -357,7 +357,7 @@ void RegistrationBook::FUN_100778c0()
m_unk0x2b8++; m_unk0x2b8++;
} }
if (strcmp(act1state->m_dunebuggyPlane.GetName()->GetData(), "") != 0) { if (act1state->m_dunebuggyPlane.IsPresent()) {
InvokeAction(Extra::e_start, m_atomId, DunecarScript::c_DuneBugy_Actor, NULL); InvokeAction(Extra::e_start, m_atomId, DunecarScript::c_DuneBugy_Actor, NULL);
NotificationManager()->Send( NotificationManager()->Send(
this, this,
@ -367,7 +367,7 @@ void RegistrationBook::FUN_100778c0()
m_unk0x2b8++; m_unk0x2b8++;
} }
if (strcmp(act1state->m_racecarPlane.GetName()->GetData(), "") != 0) { if (act1state->m_racecarPlane.IsPresent()) {
InvokeAction(Extra::e_start, m_atomId, RacecarScript::c_RaceCar_Actor, NULL); InvokeAction(Extra::e_start, m_atomId, RacecarScript::c_RaceCar_Actor, NULL);
NotificationManager()->Send( NotificationManager()->Send(
this, this,

View file

@ -91,6 +91,7 @@ class LegoFile : public LegoStorage {
public: public:
LegoFile(); LegoFile();
~LegoFile() override; ~LegoFile() override;
LegoResult Read(void* p_buffer, LegoU32 p_size) override; // vtable+0x04 LegoResult Read(void* p_buffer, LegoU32 p_size) override; // vtable+0x04
LegoResult Write(const void* p_buffer, LegoU32 p_size) override; // vtable+0x08 LegoResult Write(const void* p_buffer, LegoU32 p_size) override; // vtable+0x08
LegoResult GetPosition(LegoU32& p_position) override; // vtable+0x0c LegoResult GetPosition(LegoU32& p_position) override; // vtable+0x0c
@ -100,23 +101,18 @@ class LegoFile : public LegoStorage {
// FUNCTION: LEGO1 0x100343d0 // FUNCTION: LEGO1 0x100343d0
LegoStorage* WriteVector3(Mx3DPointFloat p_vec3) LegoStorage* WriteVector3(Mx3DPointFloat p_vec3)
{ {
float data = p_vec3[0]; ::Write(this, p_vec3[0]);
Write(&data, sizeof(float)); ::Write(this, p_vec3[1]);
::Write(this, p_vec3[2]);
data = p_vec3[1];
Write(&data, sizeof(float));
data = p_vec3[2];
Write(&data, sizeof(float));
return this; return this;
} }
// FUNCTION: LEGO1 0x10034430 // FUNCTION: LEGO1 0x10034430
LegoStorage* ReadVector3(Mx3DPointFloat& p_vec3) LegoStorage* ReadVector3(Mx3DPointFloat& p_vec3)
{ {
Read(&p_vec3[0], sizeof(float)); ::Read(this, &p_vec3[0]);
Read(&p_vec3[1], sizeof(float)); ::Read(this, &p_vec3[1]);
Read(&p_vec3[2], sizeof(float)); ::Read(this, &p_vec3[2]);
return this; return this;
} }