1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #ifndef ENGINE_CLIENT_H
4 #define ENGINE_CLIENT_H
9 class IClient
: public IInterface
11 MACRO_INTERFACE("client", 0)
13 // quick access to state of the client
16 // quick access to time variables
19 float m_GameIntraTick
;
23 float m_PredIntraTick
;
39 /* Constants: Client States
40 STATE_OFFLINE - The client is offline.
41 STATE_CONNECTING - The client is trying to connect to a server.
42 STATE_LOADING - The client has connected to a server and is loading resources.
43 STATE_ONLINE - The client is connected to a server and running the game.
44 STATE_DEMOPLAYBACK - The client is playing a demo
45 STATE_QUITING - The client is quiting.
59 inline int State() const { return m_State
; }
62 inline int PrevGameTick() const { return m_PrevGameTick
; }
63 inline int GameTick() const { return m_CurGameTick
; }
64 inline int PredGameTick() const { return m_PredTick
; }
65 inline float IntraGameTick() const { return m_GameIntraTick
; }
66 inline float PredIntraGameTick() const { return m_PredIntraTick
; }
67 inline float GameTickTime() const { return m_GameTickTime
; }
68 inline int GameTickSpeed() const { return m_GameTickSpeed
; }
71 inline float FrameTime() const { return m_FrameTime
; }
72 inline float LocalTime() const { return m_LocalTime
; }
75 virtual void Connect(const char *pAddress
) = 0;
76 virtual void Disconnect() = 0;
77 virtual void Quit() = 0;
78 virtual const char *DemoPlayer_Play(const char *pFilename
, int StorageType
) = 0;
79 virtual void DemoRecorder_Start(const char *pFilename
, bool WithTimestamp
) = 0;
80 virtual void DemoRecorder_HandleAutoStart() = 0;
81 virtual void DemoRecorder_Stop() = 0;
82 virtual void AutoScreenshot_Start() = 0;
83 virtual void ServerBrowserUpdate() = 0;
86 virtual void EnterGame() = 0;
89 virtual int MapDownloadAmount() = 0;
90 virtual int MapDownloadTotalsize() = 0;
93 virtual int *GetInput(int Tick
) = 0;
96 virtual void RconAuth(const char *pUsername
, const char *pPassword
) = 0;
97 virtual bool RconAuthed() = 0;
98 virtual bool UseTempRconCommands() = 0;
99 virtual void Rcon(const char *pLine
) = 0;
102 virtual void GetServerInfo(class CServerInfo
*pServerInfo
) = 0;
104 // snapshot interface
112 // TODO: Refactor: should redo this a bit i think, too many virtual calls
113 virtual int SnapNumItems(int SnapID
) = 0;
114 virtual void *SnapFindItem(int SnapID
, int Type
, int ID
) = 0;
115 virtual void *SnapGetItem(int SnapID
, int Index
, CSnapItem
*pItem
) = 0;
116 virtual void SnapInvalidateItem(int SnapID
, int Index
) = 0;
118 virtual void SnapSetStaticsize(int ItemType
, int Size
) = 0;
120 virtual int SendMsg(CMsgPacker
*pMsg
, int Flags
) = 0;
123 int SendPackMsg(T
*pMsg
, int Flags
)
125 CMsgPacker
Packer(pMsg
->MsgID());
126 if(pMsg
->Pack(&Packer
))
128 return SendMsg(&Packer
, Flags
);
132 virtual const char *ErrorString() = 0;
133 virtual const char *LatestVersion() = 0;
134 virtual bool ConnectionProblems() = 0;
136 virtual bool SoundInitFailed() = 0;
138 virtual int GetDebugFont() = 0;
141 class IGameClient
: public IInterface
143 MACRO_INTERFACE("gameclient", 0)
146 virtual void OnConsoleInit() = 0;
148 virtual void OnRconLine(const char *pLine
) = 0;
149 virtual void OnInit() = 0;
150 virtual void OnNewSnapshot() = 0;
151 virtual void OnEnterGame() = 0;
152 virtual void OnShutdown() = 0;
153 virtual void OnRender() = 0;
154 virtual void OnStateChange(int NewState
, int OldState
) = 0;
155 virtual void OnConnected() = 0;
156 virtual void OnMessage(int MsgID
, CUnpacker
*pUnpacker
) = 0;
157 virtual void OnPredict() = 0;
158 virtual void OnActivateEditor() = 0;
160 virtual int OnSnapInput(int *pData
) = 0;
162 virtual const char *GetItemName(int Type
) = 0;
163 virtual const char *Version() = 0;
164 virtual const char *NetVersion() = 0;
168 extern IGameClient
*CreateGameClient();