mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Some antibot fixes
This commit is contained in:
parent
eacc56059b
commit
457c4db964
|
@ -6,6 +6,8 @@
|
|||
|
||||
enum
|
||||
{
|
||||
ANTIBOT_ABI_VERSION=2,
|
||||
|
||||
ANTIBOT_MSGFLAG_NONVITAL=1,
|
||||
ANTIBOT_MSGFLAG_FLUSH=2,
|
||||
|
||||
|
@ -50,8 +52,32 @@ struct CAntibotCharacterData
|
|||
int m_WeaponChangeTick;
|
||||
};
|
||||
|
||||
struct CAntibotVersion
|
||||
{
|
||||
int m_AbiVersion;
|
||||
int m_Size;
|
||||
|
||||
int m_SizeData;
|
||||
int m_SizeCharacterData;
|
||||
int m_SizeInputData;
|
||||
int m_SizeMapData;
|
||||
int m_SizeRoundData;
|
||||
};
|
||||
|
||||
#define ANTIBOT_VERSION { \
|
||||
ANTIBOT_ABI_VERSION, \
|
||||
sizeof(CAntibotVersion), \
|
||||
sizeof(CAntibotData), \
|
||||
sizeof(CAntibotCharacterData), \
|
||||
sizeof(CAntibotInputData), \
|
||||
sizeof(CAntibotMapData), \
|
||||
sizeof(CAntibotRoundData), \
|
||||
}
|
||||
|
||||
struct CAntibotData
|
||||
{
|
||||
CAntibotVersion m_Version;
|
||||
|
||||
int64 m_Now;
|
||||
int64 m_Freq;
|
||||
void (*m_pfnLog)(const char *pMessage, void *pUser);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
extern "C"
|
||||
{
|
||||
|
||||
int AntibotAbiVersion();
|
||||
void AntibotInit(CAntibotData *pCallbackData);
|
||||
void AntibotRoundStart(CAntibotRoundData *pRoundData);
|
||||
void AntibotRoundEnd(void);
|
||||
|
|
|
@ -5,13 +5,14 @@ static CAntibotData *g_pData;
|
|||
extern "C"
|
||||
{
|
||||
|
||||
int AntibotAbiVersion()
|
||||
{
|
||||
return ANTIBOT_ABI_VERSION;
|
||||
}
|
||||
void AntibotInit(CAntibotData *pData)
|
||||
{
|
||||
g_pData = pData;
|
||||
if(g_pData->m_pfnLog)
|
||||
{
|
||||
g_pData->m_pfnLog("null antibot initialized", g_pData->m_pUser);
|
||||
}
|
||||
}
|
||||
void AntibotRoundStart(CAntibotRoundData *pRoundData) { };
|
||||
void AntibotRoundEnd(void) { };
|
||||
|
@ -19,10 +20,7 @@ void AntibotUpdateData(void) { }
|
|||
void AntibotDestroy(void) { g_pData = 0; }
|
||||
void AntibotDump(void)
|
||||
{
|
||||
if(g_pData->m_pfnLog)
|
||||
{
|
||||
g_pData->m_pfnLog("null antibot", g_pData->m_pUser);
|
||||
}
|
||||
}
|
||||
void AntibotOnPlayerInit(int ClientID) { (void)ClientID; }
|
||||
void AntibotOnPlayerDestroy(int ClientID) { (void)ClientID; }
|
||||
|
|
|
@ -48,8 +48,12 @@ void CAntibot::Init()
|
|||
m_pServer = Kernel()->RequestInterface<IServer>();
|
||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||
dbg_assert(m_pServer && m_pConsole, "antibot requires server and console");
|
||||
dbg_assert(AntibotAbiVersion() == ANTIBOT_ABI_VERSION, "antibot abi version mismatch");
|
||||
|
||||
mem_zero(&m_Data, sizeof(m_Data));
|
||||
CAntibotVersion Version = ANTIBOT_VERSION;
|
||||
m_Data.m_Version = Version;
|
||||
|
||||
m_Data.m_Now = time_get();
|
||||
m_Data.m_Freq = time_freq();
|
||||
m_Data.m_pfnLog = Log;
|
||||
|
@ -95,10 +99,11 @@ void CAntibot::OnCharacterTick(int ClientID) { Update(); AntibotOnCharacterTick(
|
|||
void CAntibot::OnHookAttach(int ClientID, bool Player) { Update(); AntibotOnHookAttach(ClientID, Player); }
|
||||
|
||||
void CAntibot::OnEngineTick() { Update(); AntibotOnEngineTick(); }
|
||||
void CAntibot::OnEngineClientJoin(int ClientID) { AntibotOnEngineClientJoin(ClientID); }
|
||||
void CAntibot::OnEngineClientDrop(int ClientID, const char *pReason) { AntibotOnEngineClientDrop(ClientID, pReason); }
|
||||
void CAntibot::OnEngineClientJoin(int ClientID) { Update(); AntibotOnEngineClientJoin(ClientID); }
|
||||
void CAntibot::OnEngineClientDrop(int ClientID, const char *pReason) { Update(); AntibotOnEngineClientDrop(ClientID, pReason); }
|
||||
void CAntibot::OnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags)
|
||||
{
|
||||
Update();
|
||||
int AntibotFlags = 0;
|
||||
if((Flags&MSGFLAG_VITAL) == 0)
|
||||
{
|
||||
|
|
|
@ -2183,6 +2183,8 @@ int CServer::Run()
|
|||
if(m_ServerInfoNeedsUpdate)
|
||||
UpdateServerInfo();
|
||||
|
||||
Antibot()->OnEngineTick();
|
||||
|
||||
if(!NonActive)
|
||||
PumpNetwork();
|
||||
|
||||
|
|
Loading…
Reference in a new issue