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 GAME_SERVER_EVENTHANDLER_H
4#define GAME_SERVER_EVENTHANDLER_H
5
6#include <cstdint>
7
8#include <engine/shared/protocol.h>
9
10class CEventHandler
11{
12 enum
13 {
14 MAX_EVENTS = 128,
15 MAX_DATASIZE = 128 * 64,
16 };
17
18 int m_aTypes[MAX_EVENTS]; // TODO: remove some of these arrays
19 int m_aOffsets[MAX_EVENTS];
20 int m_aSizes[MAX_EVENTS];
21 CClientMask m_aClientMasks[MAX_EVENTS];
22 char m_aData[MAX_DATASIZE];
23
24 class CGameContext *m_pGameServer;
25
26 int m_CurrentOffset;
27 int m_NumEvents;
28
29public:
30 CGameContext *GameServer() const { return m_pGameServer; }
31 void SetGameServer(CGameContext *pGameServer);
32
33 CEventHandler();
34 void *Create(int Type, int Size, CClientMask Mask = CClientMask().set());
35
36 template<typename T>
37 T *Create(CClientMask Mask = CClientMask().set())
38 {
39 return static_cast<T *>(Create(T::ms_MsgId, sizeof(T), Mask));
40 }
41
42 void Clear();
43 void Snap(int SnappingClient);
44
45 void EventToSixup(int *pType, int *pSize, const char **ppData);
46};
47
48#endif
49