6264: Hand the client IP addresses to the antibot module r=def- a=heinrich5991

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
bors[bot] 2023-01-11 08:57:46 +00:00 committed by GitHub
commit 067af3abbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);