Isle
Loading...
Searching...
No Matches
LegoGameState Class Reference

Comprehensive persistent game state manager: handles save/load, player selection, area switching, and score history. More...

#include <legogamestate.h>

Collaboration diagram for LegoGameState:

Classes

struct  History
 Collection of best scores for all recent plays/players (high score table). More...
 
struct  ScoreItem
 Single score record for a player, including high score grids for all major games. More...
 
struct  Username
 Player "username", stored as 7 short integers (character codes). More...
 

Public Types

enum  Act { e_actNotFound = -1 , e_act1 , e_act2 , e_act3 }
 Indicates which main storyline section (Act 1/2/3) is currently active. More...
 
enum  Area {
  e_undefined = 0 , e_previousArea = 0 , e_isle , e_infomain ,
  e_infodoor , e_unk4 , e_elevbott , e_elevride ,
  e_elevride2 , e_elevopen , e_seaview , e_observe ,
  e_elevdown , e_regbook , e_infoscor , e_jetrace ,
  e_jetrace2 , e_jetraceExterior , e_unk17 , e_carrace ,
  e_carraceExterior , e_unk20 , e_unk21 , e_pizzeriaExterior ,
  e_unk23 , e_unk24 , e_garageExterior , e_garage ,
  e_garadoor , e_unk28 , e_hospitalExterior , e_hospital ,
  e_unk31 , e_policeExterior , e_unk33 , e_police ,
  e_polidoor , e_copterbuild , e_dunecarbuild , e_jetskibuild ,
  e_racecarbuild , e_unk40 , e_unk41 , e_unk42 ,
  e_unk43 , e_unk44 , e_unk45 , e_act2main ,
  e_act3script , e_unk48 , e_unk49 , e_unk50 ,
  e_unk51 , e_unk52 , e_jukeboxw , e_jukeboxExterior ,
  e_unk55 , e_histbook , e_bike , e_dunecar ,
  e_motocycle , e_copter , e_skateboard , e_ambulance ,
  e_towtrack , e_jetski , e_unk66 = 66
}
 Enumeration of all major in-game locations ("areas") for area/scene management and serialization. More...
 

Public Member Functions

 LegoGameState ()
 
 ~LegoGameState ()
 
void SetActor (MxU8 p_actorId)
 Change the player character in the world to the given actor ID. More...
 
void RemoveActor ()
 Removes (and deletes) the current user actor from the world. More...
 
void ResetROI ()
 Re-applies the current actor's ROI to the 3D world (remove/add for update). [AI]. More...
 
MxResult Save (MxULong p_slot)
 Saves persistent game state (world variables, actor, etc.) to a file slot. More...
 
MxResult DeleteState ()
 Destroys and removes all current state objects, freeing memory and unregistering. [AI]. More...
 
MxResult Load (MxULong p_slot)
 Loads persistent game state from specified save slot. More...
 
void SerializePlayersInfo (MxS16 p_flags)
 Serializes all player info (usernames, player count) to the appropriate storage. More...
 
MxResult AddPlayer (Username &p_player)
 Adds a new player (username), moves others down, manages slot files. More...
 
void SwitchPlayer (MxS16 p_playerId)
 Make the specified player (by ID/index) the current player. More...
 
MxS16 FindPlayer (Username &p_player)
 Finds the player index for a username; returns -1 if not found. More...
 
void SerializeScoreHistory (MxS16 p_flags)
 Serializes the score history table to score file. More...
 
void SetSavePath (char *p_savePath)
 Sets the path for current save slot directory; creates a copy of input string. More...
 
LegoStateGetState (const char *p_stateName)
 Find an existing state (LegoState-derived) object by its registered script/class name. More...
 
LegoStateCreateState (const char *p_stateName)
 Creates an instance of given state, registers it, and returns pointer. More...
 
void GetFileSavePath (MxString *p_outPath, MxS16 p_slotn)
 Writes the full save path for the given slot to the output string object. More...
 
void StopArea (Area p_area)
 Calls cleanup logic for the specified area (removes actors, VMs, closes handles, etc.). More...
 
void SwitchArea (Area p_area)
 Switches the whole game state into a new area/world; manages transitions/scene loads. More...
 
void Init ()
 Re-initializes all world/variable state to the current act's defaults. [AI]. More...
 
MxU8 GetActorId ()
 Returns the current selected actor ID. [AI]. More...
 
const char * GetActorName ()
 Returns the actor name, based on the current actor ID. [AI]. More...
 
Act GetCurrentAct ()
 Returns the active act that is currently in play. [AI]. More...
 
Act GetLoadedAct ()
 Returns the act that is currently loaded in memory. [AI]. More...
 
Area GetPreviousArea ()
 Gets the last area before the current one. [AI]. More...
 
Area GetUnknown0x42c ()
 Gets the value of m_unk0x42c (used for act area save/load mechanics). [AI]. More...
 
void SetDirty (MxBool p_isDirty)
 Sets whether there are unsaved changes to the state. More...
 
void SetPreviousArea (Area p_previousArea)
 Sets the previous area for reload/stop logic. More...
 
void SetActorId (MxU8 p_actorId)
 Directly sets the current actor ID (preferred: use SetActor). More...
 
UsernameGetPlayersIndex (MxS32 p_index)
 Gets a pointer to a player username in the array by index. More...
 
MxS16 GetPlayerCount ()
 Gets the number of player slots currently used. [AI]. More...
 
LegoBackgroundColorGetBackgroundColor ()
 Gets the main background color variable object. [AI]. More...
 
void SetCurrentAct (Act p_currentAct)
 Sets the current game act. More...
 
void FindLoadedAct ()
 Analyses the loaded Lego worlds to determine which act is present. [AI]. More...
 
void RegisterState (LegoState *p_state)
 Registers a state object, replacing by class if already present. More...
 

Public Attributes

MxS16 m_unk0x24
 Serial/generation marker used for score records. [AI]. More...
 
MxS16 m_playerCount
 Number of player usernames registered. [AI]. More...
 
Username m_players [9]
 Array of all known player usernames (max 9, ranked). [AI]. More...
 
History m_history
 High score table/history for current game. [AI]. More...
 
undefined2 m_unk0x41a
 Unknown (padding or unused). [AI]. More...
 
JukeboxScript::Script m_jukeboxMusic
 Which jukebox music is currently set to play. [AI]. More...
 
MxBool m_isDirty
 TRUE if unsaved changes present. [AI]. More...
 
Area m_currentArea
 Area/world the player is presently in. [AI]. More...
 
Area m_previousArea
 Where player was before last area switch. [AI]. More...
 
Area m_unk0x42c
 Used for act area storage on save/load. [AI]. More...
 

Detailed Description

Comprehensive persistent game state manager: handles save/load, player selection, area switching, and score history.

[AI] Manages most variables for current player session, stored data, background color, player info and area/act state. [AI]

Definition at line 78 of file legogamestate.h.

Member Enumeration Documentation

◆ Act

Indicates which main storyline section (Act 1/2/3) is currently active.

[AI]

Enumerator
e_actNotFound 

No act currently loaded (does not correspond to valid play). [AI].

e_act1 

Act 1: the first main segment of the game. [AI].

e_act2 

Act 2: main story segment two. [AI].

e_act3 

Act 3: final main story segment. [AI].

Definition at line 82 of file legogamestate.h.

◆ Area

Enumeration of all major in-game locations ("areas") for area/scene management and serialization.

[AI] Used for switching large "world" states in engine. Some are unused/unknown. [AI]

Enumerator
e_undefined 

Undefined or unset area. [AI].

e_previousArea 

Alias: go to previous area. [AI].

e_isle 

Open world (LEGO Island main map). [AI].

e_infomain 

Information Center, main screen. [AI].

e_infodoor 

Info Center door/title view. [AI].

e_unk4 

Unknown / possibly reserved. [AI].

e_elevbott 

Elevator bottom. [AI].

e_elevride 

Elevator ride/cab up (animated). [AI].

e_elevride2 

Elevator ride/cab down (animated). [AI].

e_elevopen 

Elevator doors open. [AI].

e_seaview 

Ocean-side view at observatory. [AI].

e_observe 

Observatory interior. [AI].

e_elevdown 

Elevator moving down (animated). [AI].

e_regbook 

Registration book "new game" area. [AI].

e_infoscor 

Info Center hi-score area. [AI].

e_jetrace 

Jetski race area, "interior"/main. [AI].

e_jetrace2 

Jetski race (exterior). [AI].

e_jetraceExterior 

Jetski race transition? [AI].

e_unk17 

Unknown. [AI].

e_carrace 

Car race (track, main). [AI].

e_carraceExterior 

Car race exterior/transition. [AI].

e_unk20 

Unknown [AI].

e_unk21 

Unknown [AI].

e_pizzeriaExterior 

Pizzeria, seen from outside. [AI].

e_unk23 

Unknown [AI].

e_unk24 

Unknown [AI].

e_garageExterior 

Garage (vehicle construction) exterior. [AI].

e_garage 

Garage (build vehicle) interior. [AI].

e_garadoor 

Garage door or doorway. [AI].

e_unk28 

Used for certain spawn locations. [AI].

e_hospitalExterior 

Hospital, seen from outside. [AI].

e_hospital 

Hospital interior. [AI].

e_unk31 

Unknown [AI].

e_policeExterior 

Police Station, from outside. [AI].

e_unk33 

Used for certain player spawns. [AI].

e_police 

Police Station interior. [AI].

e_polidoor 

Police Station door. [AI].

e_copterbuild 

Vehicle construction: helicopter. [AI].

e_dunecarbuild 

Vehicle construction: dune buggy. [AI].

e_jetskibuild 

Vehicle construction: jetski. [AI].

e_racecarbuild 

Vehicle construction: racecar. [AI].

e_unk40 

Unknown [AI].

e_unk41 

Unknown [AI].

e_unk42 

Unknown [AI].

e_unk43 

Unknown [AI].

e_unk44 

Unknown [AI].

e_unk45 

Unknown [AI].

e_act2main 

Act 2 world main screen. [AI].

e_act3script 

Act 3 world/script main. [AI].

e_unk48 

Unknown [AI].

e_unk49 

Unknown [AI].

e_unk50 

Unknown [AI].

e_unk51 

Unknown [AI].

e_unk52 

Unknown [AI].

e_jukeboxw 

Western Jukebox (special minigame). [AI].

e_jukeboxExterior 

Jukebox, seen from outside. [AI].

e_unk55 

Unknown [AI].

e_histbook 

History book (scoreboard). [AI].

e_bike 

Bike minigame (spawns). [AI].

e_dunecar 

Dune buggy (vehicle, for spawn). [AI].

e_motocycle 

Motorcycle (vehicle, spawn). [AI].

e_copter 

Helicopter (vehicle, spawn). [AI].

e_skateboard 

Skateboard (vehicle, spawn). [AI].

e_ambulance 

Ambulance (vehicle, spawn). [AI].

e_towtrack 

Towtruck (vehicle, spawn). [AI].

e_jetski 

Jetski (vehicle, spawn). [AI].

e_unk66 

Used for some spawn locations. [AI].

Definition at line 92 of file legogamestate.h.

Constructor & Destructor Documentation

◆ LegoGameState()

LegoGameState::LegoGameState ( )

Definition at line 145 of file legogamestate.cpp.

◆ ~LegoGameState()

LegoGameState::~LegoGameState ( )

Definition at line 177 of file legogamestate.cpp.

Member Function Documentation

◆ AddPlayer()

MxResult LegoGameState::AddPlayer ( Username p_player)

Adds a new player (username), moves others down, manages slot files.

[AI] Truncates to 9, maintaining latest player in top slot. [AI]

Parameters
p_playerUsername to add. [AI]

Definition at line 599 of file legogamestate.cpp.

◆ CreateState()

LegoState * LegoGameState::CreateState ( const char *  p_stateName)

Creates an instance of given state, registers it, and returns pointer.

[AI]

Parameters
p_stateNameName to instantiate. [AI]

Definition at line 1103 of file legogamestate.cpp.

◆ DeleteState()

MxResult LegoGameState::DeleteState ( )

Destroys and removes all current state objects, freeing memory and unregistering. [AI].

Definition at line 326 of file legogamestate.cpp.

◆ FindLoadedAct()

void LegoGameState::FindLoadedAct ( )

Analyses the loaded Lego worlds to determine which act is present. [AI].

Definition at line 1593 of file legogamestate.cpp.

◆ FindPlayer()

MxS16 LegoGameState::FindPlayer ( Username p_player)

Finds the player index for a username; returns -1 if not found.

[AI]

Parameters
p_playerUsername to check. [AI]
Returns
Index in m_players array, or -1. [AI]

Definition at line 658 of file legogamestate.cpp.

◆ GetActorId()

MxU8 LegoGameState::GetActorId ( )
inline

Returns the current selected actor ID. [AI].

Definition at line 299 of file legogamestate.h.

◆ GetActorName()

const char * LegoGameState::GetActorName ( )
inline

Returns the actor name, based on the current actor ID. [AI].

Definition at line 302 of file legogamestate.h.

◆ GetBackgroundColor()

LegoBackgroundColor * LegoGameState::GetBackgroundColor ( )
inline

Gets the main background color variable object. [AI].

Definition at line 334 of file legogamestate.h.

◆ GetCurrentAct()

Act LegoGameState::GetCurrentAct ( )
inline

Returns the active act that is currently in play. [AI].

Definition at line 305 of file legogamestate.h.

◆ GetFileSavePath()

void LegoGameState::GetFileSavePath ( MxString p_outPath,
MxS16  p_slotn 
)

Writes the full save path for the given slot to the output string object.

[AI]

Parameters
p_outPathMxString to write resulting file path to. [AI]
p_slotnSlot index (0-9). [AI]

Definition at line 555 of file legogamestate.cpp.

◆ GetLoadedAct()

Act LegoGameState::GetLoadedAct ( )
inline

Returns the act that is currently loaded in memory. [AI].

Definition at line 308 of file legogamestate.h.

◆ GetPlayerCount()

MxS16 LegoGameState::GetPlayerCount ( )
inline

Gets the number of player slots currently used. [AI].

Definition at line 331 of file legogamestate.h.

◆ GetPlayersIndex()

Username * LegoGameState::GetPlayersIndex ( MxS32  p_index)
inline

Gets a pointer to a player username in the array by index.

[AI]

Parameters
p_indexIndex into m_players. [AI]

Definition at line 328 of file legogamestate.h.

◆ GetPreviousArea()

Area LegoGameState::GetPreviousArea ( )
inline

Gets the last area before the current one. [AI].

Definition at line 310 of file legogamestate.h.

◆ GetState()

LegoState * LegoGameState::GetState ( const char *  p_stateName)

Find an existing state (LegoState-derived) object by its registered script/class name.

[AI]

Parameters
p_stateNameString identifying the state class. [AI]

Definition at line 1091 of file legogamestate.cpp.

◆ GetUnknown0x42c()

Area LegoGameState::GetUnknown0x42c ( )
inline

Gets the value of m_unk0x42c (used for act area save/load mechanics). [AI].

Definition at line 312 of file legogamestate.h.

◆ Init()

void LegoGameState::Init ( )

Re-initializes all world/variable state to the current act's defaults. [AI].

Definition at line 1143 of file legogamestate.cpp.

◆ Load()

MxResult LegoGameState::Load ( MxULong  p_slot)

Loads persistent game state from specified save slot.

[AI]

Parameters
p_slotSave slot index to load. [AI]

Definition at line 350 of file legogamestate.cpp.

◆ RegisterState()

void LegoGameState::RegisterState ( LegoState p_state)

Registers a state object, replacing by class if already present.

[AI]

Parameters
p_statePointer to a LegoState to register. [AI]

Definition at line 1116 of file legogamestate.cpp.

◆ RemoveActor()

void LegoGameState::RemoveActor ( )

Removes (and deletes) the current user actor from the world.

[AI] Also clears actorId to 0. [AI]

Definition at line 228 of file legogamestate.cpp.

◆ ResetROI()

void LegoGameState::ResetROI ( )

Re-applies the current actor's ROI to the 3D world (remove/add for update). [AI].

Definition at line 238 of file legogamestate.cpp.

◆ Save()

MxResult LegoGameState::Save ( MxULong  p_slot)

Saves persistent game state (world variables, actor, etc.) to a file slot.

[AI]

Parameters
p_slotSave slot index. [AI]

Definition at line 256 of file legogamestate.cpp.

◆ SerializePlayersInfo()

void LegoGameState::SerializePlayersInfo ( MxS16  p_flags)

Serializes all player info (usernames, player count) to the appropriate storage.

[AI]

Parameters
p_flagsFile mode flags (read/write) for the storage. [AI]

Definition at line 576 of file legogamestate.cpp.

◆ SerializeScoreHistory()

void LegoGameState::SerializeScoreHistory ( MxS16  p_flags)

Serializes the score history table to score file.

[AI]

Parameters
p_flagsFile mode flags (read/write) for the score file. [AI]

Definition at line 1570 of file legogamestate.cpp.

◆ SetActor()

void LegoGameState::SetActor ( MxU8  p_actorId)

Change the player character in the world to the given actor ID.

[AI] Instantiates correct IslePathActor/setups up ROI for selected character. [AI]

Parameters
p_actorIdActor ID to set as user-controlled. [AI]

Definition at line 197 of file legogamestate.cpp.

◆ SetActorId()

void LegoGameState::SetActorId ( MxU8  p_actorId)
inline

Directly sets the current actor ID (preferred: use SetActor).

[AI]

Parameters
p_actorIdID to set. [AI]

Definition at line 324 of file legogamestate.h.

◆ SetCurrentAct()

void LegoGameState::SetCurrentAct ( Act  p_currentAct)

Sets the current game act.

Parameters
p_currentActThe new act to set as current. [AI]

Definition at line 1587 of file legogamestate.cpp.

◆ SetDirty()

void LegoGameState::SetDirty ( MxBool  p_isDirty)
inline

Sets whether there are unsaved changes to the state.

[AI]

Parameters
p_isDirtyTRUE to mark save required. [AI]

Definition at line 316 of file legogamestate.h.

◆ SetPreviousArea()

void LegoGameState::SetPreviousArea ( Area  p_previousArea)
inline

Sets the previous area for reload/stop logic.

[AI]

Parameters
p_previousAreaArea to set as last. [AI]

Definition at line 320 of file legogamestate.h.

◆ SetSavePath()

void LegoGameState::SetSavePath ( char *  p_savePath)

Sets the path for current save slot directory; creates a copy of input string.

[AI]

Parameters
p_savePathNew path for save files. [AI]

Definition at line 452 of file legogamestate.cpp.

◆ StopArea()

void LegoGameState::StopArea ( Area  p_area)

Calls cleanup logic for the specified area (removes actors, VMs, closes handles, etc.).

[AI] Used when leaving an area/world. [AI]

Parameters
p_areaArea to stop (see Area enum). [AI]

Definition at line 671 of file legogamestate.cpp.

◆ SwitchArea()

void LegoGameState::SwitchArea ( Area  p_area)

Switches the whole game state into a new area/world; manages transitions/scene loads.

[AI] Sets camera, disables input, loads if needed. [AI]

Parameters
p_areaArea to switch to. [AI]

Definition at line 849 of file legogamestate.cpp.

◆ SwitchPlayer()

void LegoGameState::SwitchPlayer ( MxS16  p_playerId)

Make the specified player (by ID/index) the current player.

[AI] Updates slots/files, reloads, and initializes if load fails. [AI]

Parameters
p_playerIdIndex to switch to (0-8). [AI]

Definition at line 628 of file legogamestate.cpp.

Member Data Documentation

◆ m_currentArea

Area LegoGameState::m_currentArea

Area/world the player is presently in. [AI].

Definition at line 391 of file legogamestate.h.

◆ m_history

History LegoGameState::m_history

High score table/history for current game. [AI].

Definition at line 387 of file legogamestate.h.

◆ m_isDirty

MxBool LegoGameState::m_isDirty

TRUE if unsaved changes present. [AI].

Definition at line 390 of file legogamestate.h.

◆ m_jukeboxMusic

JukeboxScript::Script LegoGameState::m_jukeboxMusic

Which jukebox music is currently set to play. [AI].

Definition at line 389 of file legogamestate.h.

◆ m_playerCount

MxS16 LegoGameState::m_playerCount

Number of player usernames registered. [AI].

Definition at line 385 of file legogamestate.h.

◆ m_players

Username LegoGameState::m_players[9]

Array of all known player usernames (max 9, ranked). [AI].

Definition at line 386 of file legogamestate.h.

◆ m_previousArea

Area LegoGameState::m_previousArea

Where player was before last area switch. [AI].

Definition at line 392 of file legogamestate.h.

◆ m_unk0x24

MxS16 LegoGameState::m_unk0x24

Serial/generation marker used for score records. [AI].

Definition at line 384 of file legogamestate.h.

◆ m_unk0x41a

undefined2 LegoGameState::m_unk0x41a

Unknown (padding or unused). [AI].

Definition at line 388 of file legogamestate.h.

◆ m_unk0x42c

Area LegoGameState::m_unk0x42c

Used for act area storage on save/load. [AI].

Definition at line 393 of file legogamestate.h.


The documentation for this class was generated from the following files: