Add beta annotations and adjust style/naming

This commit is contained in:
Christian Semmler 2024-05-09 09:39:02 -04:00
parent d2d7b706ea
commit 622720ebfd
6 changed files with 89 additions and 74 deletions

View File

@ -21,26 +21,35 @@ struct LegoBuildingInfo {
c_bit4 = 0x08
};
LegoEntity* m_entity; // 0x00
const char* m_hausName; // 0x04
MxU32 m_cycle1; // 0x08
MxU32 m_cycle2; // 0x0c
MxU8 m_cycle3; // 0x10
MxS8 m_unk0x11; // 0x11
MxS8 m_initialUnk0x11; // 0x12 = initial value loaded to m_unk0x11
MxU8 m_flags; // 0x13
float m_unk0x014; // 0x14
const char* m_unk0x18; // 0x18
float m_x; // 0x1c
float m_y; // 0x20
float m_z; // 0x24
LegoPathBoundary* m_pathBoundary; // 0x28
LegoEntity* m_entity; // 0x00
const char* m_hausName; // 0x04
MxU32 m_cycle1; // 0x08
MxU32 m_cycle2; // 0x0c
MxU8 m_cycle3; // 0x10
MxS8 m_unk0x11; // 0x11
MxS8 m_initialUnk0x11; // 0x12 = initial value loaded to m_unk0x11
MxU8 m_flags; // 0x13
float m_unk0x014; // 0x14
const char* m_unk0x18; // 0x18
float m_x; // 0x1c
float m_y; // 0x20
float m_z; // 0x24
LegoPathBoundary* m_boundary; // 0x28
};
// VTABLE: LEGO1 0x100d6f50
// SIZE 0x30
class LegoBuildingManager : public MxCore {
public:
// SIZE 0x14
struct AnimEntry {
LegoEntity* m_entity; // 0x00
LegoROI* m_roi; // 0x04
LegoTime m_time; // 0x08
float m_unk0x0c; // 0x0c
MxBool m_muted; // 0x10
};
LegoBuildingManager();
~LegoBuildingManager() override;
@ -72,25 +81,18 @@ class LegoBuildingManager : public MxCore {
MxBool FUN_10030000(LegoEntity* p_entity);
MxBool FUN_10030030(MxS32 p_index);
MxBool FUN_10030110(LegoBuildingInfo* p_data);
void ScheduleAnimation(LegoEntity*, MxU32 p_length, MxBool p_haveSound, MxBool);
void ScheduleAnimation(LegoEntity* p_entity, MxU32 p_length, MxBool p_haveSound, MxBool p_unk0x28);
void FUN_10030590();
void AdjustHeight(MxS32 p_index);
MxResult FUN_10030630();
LegoBuildingInfo* GetInfoArray(int* p_length);
void FUN_100307b0(LegoEntity*, MxS32);
LegoBuildingInfo* GetInfoArray(MxS32& p_length);
void FUN_100307b0(LegoEntity* p_entity, MxS32 p_adjust);
static void FUN_10030800();
// SYNTHETIC: LEGO1 0x1002f940
// LegoBuildingManager::`scalar deleting destructor'
struct AnimEntry {
LegoEntity* m_entity;
LegoROI* m_roi;
LegoTime m_time;
float m_float;
MxBool m_muted;
};
private:
static char* g_customizeAnimFile;

View File

@ -37,7 +37,7 @@ class LegoCacheSound : public MxCore {
MxResult FUN_10006a30(const char* p_str, MxBool);
void FUN_10006b80();
void FUN_10006be0();
void FUN_10006cb0(undefined4, undefined4);
void FUN_10006cb0(undefined4 p_und1, undefined4 p_und2);
// SYNTHETIC: LEGO1 0x10006610
// LegoCacheSound::`scalar deleting destructor'

View File

@ -150,9 +150,9 @@ void LegoCacheSound::FUN_10006be0()
}
// FUNCTION: LEGO1 0x10006cb0
void LegoCacheSound::FUN_10006cb0(undefined4 p_unk0x1, undefined4 p_unk0x2)
void LegoCacheSound::FUN_10006cb0(undefined4 p_und1, undefined4 p_und2)
{
m_unk0x10.FUN_10011cf0(p_unk0x1, p_unk0x2);
m_unk0x10.FUN_10011cf0(p_und1, p_und2);
}
// FUNCTION: LEGO1 0x10006cd0

View File

@ -297,7 +297,7 @@ void LegoBuildingManager::UpdatePosition(MxS32 p_index, LegoWorld* p_world)
LegoROI* roi = entity->GetROI();
AdjustHeight(p_index);
MxMatrix mat = roi->GetLocal2World();
mat.SetY(g_buildingInfo[p_index].m_unk0x014);
mat[3][1] = g_buildingInfo[p_index].m_unk0x014;
roi->FUN_100a46b0(mat);
VideoManager()->Get3DManager()->Moved(*roi);
}
@ -306,17 +306,18 @@ void LegoBuildingManager::UpdatePosition(MxS32 p_index, LegoWorld* p_world)
// FUNCTION: LEGO1 0x1002fb30
void LegoBuildingManager::FUN_1002fb30()
{
for (MxU32 i = 0; i < _countof(g_buildingInfo); i++) {
MxU32 i;
for (i = 0; i < _countof(g_buildingInfo); i++) {
g_buildingInfo[i].m_entity = NULL;
}
m_unk0x09 = 0;
// Weird if statement but the obvious != 0 does not produce
// the 100% match this does.
if ((MxU32) m_numEntries >= 0) {
for (MxU32 i = 0; i < m_numEntries; i++) {
delete m_entries[i];
}
for (i = 0; i < m_numEntries; i++) {
delete m_entries[i];
}
m_numEntries = 0;
}
@ -529,28 +530,36 @@ MxBool LegoBuildingManager::FUN_1002fed0(LegoEntity* p_entity)
}
// FUNCTION: LEGO1 0x1002ff00
// FUNCTION: BETA10 0x1006432d
MxU32 LegoBuildingManager::GetBuildingEntityId(LegoEntity* p_entity)
{
LegoBuildingInfo* data = GetInfo(p_entity);
if (data != NULL && (data->m_flags & 0x4) != 0) {
return g_buildingEntityId[data - g_buildingInfo] + data->m_cycle2;
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit3) {
return g_buildingEntityId[info - g_buildingInfo] + info->m_cycle2;
}
return 0;
}
// FUNCTION: LEGO1 0x1002ff40
// FUNCTION: BETA10 0x10064398
MxU32 LegoBuildingManager::FUN_1002ff40(LegoEntity* p_entity, MxBool p_state)
{
LegoBuildingInfo* data = GetInfo(p_entity);
if (data == NULL || (data->m_flags & 0x2) == 0) {
LegoBuildingInfo* info = GetInfo(p_entity);
if (info == NULL || !(info->m_flags & LegoBuildingInfo::c_bit2)) {
return 0;
}
if (p_state) {
return data->m_cycle3 + g_cycleLengthOffset3;
return info->m_cycle3 + g_cycleLengthOffset3;
}
if (data != NULL) {
return data->m_cycle1 + g_cycleLengthOffset1;
if (info != NULL) {
return info->m_cycle1 + g_cycleLengthOffset1;
}
return 0;
}
@ -604,25 +613,28 @@ MxBool LegoBuildingManager::FUN_10030110(LegoBuildingInfo* p_data)
}
// FUNCTION: LEGO1 0x10030150
void LegoBuildingManager::ScheduleAnimation(LegoEntity* p_entity, MxU32 p_length, MxBool p_haveSound, MxBool p_extra)
void LegoBuildingManager::ScheduleAnimation(LegoEntity* p_entity, MxU32 p_length, MxBool p_haveSound, MxBool p_unk0x28)
{
m_world = CurrentWorld();
if (p_haveSound) {
m_sound = SoundManager()->GetCacheSoundManager()->FUN_1003d170("bcrash");
m_sound->FUN_10006cb0(0x23, 0x3c);
m_sound->FUN_10006cb0(35, 60);
}
if (m_numEntries == 0) {
m_unk0x28 = p_extra;
TickleManager()->RegisterClient(this, 0x32);
m_unk0x28 = p_unk0x28;
TickleManager()->RegisterClient(this, 50);
}
m_entries[m_numEntries] = new AnimEntry;
AnimEntry* entry = m_entries[m_numEntries];
AnimEntry* entry = m_entries[m_numEntries] = new AnimEntry;
m_numEntries++;
entry->m_entity = p_entity;
entry->m_roi = p_entity->GetROI();
entry->m_time = Timer()->GetTime() + p_length + 1000;
entry->m_float = entry->m_roi->GetLocal2World().GetY();
entry->m_muted = (p_haveSound == FALSE);
entry->m_unk0x0c = entry->m_roi->GetLocal2World()[3][1];
entry->m_muted = p_haveSound == FALSE;
FUN_100307b0(p_entity, -2);
}
@ -631,6 +643,7 @@ MxResult LegoBuildingManager::Tickle()
{
// WIP, included some of this to understand the AnimEntry array.
LegoTime time = Timer()->GetTime();
if (m_numEntries != 0) {
if (m_numEntries > 0) {
for (MxS32 i = 0; i < m_numEntries; i++) {
@ -644,22 +657,25 @@ MxResult LegoBuildingManager::Tickle()
else {
TickleManager()->UnregisterClient(this);
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x10030590
// FUNCTION: BETA10 0x1006474c
void LegoBuildingManager::FUN_10030590()
{
for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) {
g_buildingInfo[i].m_unk0x11 = -1;
g_buildingInfo[i].m_initialUnk0x11 = -1;
AdjustHeight(i);
if (g_buildingInfo[i].m_entity != NULL) {
LegoROI* roi = g_buildingInfo[i].m_entity->GetROI();
MxMatrix matrix = roi->GetLocal2World();
matrix.SetY(g_buildingInfo[i].m_unk0x014);
roi->FUN_100a46b0(matrix);
VideoManager()->Get3DManager()->GetLego3DView()->Moved(*roi);
MxMatrix mat = roi->GetLocal2World();
mat[3][1] = g_buildingInfo[i].m_unk0x014;
roi->FUN_100a46b0(mat);
VideoManager()->Get3DManager()->Moved(*roi);
}
}
}
@ -671,27 +687,30 @@ MxResult LegoBuildingManager::FUN_10030630()
}
// FUNCTION: LEGO1 0x10030790
LegoBuildingInfo* LegoBuildingManager::GetInfoArray(int* p_length)
LegoBuildingInfo* LegoBuildingManager::GetInfoArray(MxS32& p_length)
{
if (m_unk0x09 == 0) {
FUN_10030630();
}
*p_length = _countof(g_buildingInfo);
p_length = _countof(g_buildingInfo);
return g_buildingInfo;
}
// FUNCTION: LEGO1 0x100307b0
void LegoBuildingManager::FUN_100307b0(LegoEntity* p_entity, MxS32 p_adjust)
{
LegoBuildingInfo* data = GetInfo(p_entity);
if (data != NULL) {
if (data->m_unk0x11 < 0) {
data->m_unk0x11 = g_buildingInfoDownshift[data - g_buildingInfo];
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL) {
if (info->m_unk0x11 < 0) {
info->m_unk0x11 = g_buildingInfoDownshift[info - g_buildingInfo];
}
if (data->m_unk0x11 > 0) {
data->m_unk0x11 += p_adjust;
if (data->m_unk0x11 <= 1 && p_adjust < 0) {
data->m_unk0x11 = 0;
if (info->m_unk0x11 > 0) {
info->m_unk0x11 += p_adjust;
if (info->m_unk0x11 <= 1 && p_adjust < 0) {
info->m_unk0x11 = 0;
}
}
}

View File

@ -68,6 +68,7 @@ MxResult LegoPathController::FUN_10046b30(LegoPathBoundary** p_path, MxS32& p_va
}
// FUNCTION: LEGO1 0x10046b50
// FUNCTION: BETA10 0x100b7531
LegoPathBoundary* LegoPathController::GetPathBoundary(const char* p_name)
{
for (MxS32 i = 0; i < m_numL; i++) {
@ -75,6 +76,7 @@ LegoPathBoundary* LegoPathController::GetPathBoundary(const char* p_name)
return &m_unk0x08[i];
}
}
return NULL;
}

View File

@ -147,14 +147,6 @@ class Matrix4 {
float* operator[](int idx) { return m_data[idx]; }
const float* operator[](int idx) const { return m_data[idx]; }
inline void SetX(float p_x) { m_data[3][0] = p_x; }
inline void SetY(float p_y) { m_data[3][1] = p_y; }
inline void SetZ(float p_z) { m_data[3][2] = p_z; }
inline float GetX() const { return m_data[3][0]; }
inline float GetY() const { return m_data[3][1]; }
inline float GetZ() const { return m_data[3][2]; }
protected:
float (*m_data)[4];
};