Isle
|
Comprehensive persistent game state manager: handles save/load, player selection, area switching, and score history. More...
#include <legogamestate.h>
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 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... | |
LegoState * | GetState (const char *p_stateName) |
Find an existing state (LegoState-derived) object by its registered script/class name. More... | |
LegoState * | CreateState (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... | |
Username * | GetPlayersIndex (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... | |
LegoBackgroundColor * | GetBackgroundColor () |
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... | |
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.
enum LegoGameState::Act |
Indicates which main storyline section (Act 1/2/3) is currently active.
[AI]
Definition at line 82 of file legogamestate.h.
enum LegoGameState::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.
LegoGameState::LegoGameState | ( | ) |
Definition at line 145 of file legogamestate.cpp.
LegoGameState::~LegoGameState | ( | ) |
Definition at line 177 of file legogamestate.cpp.
Adds a new player (username), moves others down, manages slot files.
[AI] Truncates to 9, maintaining latest player in top slot. [AI]
p_player | Username to add. [AI] |
Definition at line 599 of file legogamestate.cpp.
LegoState * LegoGameState::CreateState | ( | const char * | p_stateName | ) |
Creates an instance of given state, registers it, and returns pointer.
[AI]
p_stateName | Name to instantiate. [AI] |
Definition at line 1103 of file legogamestate.cpp.
MxResult LegoGameState::DeleteState | ( | ) |
Destroys and removes all current state objects, freeing memory and unregistering. [AI].
Definition at line 326 of file legogamestate.cpp.
void LegoGameState::FindLoadedAct | ( | ) |
Analyses the loaded Lego worlds to determine which act is present. [AI].
Definition at line 1593 of file legogamestate.cpp.
Finds the player index for a username; returns -1 if not found.
[AI]
p_player | Username to check. [AI] |
Definition at line 658 of file legogamestate.cpp.
|
inline |
Returns the current selected actor ID. [AI].
Definition at line 299 of file legogamestate.h.
|
inline |
Returns the actor name, based on the current actor ID. [AI].
Definition at line 302 of file legogamestate.h.
|
inline |
Gets the main background color variable object. [AI].
Definition at line 334 of file legogamestate.h.
|
inline |
Returns the active act that is currently in play. [AI].
Definition at line 305 of file legogamestate.h.
Writes the full save path for the given slot to the output string object.
[AI]
p_outPath | MxString to write resulting file path to. [AI] |
p_slotn | Slot index (0-9). [AI] |
Definition at line 555 of file legogamestate.cpp.
|
inline |
Returns the act that is currently loaded in memory. [AI].
Definition at line 308 of file legogamestate.h.
|
inline |
Gets the number of player slots currently used. [AI].
Definition at line 331 of file legogamestate.h.
Gets a pointer to a player username in the array by index.
[AI]
p_index | Index into m_players. [AI] |
Definition at line 328 of file legogamestate.h.
|
inline |
Gets the last area before the current one. [AI].
Definition at line 310 of file legogamestate.h.
LegoState * LegoGameState::GetState | ( | const char * | p_stateName | ) |
Find an existing state (LegoState-derived) object by its registered script/class name.
[AI]
p_stateName | String identifying the state class. [AI] |
Definition at line 1091 of file legogamestate.cpp.
|
inline |
Gets the value of m_unk0x42c (used for act area save/load mechanics). [AI].
Definition at line 312 of file legogamestate.h.
void LegoGameState::Init | ( | ) |
Re-initializes all world/variable state to the current act's defaults. [AI].
Definition at line 1143 of file legogamestate.cpp.
Loads persistent game state from specified save slot.
[AI]
p_slot | Save slot index to load. [AI] |
Definition at line 350 of file legogamestate.cpp.
void LegoGameState::RegisterState | ( | LegoState * | p_state | ) |
Registers a state object, replacing by class if already present.
[AI]
p_state | Pointer to a LegoState to register. [AI] |
Definition at line 1116 of file legogamestate.cpp.
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.
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.
Saves persistent game state (world variables, actor, etc.) to a file slot.
[AI]
p_slot | Save slot index. [AI] |
Definition at line 256 of file legogamestate.cpp.
void LegoGameState::SerializePlayersInfo | ( | MxS16 | p_flags | ) |
Serializes all player info (usernames, player count) to the appropriate storage.
[AI]
p_flags | File mode flags (read/write) for the storage. [AI] |
Definition at line 576 of file legogamestate.cpp.
void LegoGameState::SerializeScoreHistory | ( | MxS16 | p_flags | ) |
Serializes the score history table to score file.
[AI]
p_flags | File mode flags (read/write) for the score file. [AI] |
Definition at line 1570 of file legogamestate.cpp.
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]
p_actorId | Actor ID to set as user-controlled. [AI] |
Definition at line 197 of file legogamestate.cpp.
|
inline |
Directly sets the current actor ID (preferred: use SetActor).
[AI]
p_actorId | ID to set. [AI] |
Definition at line 324 of file legogamestate.h.
void LegoGameState::SetCurrentAct | ( | Act | p_currentAct | ) |
Sets the current game act.
p_currentAct | The new act to set as current. [AI] |
Definition at line 1587 of file legogamestate.cpp.
|
inline |
Sets whether there are unsaved changes to the state.
[AI]
p_isDirty | TRUE to mark save required. [AI] |
Definition at line 316 of file legogamestate.h.
|
inline |
Sets the previous area for reload/stop logic.
[AI]
p_previousArea | Area to set as last. [AI] |
Definition at line 320 of file legogamestate.h.
void LegoGameState::SetSavePath | ( | char * | p_savePath | ) |
Sets the path for current save slot directory; creates a copy of input string.
[AI]
p_savePath | New path for save files. [AI] |
Definition at line 452 of file legogamestate.cpp.
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]
p_area | Area to stop (see Area enum). [AI] |
Definition at line 671 of file legogamestate.cpp.
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]
p_area | Area to switch to. [AI] |
Definition at line 849 of file legogamestate.cpp.
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]
p_playerId | Index to switch to (0-8). [AI] |
Definition at line 628 of file legogamestate.cpp.
Area LegoGameState::m_currentArea |
Area/world the player is presently in. [AI].
Definition at line 391 of file legogamestate.h.
History LegoGameState::m_history |
High score table/history for current game. [AI].
Definition at line 387 of file legogamestate.h.
MxBool LegoGameState::m_isDirty |
TRUE if unsaved changes present. [AI].
Definition at line 390 of file legogamestate.h.
JukeboxScript::Script LegoGameState::m_jukeboxMusic |
Which jukebox music is currently set to play. [AI].
Definition at line 389 of file legogamestate.h.
MxS16 LegoGameState::m_playerCount |
Number of player usernames registered. [AI].
Definition at line 385 of file legogamestate.h.
Username LegoGameState::m_players[9] |
Array of all known player usernames (max 9, ranked). [AI].
Definition at line 386 of file legogamestate.h.
Area LegoGameState::m_previousArea |
Where player was before last area switch. [AI].
Definition at line 392 of file legogamestate.h.
MxS16 LegoGameState::m_unk0x24 |
Serial/generation marker used for score records. [AI].
Definition at line 384 of file legogamestate.h.
undefined2 LegoGameState::m_unk0x41a |
Unknown (padding or unused). [AI].
Definition at line 388 of file legogamestate.h.
Area LegoGameState::m_unk0x42c |
Used for act area storage on save/load. [AI].
Definition at line 393 of file legogamestate.h.