mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6264
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:
commit
067af3abbd
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue