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 GAME_SERVER_EVENTHANDLER_H
|
|
|
|
#define GAME_SERVER_EVENTHANDLER_H
|
|
|
|
|
2023-02-28 19:41:07 +00:00
|
|
|
#include <cstdint>
|
2021-01-11 17:28:14 +00:00
|
|
|
|
2023-01-26 10:56:48 +00:00
|
|
|
#include <engine/shared/protocol.h>
|
2023-01-24 08:27:29 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CEventHandler
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_EVENTS = 128,
|
|
|
|
MAX_DATASIZE = 128 * 64,
|
|
|
|
};
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-04-13 18:37:12 +00:00
|
|
|
int m_aTypes[MAX_EVENTS]; // TODO: remove some of these arrays
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_aOffsets[MAX_EVENTS];
|
|
|
|
int m_aSizes[MAX_EVENTS];
|
2023-01-24 08:27:29 +00:00
|
|
|
CClientMask m_aClientMasks[MAX_EVENTS];
|
2010-05-29 07:25:38 +00:00
|
|
|
char m_aData[MAX_DATASIZE];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CGameContext *m_pGameServer;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_CurrentOffset;
|
|
|
|
int m_NumEvents;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
CGameContext *GameServer() const { return m_pGameServer; }
|
|
|
|
void SetGameServer(CGameContext *pGameServer);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CEventHandler();
|
2023-01-24 08:27:29 +00:00
|
|
|
void *Create(int Type, int Size, CClientMask Mask = CClientMask().set());
|
2023-02-10 18:34:57 +00:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T *Create(CClientMask Mask = CClientMask().set())
|
|
|
|
{
|
|
|
|
return static_cast<T *>(Create(T::ms_MsgID, sizeof(T), Mask));
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void Clear();
|
|
|
|
void Snap(int SnappingClient);
|
2020-06-10 20:27:23 +00:00
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
void EventToSixup(int *pType, int *pSize, const char **ppData);
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|