From 05f2c1e43f97682b5f49b6f36b1dc8606c9a09e9 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Wed, 11 Jan 2023 01:35:50 +0100 Subject: [PATCH] Hand the client IP addresses to the antibot module --- src/antibot/antibot_data.h | 10 +++++++++- src/engine/server.h | 2 ++ src/engine/server/antibot.cpp | 1 + src/engine/server/server.cpp | 9 +++++++++ src/engine/server/server.h | 2 ++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/antibot/antibot_data.h b/src/antibot/antibot_data.h index 03d39cef6..b4963df34 100644 --- a/src/antibot/antibot_data.h +++ b/src/antibot/antibot_data.h @@ -6,7 +6,7 @@ enum { - ANTIBOT_ABI_VERSION = 5, + ANTIBOT_ABI_VERSION = 6, ANTIBOT_MSGFLAG_NONVITAL = 1, ANTIBOT_MSGFLAG_FLUSH = 2, @@ -21,6 +21,11 @@ struct CAntibotMapData unsigned char *m_pTiles; }; +struct CAntibotPlayerData +{ + char m_aAddress[64]; +}; + struct CAntibotInputData { int m_TargetX; @@ -58,6 +63,7 @@ struct CAntibotVersion int m_Size; int m_SizeData; + int m_SizePlayerData; int m_SizeCharacterData; int m_SizeInputData; int m_SizeMapData; @@ -69,6 +75,7 @@ struct CAntibotVersion ANTIBOT_ABI_VERSION, \ sizeof(CAntibotVersion), \ sizeof(CAntibotData), \ + sizeof(CAntibotPlayerData), \ sizeof(CAntibotCharacterData), \ sizeof(CAntibotInputData), \ sizeof(CAntibotMapData), \ @@ -89,6 +96,7 @@ struct CAntibotData struct CAntibotRoundData { int m_Tick; + CAntibotPlayerData m_aPlayers[ANTIBOT_MAX_CLIENTS]; CAntibotCharacterData m_aCharacters[ANTIBOT_MAX_CLIENTS]; CAntibotMapData m_Map; }; diff --git a/src/engine/server.h b/src/engine/server.h index ece8250fb..b8fb1cc11 100644 --- a/src/engine/server.h +++ b/src/engine/server.h @@ -254,6 +254,8 @@ public: virtual void SetErrorShutdown(const char *pReason) = 0; virtual void ExpireServerInfo() = 0; + virtual void FillAntibot(CAntibotRoundData *pData) = 0; + virtual void SendMsgRaw(int ClientID, const void *pData, int Size, int Flags) = 0; virtual const char *GetMapName() const = 0; diff --git a/src/engine/server/antibot.cpp b/src/engine/server/antibot.cpp index c337b1557..10217f6b2 100644 --- a/src/engine/server/antibot.cpp +++ b/src/engine/server/antibot.cpp @@ -92,6 +92,7 @@ void CAntibot::Update() m_Data.m_Now = time_get(); m_Data.m_Freq = time_freq(); + Server()->FillAntibot(&m_RoundData); if(GameServer()) { GameServer()->FillAntibot(&m_RoundData); diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 0d8493955..59765ec84 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2174,6 +2174,15 @@ void CServer::GetServerInfoSixup(CPacker *pPacker, int Token, bool SendClients) pPacker->AddRaw(FirstChunk.m_vData.data(), FirstChunk.m_vData.size()); } +void CServer::FillAntibot(CAntibotRoundData *pData) +{ + for(int i = 0; i < MAX_CLIENTS; i++) + { + CAntibotPlayerData *pPlayer = &pData->m_aPlayers[i]; + net_addr_str(m_NetServer.ClientAddr(i), pPlayer->m_aAddress, sizeof(pPlayer->m_aAddress), true); + } +} + void CServer::ExpireServerInfo() { m_ServerInfoNeedsUpdate = true; diff --git a/src/engine/server/server.h b/src/engine/server/server.h index fe943614f..c88afebb8 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -362,6 +362,8 @@ public: CCache m_aSixupServerInfoCache[2]; bool m_ServerInfoNeedsUpdate; + void FillAntibot(CAntibotRoundData *pData) override; + void ExpireServerInfo() override; void CacheServerInfo(CCache *pCache, int Type, bool SendClients); void CacheServerInfoSixup(CCache *pCache, bool SendClients);