2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef ENGINE_SERVER_H
|
|
|
|
#define ENGINE_SERVER_H
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "message.h"
|
|
|
|
|
|
|
|
class IServer : public IInterface
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("server", 0)
|
|
|
|
protected:
|
|
|
|
int m_CurrentGameTick;
|
|
|
|
int m_TickSpeed;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/*
|
|
|
|
Structure: CClientInfo
|
|
|
|
*/
|
|
|
|
struct CClientInfo
|
|
|
|
{
|
|
|
|
const char *m_pName;
|
|
|
|
int m_Latency;
|
|
|
|
};
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int Tick() const { return m_CurrentGameTick; }
|
|
|
|
int TickSpeed() const { return m_TickSpeed; }
|
|
|
|
|
2011-12-04 15:51:33 +00:00
|
|
|
virtual int MaxClients() const = 0;
|
2015-01-20 18:47:26 +00:00
|
|
|
virtual const char *ClientName(int ClientID) const = 0;
|
|
|
|
virtual const char *ClientClan(int ClientID) const = 0;
|
|
|
|
virtual int ClientCountry(int ClientID) const = 0;
|
|
|
|
virtual bool ClientIngame(int ClientID) const = 0;
|
|
|
|
virtual int GetClientInfo(int ClientID, CClientInfo *pInfo) const = 0;
|
|
|
|
virtual void GetClientAddr(int ClientID, char *pAddrStr, int Size) const = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) = 0;
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int SendPackMsg(T *pMsg, int Flags, int ClientID)
|
|
|
|
{
|
2012-08-09 08:30:04 +00:00
|
|
|
CMsgPacker Packer(pMsg->MsgID(), false);
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pMsg->Pack(&Packer))
|
|
|
|
return -1;
|
|
|
|
return SendMsg(&Packer, Flags, ClientID);
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void SetClientName(int ClientID, char const *pName) = 0;
|
2011-03-15 10:23:49 +00:00
|
|
|
virtual void SetClientClan(int ClientID, char const *pClan) = 0;
|
|
|
|
virtual void SetClientCountry(int ClientID, int Country) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void SetClientScore(int ClientID, int Score) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual int SnapNewID() = 0;
|
|
|
|
virtual void SnapFreeID(int ID) = 0;
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual void *SnapNewItem(int Type, int ID, int Size) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-12-31 11:11:48 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
RCON_CID_SERV=-1,
|
|
|
|
RCON_CID_VOTE=-2,
|
|
|
|
};
|
|
|
|
virtual void SetRconCID(int ClientID) = 0;
|
2015-01-20 18:47:26 +00:00
|
|
|
virtual bool IsAuthed(int ClientID) const = 0;
|
|
|
|
virtual bool IsBanned(int ClientID) const = 0;
|
2010-10-09 17:14:42 +00:00
|
|
|
virtual void Kick(int ClientID, const char *pReason) = 0;
|
2011-07-22 21:17:16 +00:00
|
|
|
|
|
|
|
virtual void DemoRecorder_HandleAutoStart() = 0;
|
2012-01-08 23:49:20 +00:00
|
|
|
virtual bool DemoRecorder_IsRecording() = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IGameServer : public IInterface
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("gameserver", 0)
|
|
|
|
protected:
|
|
|
|
public:
|
|
|
|
virtual void OnInit() = 0;
|
|
|
|
virtual void OnConsoleInit() = 0;
|
|
|
|
virtual void OnShutdown() = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnTick() = 0;
|
|
|
|
virtual void OnPreSnap() = 0;
|
|
|
|
virtual void OnSnap(int ClientID) = 0;
|
|
|
|
virtual void OnPostSnap() = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
virtual void OnClientConnected(int ClientID) = 0;
|
|
|
|
virtual void OnClientEnter(int ClientID) = 0;
|
2011-02-14 18:41:32 +00:00
|
|
|
virtual void OnClientDrop(int ClientID, const char *pReason) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnClientDirectInput(int ClientID, void *pInput) = 0;
|
|
|
|
virtual void OnClientPredictedInput(int ClientID, void *pInput) = 0;
|
2011-03-15 08:58:57 +00:00
|
|
|
|
2015-01-20 18:47:26 +00:00
|
|
|
virtual bool IsClientReady(int ClientID) const = 0;
|
|
|
|
virtual bool IsClientPlayer(int ClientID) const = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2015-01-20 18:47:26 +00:00
|
|
|
virtual const char *GameType() const = 0;
|
|
|
|
virtual const char *Version() const = 0;
|
|
|
|
virtual const char *NetVersion() const = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern IGameServer *CreateGameServer();
|
|
|
|
#endif
|