hopefully fixed gametracker bug with some bullshit + the actual packet size
This commit is contained in:
parent
7cf6c0431f
commit
7c92f9e5ba
@ -59,8 +59,11 @@ CDetour *g_pDetour_SendTo = NULL;
|
|||||||
char *NewBuf;
|
char *NewBuf;
|
||||||
char *OldBuf;
|
char *OldBuf;
|
||||||
|
|
||||||
char g_PlayerReply[1024];
|
struct PlayerInfo {
|
||||||
bf_write g_PlayerReplyPacket(g_PlayerReply, 1024);
|
char Name[32];
|
||||||
|
long Score;
|
||||||
|
float Time;
|
||||||
|
};
|
||||||
|
|
||||||
int g_FakePlayers = 0;
|
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)
|
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
|
PlayerReplyPacket.WriteLong(-1); // FF FF FF FF
|
||||||
g_PlayerReplyPacket.WriteByte(68); // 44
|
PlayerReplyPacket.WriteByte(68); // 44
|
||||||
|
|
||||||
g_PlayerReplyPacket.WriteByte(playerhelpers->GetNumPlayers()); // Number of players
|
|
||||||
|
|
||||||
int iPlayers = 0;
|
int iPlayers = 0;
|
||||||
|
|
||||||
|
PlayerInfo PlayerList[SM_MAXPLAYERS];
|
||||||
|
|
||||||
for (int index = 0; index <= SM_MAXPLAYERS; index++)
|
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())
|
if (pPlayer != NULL && pPlayer->IsConnected() && pPlayer->IsInGame() && !pPlayer->IsSourceTV())
|
||||||
{
|
{
|
||||||
g_PlayerReplyPacket.WriteByte(iPlayers);
|
memcpy(PlayerList[iPlayers].Name, pPlayer->GetName(), len);
|
||||||
g_PlayerReplyPacket.WriteString(pPlayer->GetName());
|
|
||||||
|
|
||||||
IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
|
IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
|
||||||
|
|
||||||
if (pInfo != NULL)
|
if (pInfo != NULL)
|
||||||
g_PlayerReplyPacket.WriteLong(pInfo->GetFragCount());
|
PlayerList[iPlayers].Score = pInfo->GetFragCount();
|
||||||
else
|
else
|
||||||
g_PlayerReplyPacket.WriteLong(0);
|
PlayerList[iPlayers].Score = 0;
|
||||||
|
|
||||||
INetChannelInfo *pNetInfo = engine->GetPlayerNetInfo(index);
|
INetChannelInfo *pNetInfo = engine->GetPlayerNetInfo(index);
|
||||||
|
|
||||||
if (pNetInfo != NULL)
|
if (pNetInfo != NULL)
|
||||||
g_PlayerReplyPacket.WriteFloat(pNetInfo->GetTimeConnected());
|
PlayerList[iPlayers].Time = pNetInfo->GetTimeConnected();
|
||||||
else
|
else
|
||||||
g_PlayerReplyPacket.WriteFloat(0.0);
|
PlayerList[iPlayers].Time = 0.0;
|
||||||
|
|
||||||
iPlayers++;
|
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);
|
return DETOUR_STATIC_CALL(Detour_SendTo)(s, buf, len, flags, to, tolen);
|
||||||
|
Loading…
Reference in New Issue
Block a user