Refactor camera locations and other structs, name functions based on BETA (#900)

* Refactor camera locations and other structs, name functions based on BETA

* Add size assert

* Fix member name
This commit is contained in:
Christian Semmler 2024-05-10 10:23:47 -04:00 committed by GitHub
parent f5ffd3aba3
commit a1388adcd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1036 additions and 256 deletions

View file

@ -16,8 +16,12 @@ class LegoROIList;
struct ModelInfo;
class MxDSAction;
// SIZE 0x18
struct Character {
// VTABLE: LEGO1 0x100d8c18
// SIZE 0x500
class LegoAnimationManager : public MxCore {
public:
// SIZE 0x18
struct Character {
char* m_name; // 0x00
MxBool m_unk0x04; // 0x04
MxS8 m_vehicleId; // 0x05
@ -30,17 +34,17 @@ struct Character {
MxBool m_active; // 0x14
MxU8 m_unk0x15; // 0x15
MxU8 m_unk0x16; // 0x16
};
};
// SIZE 0x08
struct Vehicle {
// SIZE 0x08
struct Vehicle {
char* m_name; // 0x00
undefined m_unk0x04; // 0x04
MxBool m_unk0x05; // 0x05
};
};
// SIZE 0x18
struct Unknown0x3c {
// SIZE 0x18
struct Extra {
LegoROI* m_roi; // 0x00
MxS32 m_characterId; // 0x04
MxLong m_unk0x08; // 0x08
@ -48,12 +52,8 @@ struct Unknown0x3c {
MxBool m_unk0x0d; // 0x0d
float m_unk0x10; // 0x10
MxBool m_unk0x14; // 0x14
};
};
// VTABLE: LEGO1 0x100d8c18
// SIZE 0x500
class LegoAnimationManager : public MxCore {
public:
LegoAnimationManager();
~LegoAnimationManager() override;
@ -98,8 +98,8 @@ class LegoAnimationManager : public MxCore {
void FUN_10061010(MxBool p_und);
LegoTranInfo* GetTranInfo(MxU32 p_index);
void FUN_10062770();
void FUN_100627d0(MxBool p_und);
void FUN_100629b0(MxU32, MxBool);
void PurgeExtra(MxBool p_und);
void AddExtra(MxU32 p_cameraLocation, MxBool p_und);
void FUN_10063270(LegoROIList*, LegoAnimPresenter*);
void FUN_10063780(LegoROIList* p_list);
void FUN_10064670(Vector3*);
@ -162,7 +162,7 @@ class LegoAnimationManager : public MxCore {
MxBool m_unk0x38; // 0x38
MxBool m_unk0x39; // 0x39
MxBool m_unk0x3a; // 0x3a
Unknown0x3c m_unk0x3c[40]; // 0x3c
Extra m_extras[40]; // 0x3c
undefined4 m_unk0x3fc; // 0x3fc
MxBool m_unk0x400; // 0x400
MxBool m_unk0x401; // 0x401

View file

@ -6,23 +6,23 @@
// SIZE 0x60
struct LegoCameraLocation {
// SIZE 0x18
struct Path {
const char* m_name; // 0x00
MxS32 m_src; // 0x04
float m_srcScale; // 0x08
MxS32 m_dest; // 0x0c
float m_destScale; // 0x10
undefined4 m_unk0x10; // 0x14
};
MxU32 m_index; // 0x00
const char* m_name; // 0x04
float m_position[3]; // 0x08
float m_direction[3]; // 0x14
float m_up[3]; // 0x20
const char* m_edgeName; // 0x2c
undefined4 m_unk0x30; // 0x30
float m_unk0x34; // 0x34
undefined4 m_unk0x38; // 0x38
float m_unk0x3c; // 0x3c
undefined4 m_unk0x40; // 0x40
undefined4 m_unk0x44; // 0x44
undefined4 m_unk0x48; // 0x48
undefined4 m_unk0x4c; // 0x4c
undefined4 m_unk0x50; // 0x50
undefined4 m_unk0x54; // 0x54
undefined4 m_unk0x58; // 0x58
Path m_pathA; // 0x2c
Path m_pathB; // 0x44
undefined4 m_unk0x5c; // 0x5c
};

View file

@ -5,6 +5,7 @@
#include "mxcore.h"
#include "mxtypes.h"
struct LegoCameraLocation;
class Vector3;
//////////////////////////////////////////////////////////////////////////////
@ -73,6 +74,8 @@ class LegoNavController : public MxCore {
);
static MxResult UpdateCameraLocation(MxU32 p_location);
static MxResult UpdateCameraLocation(const char* p_location);
static LegoCameraLocation* GetCameraLocation(MxU32 p_location);
inline void SetLinearVel(MxFloat p_linearVel) { m_linearVel = p_linearVel; }
inline MxFloat GetLinearVel() { return m_linearVel; }
inline MxFloat GetRotationalVel() { return m_rotationalVel; }

View file

@ -26,16 +26,16 @@
#include <io.h>
DECOMP_SIZE_ASSERT(LegoAnimationManager, 0x500)
DECOMP_SIZE_ASSERT(Character, 0x18)
DECOMP_SIZE_ASSERT(Vehicle, 0x08)
DECOMP_SIZE_ASSERT(Unknown0x3c, 0x18)
DECOMP_SIZE_ASSERT(LegoAnimationManager::Character, 0x18)
DECOMP_SIZE_ASSERT(LegoAnimationManager::Vehicle, 0x08)
DECOMP_SIZE_ASSERT(LegoAnimationManager::Extra, 0x18)
DECOMP_SIZE_ASSERT(LegoTranInfo, 0x78)
// GLOBAL: LEGO1 0x100d8b28
MxU8 g_unk0x100d8b28[] = {0, 1, 2, 4, 8, 16};
// GLOBAL: LEGO1 0x100f6d20
Vehicle g_vehicles[] = {
LegoAnimationManager::Vehicle g_vehicles[] = {
{"bikebd", 0, FALSE},
{"bikepg", 0, FALSE},
{"bikerd", 0, FALSE},
@ -46,7 +46,7 @@ Vehicle g_vehicles[] = {
};
// GLOBAL: LEGO1 0x100f7048
Character g_characters[47] = {
LegoAnimationManager::Character g_characters[47] = {
{"pepper", FALSE, 6, 0, FALSE, FALSE, TRUE, 1500, 20000, FALSE, 50, 1},
{"mama", FALSE, -1, 0, FALSE, FALSE, FALSE, 1500, 20000, FALSE, 0, 2},
{"papa", FALSE, -1, 0, FALSE, FALSE, FALSE, 1500, 20000, FALSE, 0, 3},
@ -140,8 +140,8 @@ LegoAnimationManager::~LegoAnimationManager()
FUN_10061010(FALSE);
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
LegoROI* roi = m_unk0x3c[i].m_roi;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
LegoROI* roi = m_extras[i].m_roi;
if (roi != NULL) {
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
@ -226,8 +226,8 @@ void LegoAnimationManager::Suspend()
FUN_10061010(FALSE);
MxS32 i;
for (i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
LegoROI* roi = m_unk0x3c[i].m_roi;
for (i = 0; i < (MxS32) _countof(m_extras); i++) {
LegoROI* roi = m_extras[i].m_roi;
if (roi != NULL) {
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
@ -240,10 +240,10 @@ void LegoAnimationManager::Suspend()
CharacterManager()->FUN_10083db0(roi);
}
if (m_unk0x3c[i].m_unk0x14) {
m_unk0x3c[i].m_unk0x14 = FALSE;
if (m_extras[i].m_unk0x14) {
m_extras[i].m_unk0x14 = FALSE;
MxS32 vehicleId = g_characters[m_unk0x3c[i].m_characterId].m_vehicleId;
MxS32 vehicleId = g_characters[m_extras[i].m_characterId].m_vehicleId;
if (vehicleId >= 0) {
g_vehicles[vehicleId].m_unk0x05 = FALSE;
@ -254,9 +254,9 @@ void LegoAnimationManager::Suspend()
}
}
m_unk0x3c[i].m_roi = NULL;
m_unk0x3c[i].m_characterId = -1;
m_unk0x3c[i].m_unk0x10 = -1.0f;
m_extras[i].m_roi = NULL;
m_extras[i].m_characterId = -1;
m_extras[i].m_unk0x10 = -1.0f;
}
m_unk0x18 = 0;
@ -306,11 +306,11 @@ void LegoAnimationManager::Init()
m_unk0x30[i] = 0;
}
for (i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
m_unk0x3c[i].m_roi = NULL;
m_unk0x3c[i].m_characterId = -1;
m_unk0x3c[i].m_unk0x10 = -1.0f;
m_unk0x3c[i].m_unk0x14 = FALSE;
for (i = 0; i < (MxS32) _countof(m_extras); i++) {
m_extras[i].m_roi = NULL;
m_extras[i].m_characterId = -1;
m_extras[i].m_unk0x10 = -1.0f;
m_extras[i].m_unk0x14 = FALSE;
}
m_unk0x38 = FALSE;
@ -358,7 +358,7 @@ void LegoAnimationManager::FUN_1005f6d0(MxBool p_unk0x400)
m_unk0x400 = p_unk0x400;
if (!p_unk0x400) {
FUN_100627d0(TRUE);
PurgeExtra(TRUE);
}
}
}
@ -714,7 +714,7 @@ MxResult LegoAnimationManager::FUN_100605e0(
MxResult result = FAILURE;
if (m_scriptIndex != -1 && p_index < m_animCount && m_tranInfoList != NULL) {
FUN_100627d0(FALSE);
PurgeExtra(FALSE);
FUN_10062770();
MxDSAction action;
@ -800,7 +800,7 @@ MxResult LegoAnimationManager::FUN_100609f0(MxU32 p_objectId, MxMatrix* p_matrix
MxResult result = FAILURE;
MxDSAction action;
FUN_100627d0(FALSE);
PurgeExtra(FALSE);
LegoTranInfo* info = new LegoTranInfo();
info->m_animInfo = NULL;
@ -861,9 +861,9 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt
controller->FUN_10046770(actor);
actor->ClearController();
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
if (m_unk0x3c[i].m_roi == roi) {
MxS32 characterId = m_unk0x3c[i].m_characterId;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
if (m_extras[i].m_roi == roi) {
MxS32 characterId = m_extras[i].m_characterId;
g_characters[characterId].m_unk0x07 = TRUE;
MxS32 vehicleId = g_characters[characterId].m_vehicleId;
@ -1130,8 +1130,8 @@ MxLong LegoAnimationManager::Notify(MxParam& p_param)
cursor.Detach();
delete tranInfo;
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
LegoROI* roi = m_unk0x3c[i].m_roi;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
LegoROI* roi = m_extras[i].m_roi;
if (roi != NULL) {
LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName());
@ -1180,10 +1180,10 @@ MxResult LegoAnimationManager::Tickle()
}
if (m_unk0x401) {
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
LegoROI* roi = m_unk0x3c[i].m_roi;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
LegoROI* roi = m_extras[i].m_roi;
if (roi != NULL && m_unk0x3c[i].m_unk0x0d) {
if (roi != NULL && m_extras[i].m_unk0x0d) {
LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName());
if (actor != NULL && actor->GetController() != NULL) {
@ -1193,10 +1193,10 @@ MxResult LegoAnimationManager::Tickle()
CharacterManager()->FUN_10083db0(roi);
if (m_unk0x3c[i].m_unk0x14) {
m_unk0x3c[i].m_unk0x14 = FALSE;
if (m_extras[i].m_unk0x14) {
m_extras[i].m_unk0x14 = FALSE;
MxS32 vehicleId = g_characters[m_unk0x3c[i].m_characterId].m_vehicleId;
MxS32 vehicleId = g_characters[m_extras[i].m_characterId].m_vehicleId;
if (vehicleId >= 0) {
g_vehicles[vehicleId].m_unk0x05 = FALSE;
@ -1207,11 +1207,11 @@ MxResult LegoAnimationManager::Tickle()
}
}
m_unk0x3c[i].m_roi = NULL;
g_characters[m_unk0x3c[i].m_characterId].m_unk0x04 = FALSE;
g_characters[m_unk0x3c[i].m_characterId].m_unk0x07 = FALSE;
m_unk0x3c[i].m_characterId = -1;
m_unk0x3c[i].m_unk0x0d = FALSE;
m_extras[i].m_roi = NULL;
g_characters[m_extras[i].m_characterId].m_unk0x04 = FALSE;
g_characters[m_extras[i].m_characterId].m_unk0x07 = FALSE;
m_extras[i].m_characterId = -1;
m_extras[i].m_unk0x0d = FALSE;
m_unk0x414--;
}
}
@ -1237,11 +1237,11 @@ MxResult LegoAnimationManager::Tickle()
unk0x0c = g_unk0x100d8b28[actorId];
}
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
LegoROI* roi = m_unk0x3c[i].m_roi;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
LegoROI* roi = m_extras[i].m_roi;
if (roi != NULL) {
MxU16 result = FUN_10062110(roi, direction, position, boundary, speed, unk0x0c, m_unk0x3c[i].m_unk0x14);
MxU16 result = FUN_10062110(roi, direction, position, boundary, speed, unk0x0c, m_extras[i].m_unk0x14);
if (result) {
MxMatrix mat;
@ -1269,7 +1269,7 @@ MxResult LegoAnimationManager::Tickle()
m_unk0x408 = time;
if (time - m_unk0x404 > 10000) {
FUN_100629b0(-1, FALSE);
AddExtra(-1, FALSE);
}
double elapsedSeconds = VideoManager()->GetElapsedSeconds();
@ -1450,9 +1450,9 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info)
controller->FUN_10046770(actor);
actor->ClearController();
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
if (m_unk0x3c[i].m_roi == actor->GetROI()) {
MxS32 characterId = m_unk0x3c[i].m_characterId;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
if (m_extras[i].m_roi == actor->GetROI()) {
MxS32 characterId = m_extras[i].m_characterId;
g_characters[characterId].m_unk0x07 = TRUE;
MxS32 vehicleId = g_characters[characterId].m_vehicleId;
@ -1533,15 +1533,15 @@ void LegoAnimationManager::FUN_10062770()
// FUNCTION: LEGO1 0x100627d0
// FUNCTION: BETA10 0x1004389d
void LegoAnimationManager::FUN_100627d0(MxBool p_und)
void LegoAnimationManager::PurgeExtra(MxBool p_und)
{
ViewManager* viewManager = GetViewManager();
if (p_und || viewManager != NULL) {
MxLong time = Timer()->GetTime();
for (MxS32 i = 0; i < (MxS32) _countof(m_unk0x3c); i++) {
LegoROI* roi = m_unk0x3c[i].m_roi;
for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) {
LegoROI* roi = m_extras[i].m_roi;
if (roi != NULL) {
MxU16 prefix = *(MxU16*) roi->GetName();
@ -1549,7 +1549,7 @@ void LegoAnimationManager::FUN_100627d0(MxBool p_und)
MxBool maOrPa = prefix == TWOCC('m', 'a') || prefix == TWOCC('p', 'a');
if ((p_und && !maOrPa) ||
(g_characters[m_unk0x3c[i].m_characterId].m_unk0x10 >= 0 && time - m_unk0x3c[i].m_unk0x08 > und &&
(g_characters[m_extras[i].m_characterId].m_unk0x10 >= 0 && time - m_extras[i].m_unk0x08 > und &&
CharacterManager()->GetRefCount(roi) == 1 &&
!viewManager->FUN_100a6150(roi->GetWorldBoundingBox()))) {
m_unk0x414--;
@ -1562,10 +1562,10 @@ void LegoAnimationManager::FUN_100627d0(MxBool p_und)
CharacterManager()->FUN_10083db0(roi);
if (m_unk0x3c[i].m_unk0x14) {
m_unk0x3c[i].m_unk0x14 = FALSE;
if (m_extras[i].m_unk0x14) {
m_extras[i].m_unk0x14 = FALSE;
MxS32 vehicleId = g_characters[m_unk0x3c[i].m_characterId].m_vehicleId;
MxS32 vehicleId = g_characters[m_extras[i].m_characterId].m_vehicleId;
if (vehicleId >= 0) {
g_vehicles[vehicleId].m_unk0x05 = FALSE;
@ -1576,10 +1576,10 @@ void LegoAnimationManager::FUN_100627d0(MxBool p_und)
}
}
m_unk0x3c[i].m_roi = NULL;
g_characters[m_unk0x3c[i].m_characterId].m_unk0x04 = FALSE;
g_characters[m_unk0x3c[i].m_characterId].m_unk0x07 = FALSE;
m_unk0x3c[i].m_characterId = -1;
m_extras[i].m_roi = NULL;
g_characters[m_extras[i].m_characterId].m_unk0x04 = FALSE;
g_characters[m_extras[i].m_characterId].m_unk0x07 = FALSE;
m_extras[i].m_characterId = -1;
}
}
}
@ -1588,7 +1588,7 @@ void LegoAnimationManager::FUN_100627d0(MxBool p_und)
// STUB: LEGO1 0x100629b0
// FUNCTION: BETA10 0x10043c10
void LegoAnimationManager::FUN_100629b0(MxU32, MxBool)
void LegoAnimationManager::AddExtra(MxU32 p_cameraLocation, MxBool p_und)
{
// TODO
}

File diff suppressed because it is too large Load diff

View file

@ -476,6 +476,17 @@ MxResult LegoNavController::UpdateCameraLocation(MxU32 p_location)
return result;
}
// FUNCTION: LEGO1 0x10055720
// FUNCTION: BETA10 0x1009c259
LegoCameraLocation* LegoNavController::GetCameraLocation(MxU32 p_location)
{
if (p_location < _countof(g_cameraLocations)) {
return &g_cameraLocations[p_location];
}
return NULL;
}
// FUNCTION: LEGO1 0x10055750
MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und)
{

View file

@ -487,15 +487,15 @@ void Isle::Enable(MxBool p_enable)
FUN_1003ef00(TRUE);
if (m_act1state->m_unk0x018 == 0) {
MxU32 und[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
MxU32 cameraLocations[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (MxU32 i = 0; i < 5; i++) {
MxS32 und2 = rand() % 5;
MxS32 r = rand() % 5;
for (MxU32 j = 0; j < _countof(und); j++) {
if (und[j] != 0 && und2-- == 0) {
AnimationManager()->FUN_100629b0(und[j], TRUE);
und[j] = 0;
for (MxU32 j = 0; j < _countof(cameraLocations); j++) {
if (cameraLocations[j] != 0 && r-- == 0) {
AnimationManager()->AddExtra(cameraLocations[j], TRUE);
cameraLocations[j] = 0;
break;
}
}