hopefully fixed gametracker bug with some bullshit + the actual packet size

This commit is contained in:
george 2019-05-22 18:10:50 +01:00
parent 7cf6c0431f
commit 7c92f9e5ba

View File

@ -59,8 +59,11 @@ CDetour *g_pDetour_SendTo = NULL;
char *NewBuf;
char *OldBuf;
char g_PlayerReply[1024];
bf_write g_PlayerReplyPacket(g_PlayerReply, 1024);
struct PlayerInfo {
char Name[32];
long Score;
float Time;
};
int g_FakePlayers = 0;
@ -137,14 +140,17 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
if (memcmp(buf, A2S_PLAYER_REPLY, 5) == 0)
{
g_PlayerReplyPacket.Reset(); // Build up the packet as a bitbuffer so we can use the nice helper functions to do the work for us
char PlayerReply[1024 * 6];
bf_write PlayerReplyPacket(PlayerReply, sizeof(PlayerReply));
PlayerReplyPacket.Reset(); // Build up the packet as a bitbuffer so we can use the nice helper functions to do the work for us
g_PlayerReplyPacket.WriteLong(-1); // FF FF FF FF
g_PlayerReplyPacket.WriteByte(68); // 44
g_PlayerReplyPacket.WriteByte(playerhelpers->GetNumPlayers()); // Number of players
PlayerReplyPacket.WriteLong(-1); // FF FF FF FF
PlayerReplyPacket.WriteByte(68); // 44
int iPlayers = 0;
PlayerInfo PlayerList[SM_MAXPLAYERS];
for (int index = 0; index <= SM_MAXPLAYERS; index++)
{
@ -152,28 +158,37 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
if (pPlayer != NULL && pPlayer->IsConnected() && pPlayer->IsInGame() && !pPlayer->IsSourceTV())
{
g_PlayerReplyPacket.WriteByte(iPlayers);
g_PlayerReplyPacket.WriteString(pPlayer->GetName());
memcpy(PlayerList[iPlayers].Name, pPlayer->GetName(), len);
IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
if (pInfo != NULL)
g_PlayerReplyPacket.WriteLong(pInfo->GetFragCount());
PlayerList[iPlayers].Score = pInfo->GetFragCount();
else
g_PlayerReplyPacket.WriteLong(0);
PlayerList[iPlayers].Score = 0;
INetChannelInfo *pNetInfo = engine->GetPlayerNetInfo(index);
if (pNetInfo != NULL)
g_PlayerReplyPacket.WriteFloat(pNetInfo->GetTimeConnected());
PlayerList[iPlayers].Time = pNetInfo->GetTimeConnected();
else
g_PlayerReplyPacket.WriteFloat(0.0);
PlayerList[iPlayers].Time = 0.0;
iPlayers++;
}
}
PlayerReplyPacket.WriteByte(iPlayers); // Number of players
for (int index = 0; index < iPlayers; index++)
{
PlayerReplyPacket.WriteByte(index);
PlayerReplyPacket.WriteString(PlayerList[index].Name);
PlayerReplyPacket.WriteLong(PlayerList[index].Score);
PlayerReplyPacket.WriteFloat(PlayerList[index].Time);
}
return DETOUR_STATIC_CALL(Detour_SendTo)(s, (char *)g_PlayerReplyPacket.GetData(), g_PlayerReplyPacket.GetNumBytesWritten(), flags, to, tolen);
return DETOUR_STATIC_CALL(Detour_SendTo)(s, (char *)PlayerReplyPacket.GetData(), PlayerReplyPacket.GetNumBytesWritten(), flags, to, tolen);
}
return DETOUR_STATIC_CALL(Detour_SendTo)(s, buf, len, flags, to, tolen);