83 CGame(
bool disableGraphics =
false,
bool replayLog =
true);
91 void StartGame(JS::MutableHandleValue attribs,
const std::string& savedState);
105 void Update(
const double deltaRealTime,
bool doInterpolate =
true);
107 void Interpolate(
float simFrameLength,
float realFrameLength);
176 {
if (
isfinite(simRate)) m_SimRate = std::max(simRate, 0.0f); }
197 void RegisterInit(
const JS::HandleValue attribs,
const std::string& savedState);
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:40
CColor GetPlayerColor(player_id_t player) const
Definition: Game.cpp:457
player_id_t m_PlayerID
Index assigned to the current player.
Definition: Game.h:73
bool IsVisualReplay() const
Get m_IsVisualReplay.
Definition: Game.h:140
CTurnManager * m_TurnManager
Definition: Game.h:80
void CachePlayerColors()
Retrieving player colors from scripts is slow, so this updates an internal cache of all players' colo...
Definition: Game.cpp:435
void RegisterInit(const JS::HandleValue attribs, const std::string &savedState)
Initializes the game with the set of attributes provided.
Definition: Game.cpp:204
#define isfinite
Definition: posix.h:127
int LoadInitialState()
Definition: Game.cpp:266
CWorld * m_World
pointer to the CWorld object representing the game world.
Definition: Game.h:47
bool m_IsSavedGame
Definition: Game.h:204
void SetPlayerID(player_id_t playerID)
Definition: Game.cpp:350
Replay log recorder interface.
Definition: Replay.h:30
bool m_IsVisualReplay
Definition: Game.h:208
~CGame()
Destructor.
Definition: Game.cpp:99
This file defines the base class of the turn managers for clients, local games and replays...
Definition: TurnManager.h:57
CGameView * m_GameView
pointer to the CGameView object representing the view into the game world.
Definition: Game.h:57
Public API for simulation system.
Definition: Simulation2.h:47
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:24
int GetPlayerID()
Definition: Game.cpp:345
float GetSimRate() const
Definition: Game.h:178
CTurnManager * GetTurnManager() const
Definition: Game.h:190
std::vector< CColor > m_PlayerColors
Definition: Game.h:200
void Interpolate(float simFrameLength, float realFrameLength)
Definition: Game.cpp:424
uint32_t u32
Definition: types.h:39
CWorld is a general data class containing whatever is needed to accurately represent the world...
Definition: World.h:47
u32 PSRETURN
Definition: Errors.h:75
bool StartVisualReplay(const std::string &replayPath)
Definition: Game.cpp:171
player_id_t m_ViewedPlayerID
Differs from m_PlayerID if a defeated player or observer views another player.
Definition: Game.h:78
bool m_Paused
the game is paused and no updates will be performed if true.
Definition: Game.h:89
std::string m_ReplayPath
Definition: Game.h:207
std::string m_InitialSavedState
Definition: Game.h:203
Definition: GameView.h:37
CGame(bool disableGraphics=false, bool replayLog=true)
Constructor.
Definition: Game.cpp:66
void SetTurnManager(CTurnManager *turnManager)
Replace the current turn manager.
Definition: Game.cpp:113
void SetSimRate(float simRate)
Set the simulation scale multiplier.
Definition: Game.h:175
CSimulation2 * GetSimulation2()
Get the pointer to the simulation2 object.
Definition: Game.h:164
std::string GetReplayPath() const
Definition: Game.h:181
CGameView * GetView()
Get the pointer to the game view object.
Definition: Game.h:156
void StartGame(JS::MutableHandleValue attribs, const std::string &savedState)
Definition: Game.cpp:369
bool IsGameStarted() const
Get m_GameStarted.
Definition: Game.h:130
int LoadVisualReplayData()
Definition: Game.cpp:124
std::istream * m_ReplayStream
Definition: Game.h:209
CWorld * GetWorld()
Get the pointer to the game world object.
Definition: Game.h:148
void Update(const double deltaRealTime, bool doInterpolate=true)
Periodic heartbeat that controls the process.
Definition: Game.cpp:381
u32 m_FinalReplayTurn
Definition: Game.h:210
float m_SimRate
Timescale multiplier for simulation rate.
Definition: Game.h:67
PSRETURN ReallyStartGame()
Game initialization has been completed.
Definition: Game.cpp:291
IReplayLogger * m_ReplayLogger
Definition: Game.h:198
int GetViewedPlayerID()
Definition: Game.cpp:359
bool m_GameStarted
the game has been initialized and ready for use if true.
Definition: Game.h:62
void SetViewedPlayerID(player_id_t playerID)
Definition: Game.cpp:364
IReplayLogger & GetReplayLogger() const
Definition: Game.h:193
CSimulation2 * m_Simulation2
pointer to the CSimulation2 object operating on the game world.
Definition: Game.h:52
CGame * g_Game
Globally accessible pointer to the CGame object.
Definition: Game.cpp:60