forked from 0ad/0ad
olsner
7bcc12373b
- Changed player colour JS interface: setColour(...) instead of a colour property - Introduced a network log and replaced most network LOG() calls with NET_LOG() - Moved to a slot-based system for Pre-Game and extended a lot of the JS APIs to networking stuff - A bit of cleanup in the low-level network code (Unix parts) - Clients now keep track of all other connected clients on the server (And exposes this info to JS) - Split out GameAttributes to its own file - Removed unused class AttributeMap - Changed CJSObject to use T* pointers in JS_SetPrivate (needed to make ToScript work with multiple inheritance) This was SVN commit r1929.
82 lines
1.7 KiB
C++
Executable File
82 lines
1.7 KiB
C++
Executable File
#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
|
|
#include "ps/Errors.h"
|
|
ERROR_GROUP(Game);
|
|
|
|
#include "World.h"
|
|
#include "Simulation.h"
|
|
#include "Player.h"
|
|
#include "GameView.h"
|
|
#include "GameAttributes.h"
|
|
|
|
#include <vector>
|
|
|
|
// Default player limit (not counting the Gaia player)
|
|
// This may be overriden by system.cfg ("max_players")
|
|
#define PS_MAX_PLAYERS 6
|
|
|
|
class CGame
|
|
{
|
|
CWorld m_World;
|
|
CSimulation m_Simulation;
|
|
CGameView m_GameView;
|
|
|
|
CPlayer *m_pLocalPlayer;
|
|
std::vector<CPlayer *> m_Players;
|
|
uint m_NumPlayers;
|
|
|
|
bool m_GameStarted;
|
|
|
|
public:
|
|
CGame();
|
|
~CGame();
|
|
|
|
/*
|
|
Initialize all local state and members for playing a game described by
|
|
the attribute class, and start the game.
|
|
|
|
Return: 0 on OK - a PSRETURN code otherwise
|
|
*/
|
|
PSRETURN StartGame(CGameAttributes *pGameAttributes);
|
|
|
|
/*
|
|
Perform all per-frame updates
|
|
*/
|
|
void Update(double deltaTime);
|
|
|
|
inline CPlayer *GetLocalPlayer()
|
|
{ return m_pLocalPlayer; }
|
|
inline void SetLocalPlayer(CPlayer *pLocalPlayer)
|
|
{ m_pLocalPlayer=pLocalPlayer; }
|
|
|
|
// 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);
|
|
|
|
inline std::vector<CPlayer*>* GetPlayers()
|
|
{ return( &m_Players ); }
|
|
|
|
inline uint GetNumPlayers()
|
|
{ return m_NumPlayers; }
|
|
|
|
inline bool IsGameStarted()
|
|
{
|
|
return m_GameStarted;
|
|
}
|
|
|
|
inline CWorld *GetWorld()
|
|
{ return &m_World; }
|
|
inline CGameView *GetView()
|
|
{ return &m_GameView; }
|
|
inline CSimulation *GetSimulation()
|
|
{ return &m_Simulation; }
|
|
};
|
|
|
|
extern CGame *g_Game;
|
|
|
|
#endif
|