Hand the client IP addresses to the antibot module

This commit is contained in:
heinrich5991 2023-01-11 01:35:50 +01:00
parent ddabc11bca
commit 05f2c1e43f
5 changed files with 23 additions and 1 deletions

View file

@ -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;
};

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);