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;
|
|
|
|
};
|
|
|
|
|
|
|
|
int Tick() const { return m_CurrentGameTick; }
|
|
|
|
int TickSpeed() const { return m_TickSpeed; }
|
|
|
|
|
|
|
|
virtual const char *ClientName(int ClientID) = 0;
|
|
|
|
virtual bool ClientIngame(int ClientID) = 0;
|
|
|
|
virtual int GetClientInfo(int ClientID, CClientInfo *pInfo) = 0;
|
|
|
|
virtual void GetClientIP(int ClientID, char *pIPString, int Size) = 0;
|
|
|
|
virtual int *LatestInput(int ClientID, int *pSize) = 0;
|
2010-10-11 00:39:08 +00:00
|
|
|
|
|
|
|
virtual void SetRconLevel(int ClientId, int Level) = 0;
|
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)
|
|
|
|
{
|
|
|
|
CMsgPacker Packer(pMsg->MsgID());
|
|
|
|
if(pMsg->Pack(&Packer))
|
|
|
|
return -1;
|
|
|
|
return SendMsg(&Packer, Flags, ClientID);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetBrowseInfo(char const *pGameType, int Progression) = 0;
|
|
|
|
virtual void SetClientName(int ClientID, char const *pName) = 0;
|
|
|
|
virtual void SetClientScore(int ClientID, int Score) = 0;
|
2010-07-29 05:21:18 +00:00
|
|
|
virtual void SetClientAuthed(int ClientID, int Authed) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
virtual int SnapNewID() = 0;
|
|
|
|
virtual void SnapFreeID(int ID) = 0;
|
|
|
|
virtual void *SnapNewItem(int Type, int Id, int Size) = 0;
|
|
|
|
|
|
|
|
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
2010-06-02 02:42:17 +00:00
|
|
|
|
2010-10-10 13:36:58 +00:00
|
|
|
virtual int IsAuthed(int ClientID) = 0;
|
2010-10-09 17:14:42 +00:00
|
|
|
virtual void Kick(int ClientID, const char *pReason) = 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;
|
|
|
|
|
|
|
|
virtual void OnTick() = 0;
|
|
|
|
virtual void OnPreSnap() = 0;
|
|
|
|
virtual void OnSnap(int ClientID) = 0;
|
|
|
|
virtual void OnPostSnap() = 0;
|
|
|
|
|
|
|
|
virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientID) = 0;
|
|
|
|
|
|
|
|
virtual void OnClientConnected(int ClientID) = 0;
|
|
|
|
virtual void OnClientEnter(int ClientID) = 0;
|
|
|
|
virtual void OnClientDrop(int ClientID) = 0;
|
|
|
|
virtual void OnClientDirectInput(int ClientID, void *pInput) = 0;
|
|
|
|
virtual void OnClientPredictedInput(int ClientID, void *pInput) = 0;
|
|
|
|
|
2010-08-07 18:49:57 +00:00
|
|
|
virtual void OnSetAuthed(int ClientId,int Level) = 0;
|
2010-12-19 13:11:14 +00:00
|
|
|
|
|
|
|
virtual bool PlayerCollision() = 0;
|
|
|
|
virtual bool PlayerHooking() = 0;
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual const char *Version() = 0;
|
|
|
|
virtual const char *NetVersion() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern IGameServer *CreateGameServer();
|
|
|
|
#endif
|