Clear unknowns in LegoPlantManager (#1557)

This commit is contained in:
Fabian Neundorf
2025-06-12 18:33:32 +02:00
committed by GitHub
parent 596ebde9d3
commit 7b619d5544
8 changed files with 61 additions and 61 deletions

View File

@@ -52,11 +52,11 @@ public:
MxU32 GetSoundId(LegoEntity* p_entity, MxBool p_state); MxU32 GetSoundId(LegoEntity* p_entity, MxBool p_state);
LegoPlantInfo* GetInfoArray(MxS32& p_length); LegoPlantInfo* GetInfoArray(MxS32& p_length);
LegoEntity* CreatePlant(MxS32 p_index, LegoWorld* p_world, LegoOmni::World p_worldId); LegoEntity* CreatePlant(MxS32 p_index, LegoWorld* p_world, LegoOmni::World p_worldId);
MxBool FUN_10026c50(LegoEntity* p_entity); MxBool DecrementCounter(LegoEntity* p_entity);
void ScheduleAnimation(LegoEntity* p_entity, MxLong p_length); void ScheduleAnimation(LegoEntity* p_entity, MxLong p_length);
MxResult FUN_10026410(); MxResult FUN_10026410();
void FUN_10027120(); void ClearCounters();
void FUN_10027200(); void SetInitialCounters();
static void SetCustomizeAnimFile(const char* p_value); static void SetCustomizeAnimFile(const char* p_value);
@@ -68,10 +68,10 @@ public:
private: private:
void RemovePlant(MxS32 p_index, LegoOmni::World p_worldId); void RemovePlant(MxS32 p_index, LegoOmni::World p_worldId);
void FUN_10026860(MxS32 p_index); void AdjustHeight(MxS32 p_index);
LegoPlantInfo* GetInfo(LegoEntity* p_entity); LegoPlantInfo* GetInfo(LegoEntity* p_entity);
MxBool FUN_10026c80(MxS32 p_index); MxBool DecrementCounter(MxS32 p_index);
void FUN_100271b0(LegoEntity* p_entity, MxS32 p_adjust); void AdjustCounter(LegoEntity* p_entity, MxS32 p_adjust);
static char* g_customizeAnimFile; static char* g_customizeAnimFile;
static MxS32 g_maxMove[4]; static MxS32 g_maxMove[4];

View File

@@ -41,8 +41,8 @@ struct LegoPlantInfo {
MxU32 m_move; // 0x10 MxU32 m_move; // 0x10
MxU8 m_mood; // 0x14 MxU8 m_mood; // 0x14
MxU8 m_color; // 0x15 - see enum for possible values MxU8 m_color; // 0x15 - see enum for possible values
MxS8 m_unk0x16; // 0x16 MxS8 m_counter; // 0x16
MxS8 m_initialUnk0x16; // 0x17 - initial value loaded to m_unk0x16 MxS8 m_initialCounter; // 0x17 - initial value loaded to m_counter
const char* m_name; // 0x18 const char* m_name; // 0x18
undefined4 m_unk0x1c; // 0x1c undefined4 m_unk0x1c; // 0x1c
float m_x; // 0x20 float m_x; // 0x20

View File

@@ -728,7 +728,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f0f30[i] != -1; i++) { for (i = 0; g_unk0x100f0f30[i] != -1; i++) {
if (plantInfo[g_unk0x100f0f30[i]].m_unk0x16) { if (plantInfo[g_unk0x100f0f30[i]].m_counter) {
result = plantInfo[g_unk0x100f0f30[i]].m_entity; result = plantInfo[g_unk0x100f0f30[i]].m_entity;
break; break;
} }
@@ -742,7 +742,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f0f50[i] != -1; i++) { for (i = 0; g_unk0x100f0f50[i] != -1; i++) {
if (plantInfo[g_unk0x100f0f50[i]].m_unk0x16) { if (plantInfo[g_unk0x100f0f50[i]].m_counter) {
result = plantInfo[g_unk0x100f0f50[i]].m_entity; result = plantInfo[g_unk0x100f0f50[i]].m_entity;
break; break;
} }
@@ -760,7 +760,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f0f90[i] != -1; i++) { for (i = 0; g_unk0x100f0f90[i] != -1; i++) {
if (plantInfo[g_unk0x100f0f90[i]].m_unk0x16) { if (plantInfo[g_unk0x100f0f90[i]].m_counter) {
result = plantInfo[g_unk0x100f0f90[i]].m_entity; result = plantInfo[g_unk0x100f0f90[i]].m_entity;
break; break;
} }
@@ -782,7 +782,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f0fa8[i] != -1; i++) { for (i = 0; g_unk0x100f0fa8[i] != -1; i++) {
if (plantInfo[g_unk0x100f0fa8[i]].m_unk0x16) { if (plantInfo[g_unk0x100f0fa8[i]].m_counter) {
result = plantInfo[g_unk0x100f0fa8[i]].m_entity; result = plantInfo[g_unk0x100f0fa8[i]].m_entity;
break; break;
} }
@@ -800,7 +800,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f0fb8[i] != -1; i++) { for (i = 0; g_unk0x100f0fb8[i] != -1; i++) {
if (plantInfo[g_unk0x100f0fb8[i]].m_unk0x16) { if (plantInfo[g_unk0x100f0fb8[i]].m_counter) {
result = plantInfo[g_unk0x100f0fb8[i]].m_entity; result = plantInfo[g_unk0x100f0fb8[i]].m_entity;
break; break;
} }
@@ -814,7 +814,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f0fe8[i] != -1; i++) { for (i = 0; g_unk0x100f0fe8[i] != -1; i++) {
if (plantInfo[g_unk0x100f0fe8[i]].m_unk0x16) { if (plantInfo[g_unk0x100f0fe8[i]].m_counter) {
result = plantInfo[g_unk0x100f0fe8[i]].m_entity; result = plantInfo[g_unk0x100f0fe8[i]].m_entity;
break; break;
} }
@@ -828,7 +828,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f1000[i] != -1; i++) { for (i = 0; g_unk0x100f1000[i] != -1; i++) {
if (plantInfo[g_unk0x100f1000[i]].m_unk0x16) { if (plantInfo[g_unk0x100f1000[i]].m_counter) {
result = plantInfo[g_unk0x100f1000[i]].m_entity; result = plantInfo[g_unk0x100f1000[i]].m_entity;
break; break;
} }
@@ -842,7 +842,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
} }
else { else {
for (i = 0; g_unk0x100f1018[i] != -1; i++) { for (i = 0; g_unk0x100f1018[i] != -1; i++) {
if (plantInfo[g_unk0x100f1018[i]].m_unk0x16) { if (plantInfo[g_unk0x100f1018[i]].m_counter) {
result = plantInfo[g_unk0x100f1018[i]].m_entity; result = plantInfo[g_unk0x100f1018[i]].m_entity;
break; break;
} }
@@ -851,7 +851,7 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
break; break;
case 8: case 8:
for (i = 0; g_unk0x100f1030[i] != -1; i++) { for (i = 0; g_unk0x100f1030[i] != -1; i++) {
if (plantInfo[g_unk0x100f1030[i]].m_unk0x16) { if (plantInfo[g_unk0x100f1030[i]].m_counter) {
result = plantInfo[g_unk0x100f1030[i]].m_entity; result = plantInfo[g_unk0x100f1030[i]].m_entity;
break; break;
} }

View File

@@ -607,8 +607,8 @@ void Act3Brickster::Animate(float p_time)
assert(m_shootAnim && m_pInfo); assert(m_shootAnim && m_pInfo);
if (m_unk0x50 < p_time) { if (m_unk0x50 < p_time) {
while (m_pInfo->m_unk0x16) { while (m_pInfo->m_counter) {
PlantManager()->FUN_10026c50(m_pInfo->m_entity); PlantManager()->DecrementCounter(m_pInfo->m_entity);
} }
assert(SoundManager()->GetCacheSoundManager()); assert(SoundManager()->GetCacheSoundManager());

View File

@@ -31,10 +31,10 @@ const char* g_plantLodNames[4][5] = {
}; };
// GLOBAL: LEGO1 0x100f16b0 // GLOBAL: LEGO1 0x100f16b0
float g_unk0x100f16b0[] = {0.1f, 0.7f, 0.5f, 0.9f}; float g_heightPerCount[] = {0.1f, 0.7f, 0.5f, 0.9f};
// GLOBAL: LEGO1 0x100f16c0 // GLOBAL: LEGO1 0x100f16c0
MxU8 g_unk0x100f16c0[] = {1, 2, 2, 3}; MxU8 g_counters[] = {1, 2, 2, 3};
// GLOBAL: LEGO1 0x100f315c // GLOBAL: LEGO1 0x100f315c
MxU32 LegoPlantManager::g_maxSound = 8; MxU32 LegoPlantManager::g_maxSound = 8;
@@ -217,7 +217,7 @@ LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, Leg
if (p_index < sizeOfArray(g_plantInfo)) { if (p_index < sizeOfArray(g_plantInfo)) {
MxU32 world = 1 << (MxU8) p_worldId; MxU32 world = 1 << (MxU8) p_worldId;
if (g_plantInfo[p_index].m_worlds & world && g_plantInfo[p_index].m_unk0x16 != 0) { if (g_plantInfo[p_index].m_worlds & world && g_plantInfo[p_index].m_counter != 0) {
if (g_plantInfo[p_index].m_entity == NULL) { if (g_plantInfo[p_index].m_entity == NULL) {
char name[256]; char name[256];
char lodName[256]; char lodName[256];
@@ -285,7 +285,7 @@ MxResult LegoPlantManager::Write(LegoStorage* p_storage)
if (p_storage->Write(&info->m_color, sizeof(info->m_color)) != SUCCESS) { if (p_storage->Write(&info->m_color, sizeof(info->m_color)) != SUCCESS) {
goto done; goto done;
} }
if (p_storage->Write(&info->m_initialUnk0x16, sizeof(info->m_initialUnk0x16)) != SUCCESS) { if (p_storage->Write(&info->m_initialCounter, sizeof(info->m_initialCounter)) != SUCCESS) {
goto done; goto done;
} }
} }
@@ -320,12 +320,12 @@ MxResult LegoPlantManager::Read(LegoStorage* p_storage)
if (p_storage->Read(&info->m_color, sizeof(MxU8)) != SUCCESS) { if (p_storage->Read(&info->m_color, sizeof(MxU8)) != SUCCESS) {
goto done; goto done;
} }
if (p_storage->Read(&info->m_unk0x16, sizeof(MxS8)) != SUCCESS) { if (p_storage->Read(&info->m_counter, sizeof(MxS8)) != SUCCESS) {
goto done; goto done;
} }
info->m_initialUnk0x16 = info->m_unk0x16; info->m_initialCounter = info->m_counter;
FUN_10026860(i); AdjustHeight(i);
} }
result = SUCCESS; result = SUCCESS;
@@ -336,13 +336,13 @@ done:
// FUNCTION: LEGO1 0x10026860 // FUNCTION: LEGO1 0x10026860
// FUNCTION: BETA10 0x100c5be0 // FUNCTION: BETA10 0x100c5be0
void LegoPlantManager::FUN_10026860(MxS32 p_index) void LegoPlantManager::AdjustHeight(MxS32 p_index)
{ {
MxU8 variant = g_plantInfo[p_index].m_variant; MxU8 variant = g_plantInfo[p_index].m_variant;
if (g_plantInfo[p_index].m_unk0x16 >= 0) { if (g_plantInfo[p_index].m_counter >= 0) {
float value = g_unk0x100f16c0[variant] - g_plantInfo[p_index].m_unk0x16; float value = g_counters[variant] - g_plantInfo[p_index].m_counter;
g_plantInfo[p_index].m_position[1] = g_plantInfoInit[p_index].m_position[1] - value * g_unk0x100f16b0[variant]; g_plantInfo[p_index].m_position[1] = g_plantInfoInit[p_index].m_position[1] - value * g_heightPerCount[variant];
} }
else { else {
g_plantInfo[p_index].m_position[1] = g_plantInfoInit[p_index].m_position[1]; g_plantInfo[p_index].m_position[1] = g_plantInfoInit[p_index].m_position[1];
@@ -410,7 +410,7 @@ MxBool LegoPlantManager::SwitchVariant(LegoEntity* p_entity)
{ {
LegoPlantInfo* info = GetInfo(p_entity); LegoPlantInfo* info = GetInfo(p_entity);
if (info == NULL || info->m_unk0x16 != -1) { if (info == NULL || info->m_counter != -1) {
return FALSE; return FALSE;
} }
@@ -550,7 +550,7 @@ void LegoPlantManager::SetCustomizeAnimFile(const char* p_value)
// FUNCTION: LEGO1 0x10026c50 // FUNCTION: LEGO1 0x10026c50
// FUNCTION: BETA10 0x100c6349 // FUNCTION: BETA10 0x100c6349
MxBool LegoPlantManager::FUN_10026c50(LegoEntity* p_entity) MxBool LegoPlantManager::DecrementCounter(LegoEntity* p_entity)
{ {
LegoPlantInfo* info = GetInfo(p_entity); LegoPlantInfo* info = GetInfo(p_entity);
@@ -558,12 +558,12 @@ MxBool LegoPlantManager::FUN_10026c50(LegoEntity* p_entity)
return FALSE; return FALSE;
} }
return FUN_10026c80(info - g_plantInfo); return DecrementCounter(info - g_plantInfo);
} }
// FUNCTION: LEGO1 0x10026c80 // FUNCTION: LEGO1 0x10026c80
// FUNCTION: BETA10 0x100c63eb // FUNCTION: BETA10 0x100c63eb
MxBool LegoPlantManager::FUN_10026c80(MxS32 p_index) MxBool LegoPlantManager::DecrementCounter(MxS32 p_index)
{ {
if (p_index >= sizeOfArray(g_plantInfo)) { if (p_index >= sizeOfArray(g_plantInfo)) {
return FALSE; return FALSE;
@@ -577,23 +577,23 @@ MxBool LegoPlantManager::FUN_10026c80(MxS32 p_index)
MxBool result = TRUE; MxBool result = TRUE;
if (info->m_unk0x16 < 0) { if (info->m_counter < 0) {
info->m_unk0x16 = g_unk0x100f16c0[info->m_variant]; info->m_counter = g_counters[info->m_variant];
} }
if (info->m_unk0x16 > 0) { if (info->m_counter > 0) {
LegoROI* roi = info->m_entity->GetROI(); LegoROI* roi = info->m_entity->GetROI();
info->m_unk0x16--; info->m_counter--;
if (info->m_unk0x16 == 1) { if (info->m_counter == 1) {
info->m_unk0x16 = 0; info->m_counter = 0;
} }
if (info->m_unk0x16 == 0) { if (info->m_counter == 0) {
roi->SetVisibility(FALSE); roi->SetVisibility(FALSE);
} }
else { else {
FUN_10026860(info - g_plantInfo); AdjustHeight(info - g_plantInfo);
info->m_entity->SetLocation(info->m_position, info->m_direction, info->m_up, FALSE); info->m_entity->SetLocation(info->m_position, info->m_direction, info->m_up, FALSE);
} }
} }
@@ -623,7 +623,7 @@ void LegoPlantManager::ScheduleAnimation(LegoEntity* p_entity, MxLong p_length)
time += p_length; time += p_length;
entry->m_time = time + 1000; entry->m_time = time + 1000;
FUN_100271b0(p_entity, -1); AdjustCounter(p_entity, -1);
} }
// FUNCTION: LEGO1 0x10026e00 // FUNCTION: LEGO1 0x10026e00
@@ -672,11 +672,11 @@ MxResult LegoPlantManager::Tickle()
if (entry->m_time < time) { if (entry->m_time < time) {
LegoPlantInfo* info = GetInfo(entry->m_entity); LegoPlantInfo* info = GetInfo(entry->m_entity);
if (info->m_unk0x16 == 0) { if (info->m_counter == 0) {
entry->m_roi->SetVisibility(FALSE); entry->m_roi->SetVisibility(FALSE);
} }
else { else {
FUN_10026860(info - g_plantInfo); AdjustHeight(info - g_plantInfo);
info->m_entity->SetLocation(info->m_position, info->m_direction, info->m_up, FALSE); info->m_entity->SetLocation(info->m_position, info->m_direction, info->m_up, FALSE);
} }
@@ -699,14 +699,14 @@ MxResult LegoPlantManager::Tickle()
} }
// FUNCTION: LEGO1 0x10027120 // FUNCTION: LEGO1 0x10027120
void LegoPlantManager::FUN_10027120() void LegoPlantManager::ClearCounters()
{ {
LegoWorld* world = CurrentWorld(); LegoWorld* world = CurrentWorld();
for (MxS32 i = 0; i < sizeOfArray(g_plantInfo); i++) { for (MxS32 i = 0; i < sizeOfArray(g_plantInfo); i++) {
g_plantInfo[i].m_unk0x16 = -1; g_plantInfo[i].m_counter = -1;
g_plantInfo[i].m_initialUnk0x16 = -1; g_plantInfo[i].m_initialCounter = -1;
FUN_10026860(i); AdjustHeight(i);
if (g_plantInfo[i].m_entity != NULL) { if (g_plantInfo[i].m_entity != NULL) {
g_plantInfo[i].m_entity->SetLocation( g_plantInfo[i].m_entity->SetLocation(
@@ -720,28 +720,28 @@ void LegoPlantManager::FUN_10027120()
} }
// FUNCTION: LEGO1 0x100271b0 // FUNCTION: LEGO1 0x100271b0
void LegoPlantManager::FUN_100271b0(LegoEntity* p_entity, MxS32 p_adjust) void LegoPlantManager::AdjustCounter(LegoEntity* p_entity, MxS32 p_adjust)
{ {
LegoPlantInfo* info = GetInfo(p_entity); LegoPlantInfo* info = GetInfo(p_entity);
if (info != NULL) { if (info != NULL) {
if (info->m_unk0x16 < 0) { if (info->m_counter < 0) {
info->m_unk0x16 = g_unk0x100f16c0[info->m_variant]; info->m_counter = g_counters[info->m_variant];
} }
if (info->m_unk0x16 > 0) { if (info->m_counter > 0) {
info->m_unk0x16 += p_adjust; info->m_counter += p_adjust;
if (info->m_unk0x16 <= 1 && p_adjust < 0) { if (info->m_counter <= 1 && p_adjust < 0) {
info->m_unk0x16 = 0; info->m_counter = 0;
} }
} }
} }
} }
// FUNCTION: LEGO1 0x10027200 // FUNCTION: LEGO1 0x10027200
void LegoPlantManager::FUN_10027200() void LegoPlantManager::SetInitialCounters()
{ {
for (MxU32 i = 0; i < sizeOfArray(g_plantInfo); i++) { for (MxU32 i = 0; i < sizeOfArray(g_plantInfo); i++) {
g_plantInfo[i].m_initialUnk0x16 = g_plantInfo[i].m_unk0x16; g_plantInfo[i].m_initialCounter = g_plantInfo[i].m_counter;
} }
} }

View File

@@ -500,7 +500,7 @@ MxLong LegoEntity::Notify(MxParam& p_param)
case e_unk1: case e_unk1:
break; break;
case e_plant: case e_plant:
PlantManager()->FUN_10026c50(this); PlantManager()->DecrementCounter(this);
break; break;
case e_building: case e_building:
BuildingManager()->FUN_10030000(this); BuildingManager()->FUN_10030000(this);

View File

@@ -664,7 +664,7 @@ MxLong Act3::HandleTransitionEnd()
// FUNCTION: LEGO1 0x10073270 // FUNCTION: LEGO1 0x10073270
void Act3::ReadyWorld() void Act3::ReadyWorld()
{ {
PlantManager()->FUN_10027200(); PlantManager()->SetInitialCounters();
BuildingManager()->FUN_10030800(); BuildingManager()->FUN_10030800();
AnimationManager()->FUN_1005f6d0(FALSE); AnimationManager()->FUN_1005f6d0(FALSE);
VideoManager()->Get3DManager()->SetFrustrum(90.0f, 0.1f, 125.0f); VideoManager()->Get3DManager()->SetFrustrum(90.0f, 0.1f, 125.0f);

View File

@@ -1385,7 +1385,7 @@ void Infocenter::Reset()
break; break;
} }
PlantManager()->FUN_10027120(); PlantManager()->ClearCounters();
BuildingManager()->FUN_10030590(); BuildingManager()->FUN_10030590();
AnimationManager()->Reset(FALSE); AnimationManager()->Reset(FALSE);
CharacterManager()->ReleaseAllActors(); CharacterManager()->ReleaseAllActors();