SState aggregates all the state variables of OpenMortal that do not belong
to the backend. This includes transient variables such as the current
game mode (e.g. SStade::IN_DEMO) and configuration variables (such as the
keyboard layout).
SState is a singlular object, and is accessed with a global pointer,
g_oState. All other frontend modules access the state through this object.
The state is made persistent through it's methods, Load() and Save().
Load() is called on program start, Save() is called when the program exits.
The State is the way the CMenu communicate with the rest of the system.
For example, if the user chooses "Quit" from the menu, the m_bQuitFlag is
set to true, and the program will react accordingly.
The state's most important properties are:
\li m_enGameMode: The mode changes when a game is started or the game ends
(either in the GameOver screen, or via the "Surrender Game" menu option).
\li m_bQuitFlag: This is set if the program receives a quit event from the operating system (e.g. KILL signal, window close event, etc), or the user chooses "Quit" from the menu. Once the quit flag is set, the program will abort. All main loops check the value of the quit flag, and will break as soon as it is true.
\li m_bFullScreen: Quite simply, it is true in fullscreen mode, and false in windowed mode. The user can change this via the menu. The State's ToggleFullscreen() method will switch between fullscreen and windowed mode. Maybe this functionality doesn't belong to the State? ...
\li Sound properties: Mixing rate, number of channels, volume, etc.
\li m_aiPlayerKeys: A double array of each player's keys. This is used most often in processing SDL key events: if the event's keysym matches a value in m_aiPlayerKeys, that means that a meaningful key was pushed or released.
*/
structSState
{
enumTGameMode{
IN_DEMO,///< The game is currently in "demo" mode: displaying the intro screens, etc.
IN_SINGLE,///< The game is in single-player mode.
IN_MULTI,///< The game is in multi-player mode.
IN_NETWORK,///< There is against a network opponent in progress
IN_CHAT,///< The user is on MortalNet
}m_enGameMode;
boolm_bQuitFlag;// true if quit event came
constchar*m_pcArgv0;// Set by main to argv[0]
// CONFIGURATION VARIABLES
intm_iNumPlayers;// The number of players =2
enumTTeamModeEnum{
Team_ONE_VS_ONE,
Team_GOOD_VS_EVIL,
Team_CUSTOM,
}m_enTeamMode;// Team mode
intm_iTeamSize;// The size of each team.
intm_bTeamMultiselect;// Can the same player be selected twice?
// TODO Rename this to m_iRoundLength
intm_iRoundLength;// Length of rounds in seconds.
intm_iHitPoints;// The initial number of hit points.
intm_iGameSpeed;// The speed of the game (fps = 1000/GameSpeed)
boolm_bFullscreen;// True in fullscreen mode.
intm_iChannels;// 1: mono, 2: stereo
intm_iMixingRate;// The mixing rate, in kHz
intm_iMixingBits;// 1: 8bit, 2: 16bit
intm_iMusicVolume;// Volume of music; 0: off, 100: max
intm_iSoundVolume;// Volume of sound effects; 0: off, 100: max
intm_aiPlayerKeys[MAXPLAYERS][9];// Player keysyms
charm_acLanguage[10];// Language ID (en,hu,fr,es,..)
intm_iLanguageCode;// Non-persistend language code (set by backend based on the language)
charm_acLatestServer[256];// Last server
boolm_bServer;// We were server in the last network game
charm_acNick[128];// The user name on the last server.