Implement/match LegoAct2::FUN_10052560() (#1174)

* Implement/match `LegoAct2::FUN_10052560()`

* Fix formatting

* Fix linter errors

* Address review comment

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
This commit is contained in:
jonschz 2024-11-29 21:04:50 +01:00 committed by GitHub
parent 7256eeb0ad
commit 29a0ae8f07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 109 additions and 19 deletions

View file

@ -67,11 +67,11 @@ class LegoAct2 : public LegoWorld {
void SetUnknown0x1150(undefined4 p_unk0x1150) { m_unk0x1150 = p_unk0x1150; }
undefined4 FUN_10052560(
undefined4 p_param1,
MxS32 p_param1,
MxBool p_param2,
MxBool p_param3,
Mx3DPointFloat* p_param4,
Mx3DPointFloat* p_param5,
Mx3DPointFloat* p_location,
Mx3DPointFloat* p_direction,
Mx3DPointFloat* p_param6
);
@ -89,7 +89,10 @@ class LegoAct2 : public LegoWorld {
undefined4 m_unk0x10c8; // 0x10c8
LegoAct2State* m_gameState; // 0x10cc
MxS32 m_unk0x10d0; // 0x10d0
char* m_unk0x10d4; // 0x10d4
// variable name verified by BETA10 0x10014633
char* m_siFile; // 0x10d4
LegoROI* m_unk0x10d8; // 0x10d8
MxMatrix m_unk0x10dc; // 0x10dc
undefined4 m_unk0x1124; // 0x1124

View file

@ -488,6 +488,7 @@ const char* LegoOmni::GetWorldName(MxU32 p_id)
}
// FUNCTION: LEGO1 0x1005b460
// FUNCTION: BETA10 0x1008edd8
MxAtomId* LegoOmni::GetWorldAtom(MxU32 p_id)
{
for (MxS32 i = 0; i < 19; i++) {
@ -496,6 +497,8 @@ MxAtomId* LegoOmni::GetWorldAtom(MxU32 p_id)
}
}
// A gem from BETA10
assert("Hey, check your code. We do not have this world." == NULL);
return NULL;
}

View file

@ -3,6 +3,7 @@
#include "act2actor.h"
#include "act2main_actions.h"
#include "actions/act2main_actions.h"
#include "actions/infomain_actions.h"
#include "islepathactor.h"
#include "legoanimationmanager.h"
#include "legogamestate.h"
@ -55,7 +56,7 @@ LegoAct2::LegoAct2()
m_unk0x1144 = 0;
m_unk0x1150 = 0;
m_unk0x10c8 = 0;
m_unk0x10d4 = "";
m_siFile = "";
m_unk0x113c = 5;
NotificationManager()->Register(this);
}
@ -299,17 +300,94 @@ MxBool LegoAct2::Escape()
return TRUE;
}
// STUB: LEGO1 0x10052560
// STUB: BETA10 0x100145c6
// FUNCTION: LEGO1 0x10052560
// FUNCTION: BETA10 0x100145c6
undefined4 LegoAct2::FUN_10052560(
undefined4 p_param1,
MxS32 p_param1,
MxBool p_param2,
MxBool p_param3,
Mx3DPointFloat* p_param4,
Mx3DPointFloat* p_param5,
Mx3DPointFloat* p_location,
Mx3DPointFloat* p_direction,
Mx3DPointFloat* p_param6
)
{
// TODO
if (m_unk0x1140 == 0 || p_param3) {
assert(strlen(m_siFile));
if (!p_param2) {
MxDSAction action;
action.SetObjectId(p_param1);
// not entirely sure about the constant
action.SetAtomId(*Lego()->GetWorldAtom(InfomainScript::c_Cop_Ctl));
if (p_location) {
action.SetUp(Mx3DPointFloat(0.0f, 1.0f, 0.0f));
action.SetLocation(*p_location);
}
if (p_direction) {
action.SetDirection(*p_direction);
}
StartActionIfUnknown0x13c(action);
}
else {
MxMatrix matrix;
matrix.SetIdentity();
MxBool oneVectorNotNull = FALSE;
if (p_location) {
matrix[3][0] = (*p_location)[0];
matrix[3][1] = (*p_location)[1];
matrix[3][2] = (*p_location)[2];
oneVectorNotNull = TRUE;
}
if (p_direction) {
matrix[2][0] = (*p_direction)[0];
matrix[2][1] = (*p_direction)[1];
matrix[2][2] = (*p_direction)[2];
oneVectorNotNull = TRUE;
}
if (p_param6) {
matrix[1][0] = (*p_param6)[0];
matrix[1][1] = (*p_param6)[1];
matrix[1][2] = (*p_param6)[2];
oneVectorNotNull = TRUE;
}
Vector3 firstColumn(matrix[0]);
Vector3 secondColumn(matrix[1]);
Vector3 thirdColumn(matrix[2]);
firstColumn.EqualsCross(&secondColumn, &thirdColumn);
firstColumn.Unitize();
MxMatrix* pmatrix = NULL;
if (oneVectorNotNull) {
pmatrix = &matrix;
}
MxResult result;
if (p_param1 == Act2mainScript::c_tja009ni_RunAnim) {
result = AnimationManager()->FUN_10060dc0(p_param1, pmatrix, TRUE, FALSE, NULL, TRUE, TRUE, TRUE, TRUE);
}
else {
result =
AnimationManager()->FUN_10060dc0(p_param1, pmatrix, TRUE, FALSE, NULL, TRUE, TRUE, TRUE, FALSE);
}
if (result == SUCCESS) {
m_unk0x1140 = p_param1;
}
}
}
return 0;
}

View file

@ -94,9 +94,15 @@ class MxDSAction : public MxDSObject {
// FUNCTION: BETA10 0x1003dbb0
Vector3& GetUp() { return m_up; }
// FUNCTION: BETA10 0x100153b0
void SetLocation(const Vector3& p_location) { m_location = p_location; }
// FUNCTION: BETA10 0x100153f0
void SetDirection(const Vector3& p_direction) { m_direction = p_direction; }
// FUNCTION: BETA10 0x10015430
void SetUp(const Vector3& p_up) { m_up = p_up; }
MxCore* GetUnknown84() { return m_unk0x84; }
void SetUnknown84(MxCore* p_unk0x84) { m_unk0x84 = p_unk0x84; }
MxCore* GetOrigin() { return m_origin; }