Add LegoOmni::World enum (#1252)

This commit is contained in:
Christian Semmler 2024-12-21 10:08:55 -07:00 committed by GitHub
parent 3e427ab03e
commit bcc41256f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 93 additions and 70 deletions

View File

@ -3,6 +3,7 @@
#include "decomp.h"
#include "legolocations.h"
#include "legomain.h"
#include "legostate.h"
#include "legotraninfolist.h"
#include "mxcore.h"
@ -151,7 +152,7 @@ public:
void Resume();
void FUN_1005f6d0(MxBool p_unk0x400);
void EnableCamAnims(MxBool p_enableCamAnims);
MxResult LoadWorldInfo(MxS32 p_worldId);
MxResult LoadWorldInfo(LegoOmni::World p_worldId);
MxBool FindVehicle(const char* p_name, MxU32& p_index);
MxResult ReadAnimInfo(LegoFile* p_file, AnimInfo* p_info);
MxResult ReadModelInfo(LegoFile* p_file, ModelInfo* p_info);
@ -247,7 +248,7 @@ private:
void FUN_100648f0(LegoTranInfo* p_tranInfo, MxLong p_unk0x404);
void FUN_10064b50(MxLong p_time);
MxS32 m_worldId; // 0x08
LegoOmni::World m_worldId; // 0x08
MxU16 m_animCount; // 0x0c
MxU16 m_unk0x0e; // 0x0e
MxU16 m_unk0x10; // 0x10

View File

@ -37,16 +37,39 @@ public:
c_clearScreen = 0x04
};
enum World {
e_undefined = -1,
e_act1 = 0,
e_imain,
e_icube,
e_ireg,
e_ielev,
e_iisle,
e_hosp,
e_police,
e_gmain,
e_bldh,
e_bldd,
e_bldj,
e_bldr,
e_racc,
e_racj,
e_act2,
e_act3,
e_test,
e_numWorlds = e_test + 2 // count e_undefined
};
// SIZE 0x1c
struct WorldContainer {
// FUNCTION: LEGO1 0x1005ac40
WorldContainer()
{
m_id = -1;
m_id = e_undefined;
m_atomId = NULL;
}
WorldContainer(MxS32 p_id, const char* p_key, MxAtomId* p_atomId)
WorldContainer(World p_id, const char* p_key, MxAtomId* p_atomId)
{
m_id = p_id;
@ -66,10 +89,10 @@ public:
return *this;
}
MxS32 GetId() { return m_id; }
World GetId() { return m_id; }
const char* GetKey() { return m_key; }
MxS32 m_id; // 0x00
World m_id; // 0x00
char m_key[20]; // 0x04
MxAtomId* m_atomId; // 0x18
};
@ -111,9 +134,9 @@ public:
void CreateBackgroundAudio();
void RemoveWorld(const MxAtomId& p_atom, MxLong p_objectId);
MxResult RegisterWorlds();
const char* GetWorldName(MxU32 p_id);
MxAtomId* GetWorldAtom(MxU32 p_id);
MxS32 GetWorldId(const char* p_key);
const char* GetWorldName(LegoOmni::World p_id);
MxAtomId* GetWorldAtom(LegoOmni::World p_id);
World GetWorldId(const char* p_key);
void DeleteAction();
static MxS32 GetCurrPathInfo(LegoPathBoundary**, MxS32&);

View File

@ -2,6 +2,7 @@
#define LEGOPLANTMANAGER_H
#include "decomp.h"
#include "legomain.h"
#include "mxcore.h"
class LegoEntity;
@ -35,8 +36,8 @@ public:
}
void Init();
void LoadWorldInfo(MxS32 p_worldId);
void Reset(MxS32 p_worldId);
void LoadWorldInfo(LegoOmni::World p_worldId);
void Reset(LegoOmni::World p_worldId);
MxResult Write(LegoStorage* p_storage);
MxResult Read(LegoStorage* p_storage);
MxBool SwitchColor(LegoEntity* p_entity);
@ -60,8 +61,8 @@ public:
// LegoPlantManager::`scalar deleting destructor'
private:
LegoEntity* CreatePlant(MxS32 p_index, LegoWorld* p_world, MxS32 p_worldId);
void RemovePlant(MxS32 p_index, MxS32 p_worldId);
LegoEntity* CreatePlant(MxS32 p_index, LegoWorld* p_world, LegoOmni::World p_worldId);
void RemovePlant(MxS32 p_index, LegoOmni::World p_worldId);
void FUN_10026860(MxS32 p_index);
LegoPlantInfo* GetInfo(LegoEntity* p_entity);
MxBool FUN_10026c80(MxS32 p_index);
@ -71,11 +72,11 @@ private:
static MxS32 g_maxMove[4];
static MxU32 g_maxSound;
MxS32 m_worldId; // 0x08
undefined m_unk0x0c; // 0x0c
AnimEntry* m_entries[5]; // 0x10
MxS8 m_numEntries; // 0x24
LegoWorld* m_world; // 0x28
LegoOmni::World m_worldId; // 0x08
undefined m_unk0x0c; // 0x0c
AnimEntry* m_entries[5]; // 0x10
MxS8 m_numEntries; // 0x24
LegoWorld* m_world; // 0x28
};
#endif // LEGOPLANTMANAGER_H

View File

@ -2,6 +2,7 @@
#define LEGOWORLD_H
#include "legoentity.h"
#include "legomain.h"
#include "legopathcontrollerlist.h"
#include "mxpresenterlist.h"
#include "roi/legoroi.h"
@ -104,12 +105,12 @@ public:
LegoCameraController* GetCamera() { return m_cameraController; }
LegoEntityList* GetEntityList() { return m_entityList; }
MxS32 GetWorldId() { return m_worldId; }
LegoOmni::World GetWorldId() { return m_worldId; }
MxBool GetUnknown0xd0Empty() { return m_set0xd0.empty(); }
list<LegoROI*>& GetROIList() { return m_roiList; }
LegoHideAnimPresenter* GetHideAnimPresenter() { return m_hideAnim; }
void SetWorldId(MxS32 p_worldId) { m_worldId = p_worldId; }
void SetWorldId(LegoOmni::World p_worldId) { m_worldId = p_worldId; }
// SYNTHETIC: LEGO1 0x1001dee0
// LegoWorld::`scalar deleting destructor'
@ -125,7 +126,7 @@ protected:
MxPresenterList m_controlPresenters; // 0xb8
MxCoreSet m_set0xd0; // 0xd0
list<LegoROI*> m_roiList; // 0xe0
MxS32 m_worldId; // 0xec
LegoOmni::World m_worldId; // 0xec
// name verified by BETA10 0x100c7f59
LegoHideAnimPresenter* m_hideAnim; // 0xf0

View File

@ -416,7 +416,7 @@ void LegoAnimationManager::Suspend()
m_animState = (AnimState*) GameState()->CreateState("AnimState");
}
if (m_worldId == 0) {
if (m_worldId == LegoOmni::e_act1) {
m_animState->InitFromAnims(m_animCount, m_anims, m_lastExtraCharacterId);
}
@ -495,7 +495,7 @@ void LegoAnimationManager::Resume()
void LegoAnimationManager::Init()
{
m_unk0x402 = FALSE;
m_worldId = -1;
m_worldId = LegoOmni::e_undefined;
m_animCount = 0;
m_anims = NULL;
m_unk0x18 = 0;
@ -580,7 +580,7 @@ void LegoAnimationManager::EnableCamAnims(MxBool p_enableCamAnims)
}
// FUNCTION: LEGO1 0x1005f720
MxResult LegoAnimationManager::LoadWorldInfo(MxS32 p_worldId)
MxResult LegoAnimationManager::LoadWorldInfo(LegoOmni::World p_worldId)
{
MxResult result = FAILURE;
MxS32 i, j, k;
@ -615,7 +615,7 @@ MxResult LegoAnimationManager::LoadWorldInfo(MxS32 p_worldId)
m_animState = (AnimState*) GameState()->CreateState("AnimState");
}
if (m_worldId == 0) {
if (m_worldId == LegoOmni::e_act1) {
m_animState->InitFromAnims(m_animCount, m_anims, m_lastExtraCharacterId);
}
@ -623,7 +623,7 @@ MxResult LegoAnimationManager::LoadWorldInfo(MxS32 p_worldId)
LegoFile file;
if (p_worldId == -1) {
if (p_worldId == LegoOmni::e_undefined) {
result = SUCCESS;
goto done;
}
@ -961,7 +961,7 @@ MxResult LegoAnimationManager::FUN_100605e0(
{
MxResult result = FAILURE;
if (m_worldId != -1 && p_index < m_animCount && m_tranInfoList != NULL) {
if (m_worldId != LegoOmni::e_undefined && p_index < m_animCount && m_tranInfoList != NULL) {
PurgeExtra(FALSE);
FUN_10062770();

View File

@ -78,14 +78,14 @@ void LegoPlantManager::Init()
g_plantInfo[i] = g_plantInfoInit[i];
}
m_worldId = -1;
m_worldId = LegoOmni::e_undefined;
m_unk0x0c = 0;
m_numEntries = 0;
}
// FUNCTION: LEGO1 0x10026360
// FUNCTION: BETA10 0x100c5032
void LegoPlantManager::LoadWorldInfo(MxS32 p_worldId)
void LegoPlantManager::LoadWorldInfo(LegoOmni::World p_worldId)
{
m_worldId = p_worldId;
LegoWorld* world = CurrentWorld();
@ -98,7 +98,7 @@ void LegoPlantManager::LoadWorldInfo(MxS32 p_worldId)
}
// FUNCTION: LEGO1 0x100263a0
void LegoPlantManager::Reset(MxS32 p_worldId)
void LegoPlantManager::Reset(LegoOmni::World p_worldId)
{
MxU32 i;
DeleteObjects(g_sndAnimScript, SndanimScript::c_AnimC1, SndanimScript::c_AnimBld18);
@ -113,7 +113,7 @@ void LegoPlantManager::Reset(MxS32 p_worldId)
RemovePlant(i, p_worldId);
}
m_worldId = -1;
m_worldId = LegoOmni::e_undefined;
m_unk0x0c = 0;
}
@ -205,7 +205,7 @@ LegoPlantInfo* LegoPlantManager::GetInfoArray(MxS32& p_length)
// FUNCTION: LEGO1 0x10026590
// FUNCTION: BETA10 0x100c561e
LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, MxS32 p_worldId)
LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, LegoOmni::World p_worldId)
{
LegoEntity* entity = NULL;
@ -244,7 +244,7 @@ LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, MxS
// FUNCTION: LEGO1 0x100266c0
// FUNCTION: BETA10 0x100c5859
void LegoPlantManager::RemovePlant(MxS32 p_index, MxS32 p_worldId)
void LegoPlantManager::RemovePlant(MxS32 p_index, LegoOmni::World p_worldId)
{
if (p_index < sizeOfArray(g_plantInfo)) {
MxU32 world = 1 << (MxU8) p_worldId;

View File

@ -12,7 +12,6 @@
#include "legogamestate.h"
#include "legoinputmanager.h"
#include "legolocomotionanimpresenter.h"
#include "legomain.h"
#include "legonavcontroller.h"
#include "legoplantmanager.h"
#include "legosoundmanager.h"
@ -102,8 +101,7 @@ MxResult LegoWorld::Create(MxDSAction& p_dsAction)
}
SetIsWorldActive(TRUE);
m_worldId = -1;
m_worldId = LegoOmni::e_undefined;
return SUCCESS;
}
@ -180,7 +178,7 @@ void LegoWorld::Destroy(MxBool p_fromDestructor)
}
}
if (m_worldId != -1 && m_set0xd0.empty()) {
if (m_worldId != LegoOmni::e_undefined && m_set0xd0.empty()) {
PlantManager()->Reset(m_worldId);
BuildingManager()->Reset();
}
@ -701,7 +699,7 @@ void LegoWorld::Enable(MxBool p_enable)
Lego()->SetNavController(m_cameraController->GetNavController());
}
if (m_worldId != -1) {
if (m_worldId != LegoOmni::e_undefined) {
PlantManager()->LoadWorldInfo(m_worldId);
AnimationManager()->LoadWorldInfo(m_worldId);
BuildingManager()->LoadWorldInfo();
@ -724,7 +722,7 @@ void LegoWorld::Enable(MxBool p_enable)
AnimationManager()->Reset(FALSE);
m_set0xd0.insert(this);
if (m_worldId != -1) {
if (m_worldId != LegoOmni::e_undefined) {
PlantManager()->Reset(m_worldId);
BuildingManager()->Reset();
}

View File

@ -54,7 +54,7 @@ LegoWorldPresenter::~LegoWorldPresenter()
{
MxBool result = FALSE;
if (m_entity) {
MxS32 worldId = ((LegoWorld*) m_entity)->GetWorldId();
LegoOmni::World worldId = ((LegoWorld*) m_entity)->GetWorldId();
PlantManager()->LoadWorldInfo(worldId);
AnimationManager()->LoadWorldInfo(worldId);
BuildingManager()->LoadWorldInfo();

View File

@ -266,32 +266,31 @@ done:
// FUNCTION: LEGO1 0x1005a5f0
MxResult LegoOmni::RegisterWorlds()
{
m_worlds = new WorldContainer[19];
m_worlds = new WorldContainer[e_numWorlds];
if (!m_worlds) {
return FAILURE;
}
m_worlds[0] = WorldContainer();
m_worlds[1] = WorldContainer(0, "ACT1", g_isleScript);
m_worlds[2] = WorldContainer(1, "IMAIN", g_infomainScript);
m_worlds[3] = WorldContainer(2, "ICUBE", g_infoscorScript);
m_worlds[4] = WorldContainer(3, "IREG", g_regbookScript);
m_worlds[5] = WorldContainer(4, "IELEV", g_elevbottScript);
m_worlds[6] = WorldContainer(5, "IISLE", g_infodoorScript);
m_worlds[7] = WorldContainer(6, "HOSP", g_hospitalScript);
m_worlds[8] = WorldContainer(7, "POLICE", g_policeScript);
m_worlds[9] = WorldContainer(8, "GMAIN", g_garageScript);
m_worlds[10] = WorldContainer(9, "BLDH", g_copterScript);
m_worlds[11] = WorldContainer(10, "BLDD", g_dunecarScript);
m_worlds[12] = WorldContainer(11, "BLDJ", g_jetskiScript);
m_worlds[13] = WorldContainer(12, "BLDR", g_racecarScript);
m_worlds[14] = WorldContainer(13, "RACC", g_carraceScript);
m_worlds[15] = WorldContainer(14, "RACJ", g_jetraceScript);
m_worlds[16] = WorldContainer(15, "ACT2", g_act2mainScript);
m_worlds[17] = WorldContainer(16, "ACT3", g_act3Script);
m_worlds[18] = WorldContainer(17, "TEST", g_testScript);
m_worlds[1] = WorldContainer(e_act1, "ACT1", g_isleScript);
m_worlds[2] = WorldContainer(e_imain, "IMAIN", g_infomainScript);
m_worlds[3] = WorldContainer(e_icube, "ICUBE", g_infoscorScript);
m_worlds[4] = WorldContainer(e_ireg, "IREG", g_regbookScript);
m_worlds[5] = WorldContainer(e_ielev, "IELEV", g_elevbottScript);
m_worlds[6] = WorldContainer(e_iisle, "IISLE", g_infodoorScript);
m_worlds[7] = WorldContainer(e_hosp, "HOSP", g_hospitalScript);
m_worlds[8] = WorldContainer(e_police, "POLICE", g_policeScript);
m_worlds[9] = WorldContainer(e_gmain, "GMAIN", g_garageScript);
m_worlds[10] = WorldContainer(e_bldh, "BLDH", g_copterScript);
m_worlds[11] = WorldContainer(e_bldd, "BLDD", g_dunecarScript);
m_worlds[12] = WorldContainer(e_bldj, "BLDJ", g_jetskiScript);
m_worlds[13] = WorldContainer(e_bldr, "BLDR", g_racecarScript);
m_worlds[14] = WorldContainer(e_racc, "RACC", g_carraceScript);
m_worlds[15] = WorldContainer(e_racj, "RACJ", g_jetraceScript);
m_worlds[16] = WorldContainer(e_act2, "ACT2", g_act2mainScript);
m_worlds[17] = WorldContainer(e_act3, "ACT3", g_act3Script);
m_worlds[18] = WorldContainer(e_test, "TEST", g_testScript);
return SUCCESS;
}
@ -476,10 +475,10 @@ MxS32 LegoOmni::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value)
}
// FUNCTION: LEGO1 0x1005b430
const char* LegoOmni::GetWorldName(MxU32 p_id)
const char* LegoOmni::GetWorldName(LegoOmni::World p_worldId)
{
for (MxS32 i = 0; i < 19; i++) {
if (m_worlds[i].m_id == p_id) {
for (MxS32 i = 0; i < e_numWorlds; i++) {
if (m_worlds[i].m_id == p_worldId) {
return m_worlds[i].m_key;
}
}
@ -489,10 +488,10 @@ const char* LegoOmni::GetWorldName(MxU32 p_id)
// FUNCTION: LEGO1 0x1005b460
// FUNCTION: BETA10 0x1008edd8
MxAtomId* LegoOmni::GetWorldAtom(MxU32 p_id)
MxAtomId* LegoOmni::GetWorldAtom(LegoOmni::World p_worldId)
{
for (MxS32 i = 0; i < 19; i++) {
if (m_worlds[i].m_id == p_id) {
for (MxS32 i = 0; i < e_numWorlds; i++) {
if (m_worlds[i].m_id == p_worldId) {
return m_worlds[i].m_atomId;
}
}
@ -503,15 +502,15 @@ MxAtomId* LegoOmni::GetWorldAtom(MxU32 p_id)
}
// FUNCTION: LEGO1 0x1005b490
MxS32 LegoOmni::GetWorldId(const char* p_key)
LegoOmni::World LegoOmni::GetWorldId(const char* p_key)
{
for (MxS32 i = 0; i < 19; i++) {
for (MxS32 i = 0; i < e_numWorlds; i++) {
if ((MxS32) &m_worlds[i] != -4 && !strcmpi(m_worlds[i].GetKey(), p_key)) {
return m_worlds[i].GetId();
}
}
return -1;
return e_undefined;
}
// FUNCTION: LEGO1 0x1005b4f0

View File

@ -1111,7 +1111,7 @@ MxResult LegoAct2::FUN_10052560(
action.SetObjectId(p_objectId);
// World index: see LegoOmni::RegisterWorlds
action.SetAtomId(*Lego()->GetWorldAtom(15));
action.SetAtomId(*Lego()->GetWorldAtom(LegoOmni::e_act2));
if (p_location) {
action.SetUp(Mx3DPointFloat(0.0f, 1.0f, 0.0f));