2004-07-27 23:00:53 +02:00
|
|
|
#ifndef _ps_Game_H
|
|
|
|
#define _ps_Game_H
|
|
|
|
|
|
|
|
// Kludge: Our included headers might want to subgroup the Game group, so do it
|
|
|
|
// here, before including the other guys
|
2005-01-07 01:47:44 +01:00
|
|
|
#include "ps/Errors.h"
|
2004-07-27 23:00:53 +02:00
|
|
|
ERROR_GROUP(Game);
|
|
|
|
|
2004-08-05 15:07:51 +02:00
|
|
|
#include <vector>
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2006-03-21 21:55:45 +01:00
|
|
|
class CWorld;
|
|
|
|
class CSimulation;
|
|
|
|
class CGameView;
|
|
|
|
class CSimulation;
|
2005-07-03 18:25:48 +02:00
|
|
|
class CPlayer;
|
|
|
|
class CGameAttributes;
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
// Default player limit (not counting the Gaia player)
|
2006-03-21 21:55:45 +01:00
|
|
|
// This may be overridden by system.cfg ("max_players")
|
2005-01-23 05:14:49 +01:00
|
|
|
#define PS_MAX_PLAYERS 6
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
class CGame
|
|
|
|
{
|
2006-03-21 21:55:45 +01:00
|
|
|
CWorld *m_World;
|
|
|
|
CSimulation *m_Simulation;
|
|
|
|
CGameView *m_GameView;
|
2004-07-27 23:00:53 +02:00
|
|
|
|
|
|
|
CPlayer *m_pLocalPlayer;
|
2004-11-07 22:59:52 +01:00
|
|
|
std::vector<CPlayer *> m_Players;
|
2004-08-16 17:19:17 +02:00
|
|
|
uint m_NumPlayers;
|
2004-09-21 16:40:43 +02:00
|
|
|
|
|
|
|
bool m_GameStarted;
|
2005-12-29 05:52:40 +01:00
|
|
|
|
2006-01-23 04:56:48 +01:00
|
|
|
float m_Time;
|
|
|
|
|
2005-12-29 05:52:40 +01:00
|
|
|
enum EOG
|
|
|
|
{
|
|
|
|
EOG_NEUTRAL,
|
|
|
|
EOG_DRAW, //Draw by means of agreement of civilization
|
|
|
|
EOG_SPECIAL_DRAW, //Theoretically, players could die at the same time...?
|
|
|
|
EOG_LOSE,
|
|
|
|
EOG_WIN
|
|
|
|
} GameStatus;
|
2004-07-27 23:00:53 +02:00
|
|
|
|
|
|
|
public:
|
2004-08-05 15:07:51 +02:00
|
|
|
CGame();
|
|
|
|
~CGame();
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2006-01-02 04:07:29 +01:00
|
|
|
bool m_Paused;
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
/*
|
|
|
|
Initialize all local state and members for playing a game described by
|
2004-08-16 17:19:17 +02:00
|
|
|
the attribute class, and start the game.
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
Return: 0 on OK - a PSRETURN code otherwise
|
2004-07-27 23:00:53 +02:00
|
|
|
*/
|
2004-08-16 17:19:17 +02:00
|
|
|
PSRETURN StartGame(CGameAttributes *pGameAttributes);
|
2005-03-22 03:17:55 +01:00
|
|
|
PSRETURN ReallyStartGame();
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
/*
|
|
|
|
Perform all per-frame updates
|
|
|
|
*/
|
|
|
|
void Update(double deltaTime);
|
2005-12-29 05:52:40 +01:00
|
|
|
void UpdateGameStatus();
|
|
|
|
void EndGame();
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
inline CPlayer *GetLocalPlayer()
|
|
|
|
{ return m_pLocalPlayer; }
|
2004-11-07 22:59:52 +01:00
|
|
|
inline void SetLocalPlayer(CPlayer *pLocalPlayer)
|
|
|
|
{ m_pLocalPlayer=pLocalPlayer; }
|
|
|
|
|
2005-01-29 01:11:50 +01:00
|
|
|
// PT: No longer inline, because it does too much error checking. When
|
|
|
|
// everything stops trying to access players before they're loaded, feel
|
|
|
|
// free to put the inline version back.
|
|
|
|
CPlayer *GetPlayer(uint idx);
|
2005-01-18 01:46:18 +01:00
|
|
|
|
|
|
|
inline std::vector<CPlayer*>* GetPlayers()
|
|
|
|
{ return( &m_Players ); }
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
inline uint GetNumPlayers()
|
|
|
|
{ return m_NumPlayers; }
|
|
|
|
|
2004-09-21 16:40:43 +02:00
|
|
|
inline bool IsGameStarted()
|
|
|
|
{
|
|
|
|
return m_GameStarted;
|
|
|
|
}
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
inline CWorld *GetWorld()
|
2006-03-21 21:55:45 +01:00
|
|
|
{ return m_World; }
|
2004-07-27 23:00:53 +02:00
|
|
|
inline CGameView *GetView()
|
2006-03-21 21:55:45 +01:00
|
|
|
{ return m_GameView; }
|
2004-08-16 17:19:17 +02:00
|
|
|
inline CSimulation *GetSimulation()
|
2006-03-21 21:55:45 +01:00
|
|
|
{ return m_Simulation; }
|
2006-01-23 04:56:48 +01:00
|
|
|
|
|
|
|
inline float GetTime()
|
|
|
|
{ return m_Time; }
|
2005-03-22 03:17:55 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
PSRETURN RegisterInit(CGameAttributes* pAttribs);
|
2005-08-09 17:55:44 +02:00
|
|
|
|
|
|
|
// squelch "unable to generate" warnings
|
|
|
|
CGame(const CGame& rhs);
|
|
|
|
const CGame& operator=(const CGame& rhs);
|
2004-07-27 23:00:53 +02:00
|
|
|
};
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
extern CGame *g_Game;
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
#endif
|