Match code, fix annotations

This commit is contained in:
Christian Semmler 2024-03-15 20:30:29 -04:00
parent 2a15b3188b
commit 558a882bc4
6 changed files with 270 additions and 237 deletions

View File

@ -24,6 +24,7 @@ class Isle : public LegoWorld {
public:
Isle();
~Isle() override;
MxLong Notify(MxParam& p_param) override; // vtable+0x04
// FUNCTION: LEGO1 0x10030910
@ -42,22 +43,25 @@ class Isle : public LegoWorld {
MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18
void ReadyWorld() override; // vtable+50
void Add(MxCore* p_object) override; // vtable+58
// FUNCTION: LEGO1 0x10030900
MxBool VTable0x5c() override { return TRUE; } // vtable+5c
// FUNCTION: LEGO1 0x10033170
void VTable0x60() override {} // vtable+60
void VTable0x60() override {} // vtable+60
MxBool VTable0x64() override; // vtable+64
void Enable(MxBool p_enable) override; // vtable+68
virtual void VTable0x6c(IslePathActor* p_actor); // vtable+6c
inline void SetUnknown13c(MxU32 p_unk0x13c) { m_unk0x13c = p_unk0x13c; }
MxLong StopAction(MxParam& p_param);
MxLong HandleType17Notification(MxParam& p_param);
MxLong HandleType19Notification(MxParam& p_param);
MxLong HandleTransitionEnd();
void FUN_10032620();
inline void SetUnknown13c(MxU32 p_unk0x13c) { m_unk0x13c = p_unk0x13c; }
// SYNTHETIC: LEGO1 0x10030a30
// Isle::`scalar deleting destructor'

View File

@ -3,8 +3,8 @@
#include "animstate.h"
#include "decomp.h"
#include "legotraninfolist.h"
#include "mxcore.h"
#include "traninfo.h"
// SIZE 0x18
struct Character {
@ -18,7 +18,7 @@ struct Character {
class LegoAnimationManager : public MxCore {
public:
LegoAnimationManager();
~LegoAnimationManager() override; // vtable+0x00
~LegoAnimationManager() override;
MxLong Notify(MxParam& p_param) override; // vtable+0x04
MxResult Tickle() override; // vtable+0x08
@ -58,34 +58,34 @@ class LegoAnimationManager : public MxCore {
private:
void Init();
undefined4 m_unk0x08; // 0x08
MxU16 m_animCount; // 0x0c
MxU16 m_unk0x0e; // 0x0e
MxU32 m_unk0x10; // 0x10
AnimInfo* m_anims; // 0x14
undefined m_unk0x018[8]; // 0x18
TranInfoList* m_tranInfoList; // 0x20
TranInfoList* m_tranInfoList2; // 0x24
undefined4 m_unk0x28[2]; // 0x28
undefined4 m_unk0x30[2]; // 0x30
undefined m_unk0x38; // 0x38
undefined m_unk0x39; // 0x39
undefined m_unk0x3a; // 0x3a
undefined m_unk0x3b[0x3c1]; // 0x3b
undefined4 m_unk0x3fc; // 0x3fc
MxU8 m_unk0x400; // 0x400
undefined m_unk0x401; // 0x401
MxU8 m_unk0x402; // 0x402
undefined m_unk0x403[0x1d]; // 0x403
AnimState* m_animState; // 0x420
undefined4 m_unk0x424; // 0x424
undefined m_unk0x428; // 0x428
undefined m_unk0x429; // 0x429
undefined m_unk0x42a; // 0x42a
undefined m_unk0x42b; // 0x42b
undefined4 m_unk0x42c; // 0x42c
undefined m_unk0x430; // 0x430
undefined m_unk0x431[0xcf]; // 0x431
undefined4 m_unk0x08; // 0x08
MxU16 m_animCount; // 0x0c
MxU16 m_unk0x0e; // 0x0e
MxU32 m_unk0x10; // 0x10
AnimInfo* m_anims; // 0x14
undefined m_unk0x018[8]; // 0x18
LegoTranInfoList* m_tranInfoList; // 0x20
LegoTranInfoList* m_tranInfoList2; // 0x24
undefined4 m_unk0x28[2]; // 0x28
undefined4 m_unk0x30[2]; // 0x30
undefined m_unk0x38; // 0x38
undefined m_unk0x39; // 0x39
undefined m_unk0x3a; // 0x3a
undefined m_unk0x3b[0x3c1]; // 0x3b
undefined4 m_unk0x3fc; // 0x3fc
MxU8 m_unk0x400; // 0x400
undefined m_unk0x401; // 0x401
MxU8 m_unk0x402; // 0x402
undefined m_unk0x403[0x1d]; // 0x403
AnimState* m_animState; // 0x420
undefined4 m_unk0x424; // 0x424
undefined m_unk0x428; // 0x428
undefined m_unk0x429; // 0x429
undefined m_unk0x42a; // 0x42a
undefined m_unk0x42b; // 0x42b
undefined4 m_unk0x42c; // 0x42c
undefined m_unk0x430; // 0x430
undefined m_unk0x431[0xcf]; // 0x431
};
#endif // LEGOANIMATIONMANAGER_H

View File

@ -0,0 +1,11 @@
#ifndef LEGOTRANINFO_H
#define LEGOTRANINFO_H
#include "decomp.h"
// SIZE 0x78
struct LegoTranInfo { // See FUN_100609f0 for construction
undefined m_unk0x00[0x78]; // 0x00
};
#endif // LEGOTRANINFO_H

View File

@ -0,0 +1,51 @@
#ifndef LEGOTRANINFOLIST_H
#define LEGOTRANINFOLIST_H
#include "legotraninfo.h"
#include "mxlist.h"
#include "mxtypes.h"
// VTABLE: LEGO1 0x100d8ca8
// class MxCollection<LegoTranInfo *>
// VTABLE: LEGO1 0x100d8cc0
// class MxList<LegoTranInfo *>
// VTABLE: LEGO1 0x100d8cd8
// class MxPtrList<LegoTranInfo>
// VTABLE: LEGO1 0x100d8c90
// SIZE 0x18
class LegoTranInfoList : public MxPtrList<LegoTranInfo> {
public:
LegoTranInfoList() : MxPtrList<LegoTranInfo>(FALSE) {}
};
// TEMPLATE: LEGO1 0x1005fdf0
// MxCollection<LegoTranInfo *>::Compare
// TEMPLATE: LEGO1 0x1005fe00
// MxCollection<LegoTranInfo *>::~MxCollection<LegoTranInfo *>
// TEMPLATE: LEGO1 0x1005fe50
// MxCollection<LegoTranInfo *>::Destroy
// TEMPLATE: LEGO1 0x1005fe60
// MxList<LegoTranInfo *>::~MxList<LegoTranInfo *>
// SYNTHETIC: LEGO1 0x1005fef0
// LegoTranInfoList::`scalar deleting destructor'
// TEMPLATE: LEGO1 0x1005ff60
// MxPtrList<LegoTranInfo>::~MxPtrList<LegoTranInfo>
// SYNTHETIC: LEGO1 0x1005ffb0
// MxCollection<LegoTranInfo *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x10060020
// MxList<LegoTranInfo *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x100600d0
// MxPtrList<LegoTranInfo>::`scalar deleting destructor'
#endif // LEGOTRANINFOLIST_H

View File

@ -1,77 +0,0 @@
#ifndef TRANINFO_H
#define TRANINFO_H
#include "mxlist.h"
#include "mxtypes.h"
// SIZE 0x78
struct TranInfo { // See FUN_100609f0 for construction
undefined m_unk0x00[0x78]; // 0x00
};
// VTABLE: LEGO1 0x100d8c90
// SIZE 0x18
class TranInfoList : public MxPtrList<TranInfo> {
public:
TranInfoList(MxBool p_ownership = FALSE) : MxPtrList<TranInfo>(p_ownership) {}
};
// VTABLE: LEGO1 0x100d8ca8
// class MxCollection<TranInfo *>
// VTABLE: LEGO1 0x100d8cc0
// class MxList<TranInfo *>
// VTABLE: LEGO1 0x100d8cd8
// class MxPtrList<TranInfo>
// VTABLE: LEGO1 0x100d8cf0
// class MxListCursor<TranInfo *>
// VTABLE: LEGO1 0x100d8d08
// class MxPtrListCursor<TranInfo>
// VTABLE: LEGO1 0x100d8d20
// SIZE 0x10
class TranInfoListCursor : public MxPtrListCursor<TranInfo> {
public:
TranInfoListCursor(TranInfoList* p_list) : MxPtrListCursor<TranInfo>(p_list) {}
};
// TEMPLATE: LEGO1 0x1005fdf0
// MxCollection<TranInfo *>::Compare
// TEMPLATE: LEGO1 0x1005fe50
// MxCollection<TranInfo *>::Destroy
// SYNTHETIC: LEGO1 0x1005fef0
// TranInfoList::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x1005ffb0
// MxCollection<TranInfo *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x10060020
// MxList<TranInfo *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x100600d0
// MxPtrList<TranInfo>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x100612f0
// TranInfoListCursor::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x10061360
// MxPtrListCursor<TranInfo>::~MxPtrListCursor<TranInfo>
// SYNTHETIC: LEGO1 0x100613b0
// MxListCursor<TranInfo *>::`scalar deleting destructor'
// SYNTHETIC: LEGO1 0x10061420
// MxPtrListCursor<TranInfo>::`scalar deleting destructor'
// TEMPLATE: LEGO1 0x10061490
// MxListCursor<TranInfo *>::~MxListCursor<TranInfo *>
// TEMPLATE: LEGO1 0x100614e0
// TranInfoListCursor::~TranInfoListCursor
#endif // TranInfoLIST_H

View File

@ -13,7 +13,7 @@ DECOMP_SIZE_ASSERT(LegoAnimationManager, 0x500)
Character g_characters[47]; // TODO: Initialize this
// GLOBAL: LEGO1 0x100f74f8
int g_legoAnimationManagerConfig = 1;
MxS32 g_legoAnimationManagerConfig = 1;
// FUNCTION: LEGO1 0x1005eb50
void LegoAnimationManager::configureLegoAnimationManager(MxS32 p_legoAnimationManagerConfig)
@ -67,136 +67,163 @@ void LegoAnimationManager::FUN_1005f6d0(MxBool)
MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex)
{
MxResult result = FAILURE;
MxS32 i, j, k;
if (m_unk0x08 != p_scriptIndex) {
if (m_tranInfoList != NULL) {
delete m_tranInfoList;
m_tranInfoList = NULL;
}
if (m_tranInfoList2 != NULL) {
delete m_tranInfoList2;
m_tranInfoList2 = NULL;
}
for (int i = 0; i < 2; i++) {
for (i = 0; i < 2; i++) {
m_unk0x28[i] = 0;
m_unk0x30[i] = 0;
}
m_unk0x38 = 0;
m_unk0x39 = 0;
m_unk0x430 = 0;
m_unk0x42c = 0;
for (int i2 = 0; i2 < 0x2f; i2++) {
g_characters[i2].m_active = FALSE;
for (j = 0; j < 0x2f; j++) { // TODO countof
g_characters[j].m_active = FALSE;
}
m_animState = (AnimState*) GameState()->GetState("AnimState");
if (m_animState == NULL) {
m_animState = (AnimState*) GameState()->CreateState("AnimState");
}
if (m_unk0x08 == 0) {
m_animState->FUN_10065240(m_animCount, m_anims, m_unk0x3fc);
}
FUN_100603c0();
LegoFile file;
if (p_scriptIndex == -1) {
result = SUCCESS;
goto done;
}
else {
char filename[128];
char path[1024];
sprintf(filename, "lego\\data\\%sinf.dta", Lego()->FindScript(p_scriptIndex));
sprintf(path, "%s", MxOmni::GetHD());
char filename[128];
char path[1024];
sprintf(filename, "lego\\data\\%sinf.dta", Lego()->FindScript(p_scriptIndex));
sprintf(path, "%s", MxOmni::GetHD());
if (path[strlen(path) - 1] != '\\') {
strcat(path, "\\");
}
strcat(path, filename);
if (_access(path, 4)) {
sprintf(path, "%s", MxOmni::GetCD());
if (path[strlen(path) - 1] != '\\') {
strcat(path, "\\");
}
strcat(path, filename);
if (_access(path, 4)) {
sprintf(path, "%s", MxOmni::GetCD());
if (path[strlen(path) - 1] != '\\') {
strcat(path, "\\");
}
strcat(path, filename);
if (_access(path, 4)) {
goto done;
}
}
if (file.Open(path, LegoFile::c_read) == FAILURE) {
goto done;
}
MxU32 version;
if (file.Read(&version, 4) == FAILURE) {
goto done;
}
if (version != 3) {
OmniError("World animation version mismatch", 0);
goto done;
}
if (file.Read(&m_animCount, 2) == FAILURE) {
goto done;
}
m_anims = new AnimInfo[m_animCount];
memset(m_anims, 0, m_animCount * sizeof(AnimInfo));
for (int i = 0; i < m_animCount; i++) {
if (ReadAnimInfo(&file, &m_anims[i]) == FAILURE) {
goto done;
}
m_anims[i].m_unk0x28 = FUN_10062360(m_anims[i].m_animName + strlen(m_anims[i].m_animName) - 2);
m_anims[i].m_unk0x29 = 0;
for (int j = 0; j < 3; j++) {
m_anims[i].m_unk0x2a[j] = -1;
}
if (m_anims[i].m_unk0x08 == -1) {
for (int j = 0; j < m_anims[i].m_modelCount; j++) {
MxS32 index = FUN_10062360(m_anims[i].m_models[j].m_modelName);
if (index >= 0) {
g_characters[index].m_active = TRUE;
}
}
}
MxS32 count = 0;
for (int j2 = 0; j2 < m_anims[i].m_modelCount; j2++) {
MxU32 k;
if (FUN_10060140(m_anims[i].m_models[j2].m_modelName, k) && m_anims[i].m_models[j2].m_unk0x2c) {
m_anims[i].m_unk0x2a[count++] = k;
if (count > 3) {
break;
}
}
}
}
m_unk0x08 = p_scriptIndex;
m_tranInfoList = new LegoUnknown100d8c90();
m_tranInfoList2 = new LegoUnknown100d8c90();
FUN_100617c0(-1, m_unk0x0e, m_unk0x10);
result = SUCCESS;
m_unk0x402 = 1;
if (m_unk0x42b) {
m_unk0x42a = 1;
m_unk0x402 = 0;
m_unk0x428 = m_unk0x3a;
m_unk0x3a = 0;
m_unk0x429 = m_unk0x400;
m_unk0x400 = 0;
}
if (p_scriptIndex == 0) {
m_animState->FUN_100651d0(m_animCount, m_anims, m_unk0x3fc);
}
}
if (file.Open(path, LegoFile::c_read) == FAILURE) {
goto done;
}
MxU32 version;
if (file.Read(&version, sizeof(version)) == FAILURE) {
goto done;
}
if (version != 3) {
OmniError("World animation version mismatch", 0);
goto done;
}
if (file.Read(&m_animCount, sizeof(m_animCount)) == FAILURE) {
goto done;
}
m_anims = new AnimInfo[m_animCount];
memset(m_anims, 0, m_animCount * sizeof(*m_anims));
for (j = 0; j < m_animCount; j++) {
if (ReadAnimInfo(&file, &m_anims[j]) == FAILURE) {
goto done;
}
m_anims[j].m_unk0x28 = FUN_10062360(m_anims[j].m_animName + strlen(m_anims[j].m_animName) - 2);
m_anims[j].m_unk0x29 = 0;
for (k = 0; k < 3; k++) {
m_anims[j].m_unk0x2a[k] = -1;
}
if (m_anims[j].m_unk0x08 == -1) {
for (MxS32 l = 0; l < m_anims[j].m_modelCount; l++) {
MxS32 index = FUN_10062360(m_anims[j].m_models[l].m_modelName);
if (index >= 0) {
g_characters[index].m_active = TRUE;
}
}
}
MxS32 count = 0;
for (MxS32 m = 0; m < m_anims[j].m_modelCount; m++) {
MxU32 n;
if (FUN_10060140(m_anims[j].m_models[m].m_modelName, n) && m_anims[j].m_models[m].m_unk0x2c) {
m_anims[j].m_unk0x2a[count++] = n;
if (count > 3) {
break;
}
}
}
}
m_unk0x08 = p_scriptIndex;
m_tranInfoList = new LegoTranInfoList();
m_tranInfoList2 = new LegoTranInfoList();
FUN_100617c0(-1, m_unk0x0e, m_unk0x10);
result = SUCCESS;
m_unk0x402 = 1;
if (m_unk0x42b) {
m_unk0x428 = m_unk0x3a;
m_unk0x429 = m_unk0x400;
m_unk0x42a = 1;
m_unk0x3a = 0;
m_unk0x400 = 0;
m_unk0x402 = 0;
}
if (p_scriptIndex == 0) {
m_animState->FUN_100651d0(m_animCount, m_anims, m_unk0x3fc);
}
}
done:
if (result == FAILURE) {
FUN_100603c0();
}
return result;
}
// FUNCTION: LEGO1 0x1005fe50
void LegoUnknown100d8ca8Handler()
{
}
void LegoUnknown100d8cd8Handler()
{
}
// STUB: LEGO1 0x10060140
MxBool LegoAnimationManager::FUN_10060140(char* p_name, MxU32& p_index)
{
@ -208,50 +235,60 @@ MxResult LegoAnimationManager::ReadAnimInfo(LegoFile* p_file, AnimInfo* p_info)
{
MxResult result = FAILURE;
MxU8 length;
int i, i2;
if (p_file->Read(&length, 1) == FAILURE) {
goto fail;
MxS32 i, j;
if (p_file->Read(&length, sizeof(length)) == FAILURE) {
goto done;
}
p_info->m_animName = new char[length + 1];
if (p_file->Read(p_info->m_animName, length) == FAILURE) {
goto fail;
goto done;
}
p_info->m_animName[length] = 0;
if (p_file->Read(&p_info->m_unk0x04, 4) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x04, sizeof(p_info->m_unk0x04)) == FAILURE) {
goto done;
}
if (p_file->Read(&p_info->m_unk0x08, 2) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x08, sizeof(p_info->m_unk0x08)) == FAILURE) {
goto done;
}
if (p_file->Read(&p_info->m_unk0x0a, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x0a, sizeof(p_info->m_unk0x0a)) == FAILURE) {
goto done;
}
if (p_file->Read(&p_info->m_unk0x0b, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x0b, sizeof(p_info->m_unk0x0b)) == FAILURE) {
goto done;
}
if (p_file->Read(&p_info->m_unk0x0c, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x0c, sizeof(p_info->m_unk0x0c)) == FAILURE) {
goto done;
}
if (p_file->Read(&p_info->m_unk0x0d, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x0d, sizeof(p_info->m_unk0x0d)) == FAILURE) {
goto done;
}
for (i = 0; i < 4; i++) {
if (p_file->Read(&p_info->m_unk0x10[i], 4) != SUCCESS) {
goto fail;
for (i = 0; i < (MxS32) _countof(p_info->m_unk0x10); i++) {
if (p_file->Read(&p_info->m_unk0x10[i], sizeof(*p_info->m_unk0x10)) != SUCCESS) {
goto done;
}
}
if (p_file->Read(&p_info->m_modelCount, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_modelCount, sizeof(p_info->m_modelCount)) == FAILURE) {
goto done;
}
p_info->m_models = new ModelInfo[p_info->m_modelCount];
memset(p_info->m_models, 0, p_info->m_modelCount * sizeof(ModelInfo));
for (i2 = 0; i2 < p_info->m_modelCount; i2++) {
if (ReadModelInfo(p_file, &p_info->m_models[i2]) == FAILURE) {
goto fail;
memset(p_info->m_models, 0, p_info->m_modelCount * sizeof(*p_info->m_models));
for (j = 0; j < p_info->m_modelCount; j++) {
if (ReadModelInfo(p_file, &p_info->m_models[j]) == FAILURE) {
goto done;
}
}
result = SUCCESS;
fail:
done:
return result;
}
@ -260,37 +297,44 @@ MxResult LegoAnimationManager::ReadModelInfo(LegoFile* p_file, ModelInfo* p_info
{
MxResult result = FAILURE;
MxU8 length;
if (p_file->Read(&length, 1) == FAILURE) {
goto fail;
goto done;
}
p_info->m_modelName = new char[length + 1];
if (p_file->Read(p_info->m_modelName, length) == FAILURE) {
goto fail;
goto done;
}
p_info->m_modelName[length] = 0;
if (p_file->Read(&p_info->m_unk0x04, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x04, sizeof(p_info->m_unk0x04)) == FAILURE) {
goto done;
}
if (p_file->Read(p_info->m_location, 12) != SUCCESS) {
goto fail;
if (p_file->Read(p_info->m_location, sizeof(p_info->m_location)) != SUCCESS) {
goto done;
}
if (p_file->Read(p_info->m_direction, 12) != SUCCESS) {
goto fail;
if (p_file->Read(p_info->m_direction, sizeof(p_info->m_direction)) != SUCCESS) {
goto done;
}
if (p_file->Read(p_info->m_up, 12) != SUCCESS) {
goto fail;
if (p_file->Read(p_info->m_up, sizeof(p_info->m_up)) != SUCCESS) {
goto done;
}
if (p_file->Read(&p_info->m_unk0x2c, 1) == FAILURE) {
goto fail;
if (p_file->Read(&p_info->m_unk0x2c, sizeof(p_info->m_unk0x2c)) == FAILURE) {
goto done;
}
result = SUCCESS;
fail:
done:
return result;
}
// STUB: LEGO1 0x100603c0
void LegoAnimationManager::FUN_100603c0()
{
// TODO
}
// STUB: LEGO1 0x10061010
@ -302,13 +346,13 @@ void LegoAnimationManager::FUN_10061010(undefined4)
// STUB: LEGO1 0x100617c0
void LegoAnimationManager::FUN_100617c0(MxS32, MxU16&, MxU32&)
{
// TODO
}
// STUB: LEGO1 0x100619f0
MxLong LegoAnimationManager::Notify(MxParam& p_param)
{
// TODO
return 0;
}
@ -316,7 +360,6 @@ MxLong LegoAnimationManager::Notify(MxParam& p_param)
MxResult LegoAnimationManager::Tickle()
{
// TODO
return SUCCESS;
}
@ -329,4 +372,5 @@ MxS8 LegoAnimationManager::FUN_10062360(char*)
// STUB: LEGO1 0x10064670
void LegoAnimationManager::FUN_10064670(MxBool)
{
// TODO
}