1
0
forked from 0ad/0ad
0ad/source/network/ServerSession.h
Matei 207d1367ec # A number of network synchronization fixes.
- The server will no longer send a new turn until the previous one has
been "acknowledged". (TODO: this may create lag between turns in its
current form; investigate and possibly allow executing two turns while
the third is being negotiated).
- Mutexes are now being used in NetServer and NetClient to ensure
commands go into the right batches.
- Commented out some orders in the GUI code that should not be there and
are not 100% working anyway (they were part of the follow/formation
system).
- Units that spawn or are created by scripts now have net-safe position
and orientation.
- Added a debug flag that can be turned on to print details about when
commands are received and executed (DEBUG_SYNCHRONIZATION). This is
especially useful if you diff the stdouts of two running games. There
should be no differences if everything is in synch.

This was SVN commit r5463.
2007-11-18 09:09:06 +00:00

74 lines
1.7 KiB
C++

/*
CNetServerSession - the server's representation of a connected client
DESCRIPTION:
*/
#ifndef INCLUDED_NETWORK_SERVERSESSION
#define INCLUDED_NETWORK_SERVERSESSION
#include "Session.h"
#include "scripting/ScriptableObject.h"
class CNetServer;
class CPlayer;
class CPlayerSlot;
class CNetServerSession: public CNetSession, public CJSObject<CNetServerSession>
{
CNetServer *m_pServer;
CPlayer *m_pPlayer;
CPlayerSlot *m_pPlayerSlot;
bool m_IsObserver;
int m_ID;
bool m_ReadyForTurn; // Is the last turn acknowledged?
// JS INTERFACE
static void ScriptingInit();
bool JSI_Close(JSContext *cx, uintN argc, jsval *argv);
protected:
friend class CNetServer;
inline void SetPlayer(CPlayer *pPlayer)
{ m_pPlayer=pPlayer; }
inline void SetPlayerSlot(CPlayerSlot *pPlayerSlot)
{ m_pPlayerSlot=pPlayerSlot; }
inline void SetID(int id)
{ m_ID=id; }
public:
CNetServerSession(CNetServer *pServer, CSocketInternal *pInt, MessageHandler *pMsgHandler=HandshakeHandler);
virtual ~CNetServerSession();
inline bool IsObserver()
{ return m_IsObserver; }
inline CPlayer *GetPlayer()
{ return m_pPlayer; }
inline CPlayerSlot *GetPlayerSlot()
{ return m_pPlayerSlot; }
inline int GetID()
{ return m_ID; }
inline bool IsReadyForTurn()
{ return m_ReadyForTurn; }
inline void SetReadyForTurn(bool value)
{ m_ReadyForTurn = value; }
// Called by server when starting the game, after sending NMT_StartGame to
// all connected clients.
void StartGame();
static MessageHandler BaseHandler;
static MessageHandler HandshakeHandler;
static MessageHandler AuthenticateHandler;
static MessageHandler PreGameHandler;
static MessageHandler ObserverHandler;
static MessageHandler ChatHandler;
static MessageHandler InGameHandler;
};
#endif