diff --git a/extension.cpp b/extension.cpp index 622eec2..87d0b6b 100644 --- a/extension.cpp +++ b/extension.cpp @@ -62,6 +62,55 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag if (memcmp(buf, A2S_INFO_REPLY, 5) == 0) { g_pSM->LogMessage(myself, "A2S_INFO_REPLY: %s", buf); + + char *NewBuf; + char *OldBuf; + + NewBuf = new char[len]; + memcpy(NewBuf, buf, len); + OldBuf = NewBuf; + + // Skip header and protocol + NewBuf += 5; + + // Skip server name + while(*NewBuf) + NewBuf++; + + NewBuf++; + + // Skip map name + while(*NewBuf) + NewBuf++; + + NewBuf++; + + // Skip folder + while(*NewBuf) + NewBuf++; + + NewBuf++; + + // Skip game name + while(*NewBuf) + NewBuf++; + + NewBuf++; + + // Skip game id + NewBuf += 2; + + // Correct playercount + int NumPlayers = playerhelpers->GetNumPlayers(); + + NumPlayers -= 1; // Subtract SourceTV + + memset(NewBuf, NumPlayers, 1); + + // Reset Pointer + NewBuf = OldBuf; + + return DETOUR_STATIC_CALL(Detour_SendTo)(s, NewBuf, len, flags, to, tolen); } if (memcmp(buf, A2S_PLAYER_REPLY, 5) == 0)