Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from isledecomp/isle #48

Merged
merged 10 commits into from
Dec 27, 2024
5 changes: 0 additions & 5 deletions LEGO1/lego/legoomni/include/helicopter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,9 @@ class HelicopterState : public LegoState {
return TRUE;
} // vtable+0x18

void SetUnknown8(MxU32 p_unk0x08) { m_unk0x08 = p_unk0x08; }
MxU32 GetUnkown8() { return m_unk0x08; }

// SYNTHETIC: LEGO1 0x1000e190
// HelicopterState::`scalar deleting destructor'

// TODO: Most likely getters/setters are not used according to BETA.

MxU32 m_unk0x08; // 0x08
};

Expand Down
13 changes: 12 additions & 1 deletion LEGO1/lego/legoomni/include/legonamedpart.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ class LegoNamedPart {
m_name = p_name;
m_list = p_list;
}
~LegoNamedPart() { delete m_list; }
~LegoNamedPart()
{
LegoLODListCursor cursor(m_list);
LegoLOD* lod;

while (cursor.First(lod)) {
cursor.Detach();
delete lod;
}

delete m_list;
}

const MxString* GetName() const { return &m_name; }
LegoLODList* GetList() { return m_list; }
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/include/legoworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class LegoWorld : public LegoEntity {
MxCore* Find(const MxAtomId& p_atom, MxS32 p_entityId);

// FUNCTION: BETA10 0x1002b4f0
LegoCameraController* GetCamera() { return m_cameraController; }
LegoCameraController* GetCameraController() { return m_cameraController; }

LegoEntityList* GetEntityList() { return m_entityList; }
LegoOmni::World GetWorldId() { return m_worldId; }
Expand Down
2 changes: 2 additions & 0 deletions LEGO1/lego/legoomni/src/actors/act2actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ MxS32 Act2Actor::VTable0xa0()
{
undefined4 newLocation;

assert(!m_grec);

CurrentWorld();
MxU16 randomVal = rand() / (RAND_MAX / 2) + 1;

Expand Down
76 changes: 44 additions & 32 deletions LEGO1/lego/legoomni/src/actors/helicopter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DECOMP_SIZE_ASSERT(Matrix4, 0x08)
DECOMP_SIZE_ASSERT(MxMatrix, 0x48)

// FUNCTION: LEGO1 0x10001e60
// FUNCTION: BETA10 0x1002a0d0
Helicopter::Helicopter()
{
m_maxLinearVel = 60;
Expand All @@ -43,6 +44,7 @@ Helicopter::~Helicopter()
}

// FUNCTION: LEGO1 0x100032c0
// FUNCTION: BETA10 0x1002a16d
MxResult Helicopter::Create(MxDSAction& p_dsAction)
{
MxResult result = IslePathActor::Create(p_dsAction);
Expand All @@ -52,6 +54,8 @@ MxResult Helicopter::Create(MxDSAction& p_dsAction)
((Act3*) m_world)->SetHelicopter(this);
}

assert(m_world);

if (m_world != NULL) {
m_world->Add(this);
}
Expand All @@ -61,6 +65,7 @@ MxResult Helicopter::Create(MxDSAction& p_dsAction)
}

// FUNCTION: LEGO1 0x10003320
// FUNCTION: BETA10 0x1002a240
void Helicopter::CreateState()
{
m_state = (HelicopterState*) GameState()->GetState("HelicopterState");
Expand All @@ -70,8 +75,11 @@ void Helicopter::CreateState()
}

// FUNCTION: LEGO1 0x10003360
// FUNCTION: BETA10 0x1002a29a
void Helicopter::Exit()
{
assert(UserActor() == this);

if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
SpawnPlayer(
LegoGameState::e_unk40,
Expand All @@ -94,7 +102,7 @@ void Helicopter::Exit()
}
}

m_state->SetUnknown8(0);
m_state->m_unk0x08 = 0;
RemoveFromCurrentWorld(m_script, IsleScript::c_HelicopterDashboard_Bitmap);
RemoveFromCurrentWorld(m_script, IsleScript::c_HelicopterArms_Ctl);
RemoveFromCurrentWorld(m_script, IsleScript::c_Helicopter_TakeOff_Ctl);
Expand All @@ -110,6 +118,7 @@ void Helicopter::Exit()
}

// FUNCTION: LEGO1 0x10003480
// FUNCTION: BETA10 0x1002a3db
MxLong Helicopter::HandleClick()
{
if (!FUN_1003ef60()) {
Expand All @@ -118,6 +127,7 @@ MxLong Helicopter::HandleClick()

if (!m_world) {
m_world = CurrentWorld();
assert(m_world);
}

AnimationManager()->FUN_1005f6d0(FALSE);
Expand Down Expand Up @@ -163,6 +173,8 @@ MxLong Helicopter::HandleClick()
MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
{
MxLong result = 0;

assert(m_world);
MxAtomId script;

switch (GameState()->GetCurrentAct()) {
Expand Down Expand Up @@ -199,9 +211,10 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
break;
}

Act1State* state = (Act1State*) GameState()->GetState("Act1State");
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
assert(act1State);
if (m_state->m_unk0x08 == 0) {
state->m_unk0x018 = 4;
act1State->m_unk0x018 = 4;
m_state->m_unk0x08 = 1;
m_world->RemoveActor(this);
InvokeAction(Extra::ActionType::e_start, script, IsleScript::c_HelicopterTakeOff_Anim, NULL);
Expand Down Expand Up @@ -238,19 +251,19 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)

assert(m_pathController);

if (m_world && m_world->GetCamera()) {
if (m_world && m_world->GetCameraController()) {
Mx3DPointFloat location, direction, lookat;

location = m_world->GetCamera()->GetWorldLocation();
direction = m_world->GetCamera()->GetWorldDirection();
location = m_world->GetCameraController()->GetWorldLocation();
direction = m_world->GetCameraController()->GetWorldDirection();

lookat = direction;
lookat *= 3.0f;
location += lookat;

Mx3DPointFloat v68, va4, up;
Mx3DPointFloat v90(0, 1, 0);
v68 = m_world->GetCamera()->GetWorldUp();
v68 = m_world->GetCameraController()->GetWorldUp();
va4.EqualsCross(v68, direction);
up.EqualsCross(va4, v90);

Expand Down Expand Up @@ -295,14 +308,17 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
}

// FUNCTION: LEGO1 0x10003c20
// FUNCTION: BETA10 0x1002ab4c
MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
{
MxU32 ret = 0;
MxLong result = 0;

switch (m_state->GetUnkown8()) {
switch (m_state->m_unk0x08) {
case 1: {
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(4);
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
assert(act1State);
act1State->m_unk0x018 = 4;
SpawnPlayer(
LegoGameState::e_unk42,
TRUE,
Expand All @@ -317,25 +333,17 @@ MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
);
}

m_state->SetUnknown8(2);
m_state->m_unk0x08 = 2;

MxMatrix matrix;
matrix.SetIdentity();

float s = sin(0.5235987901687622); // PI / 6, 30 deg
float c = cos(0.5235987901687622); // PI / 6, 30 deg

float matrixCopy[4][4];
memcpy(matrixCopy, matrix.GetData(), sizeof(matrixCopy));
for (MxS32 i = 0; i < 4; i++) {
matrix.GetData()[i][1] = matrixCopy[i][1] * c - matrixCopy[i][2] * s;
matrix.GetData()[i][2] = matrixCopy[i][2] * c + matrixCopy[i][1] * s;
}

matrix.RotateX(0.5235987901687622); // PI / 6, 30 deg
Vector3 at(matrix[3]), dir(matrix[2]), up(matrix[1]);
m_world->GetCamera()->SetWorldTransform(at, dir, up);

assert(m_world && m_world->GetCameraController());
m_world->GetCameraController()->SetWorldTransform(at, dir, up);
FUN_10010c30();
ret = 1;
result = 1;
break;
}
case 3: {
Expand All @@ -344,10 +352,14 @@ MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)

Vector3 at(matrix[3]), dir(matrix[2]), up(matrix[1]);
at[1] = 1.25;
m_world->GetCamera()->SetWorldTransform(at, dir, up);

assert(m_world && m_world->GetCameraController());
m_world->GetCameraController()->SetWorldTransform(at, dir, up);

if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(0);
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
assert(act1State);
act1State->m_unk0x018 = 0;
SpawnPlayer(
LegoGameState::e_unk41,
TRUE,
Expand All @@ -362,13 +374,13 @@ MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
);
}

m_state->SetUnknown8(0);
ret = 1;
m_state->m_unk0x08 = 0;
result = 1;
break;
}
}

return ret;
return result;
}

// FUNCTION: LEGO1 0x10003e90
Expand Down Expand Up @@ -414,7 +426,7 @@ void Helicopter::Animate(float p_time)
v2 *= f2;
v2 += v1;

m_world->GetCamera()->FUN_100123e0(mat, 0);
m_world->GetCameraController()->FUN_100123e0(mat, 0);
}
else {
if (m_state->m_unk0x08 == 4) {
Expand All @@ -424,7 +436,7 @@ void Helicopter::Animate(float p_time)
((Act3*) m_world)->FUN_10073430();
}

LegoPathActor::m_actorState = c_disabled;
SetActorState(c_disabled);
}
}
else {
Expand All @@ -445,7 +457,7 @@ void Helicopter::FUN_100042a0(const Matrix4& p_matrix)
Vector3 vec5(m_unk0x1a8[2]); // EDI
Vector3 vec6(m_unk0x1a8[3]); // locala0 // esp+0x28

m_world->GetCamera()->FUN_100123b0(local48);
m_world->GetCameraController()->FUN_100123b0(local48);
m_unk0x1a8.SetIdentity();
local90 = p_matrix;

Expand Down
Loading
Loading