Fix issue that causes crash when retrieving client score on status generation if clients are in certain states

This commit is contained in:
RaidMax 2020-05-11 13:33:08 -05:00
parent dd42a06151
commit e0cb39ceaa
2 changed files with 24 additions and 0 deletions

View File

@ -119,6 +119,26 @@ namespace Components
}
}
__declspec(naked) int QuickPatch::SVGameClientNum()
{
_asm
{
mov eax, [esp + 4] // index
mov ecx, 1A831A8h
mov ecx, [ecx]
imul eax, 366Ch
lea edx, [eax + ecx + 3134h]
cmp edx, 0
jnz valid_player_state
mov eax, 0
ret
valid_player_state:
mov eax, [eax + ecx + 3134h]
ret
}
}
bool QuickPatch::InvalidNameCheck(char *dest, char *source, int size)
{
strncpy(dest, source, size - 1);
@ -589,6 +609,9 @@ namespace Components
// Patch selectStringTableEntryInDvar
Utils::Hook::Set(0x405959, QuickPatch::SelectStringTableEntryInDvarStub);
// Patch SV_GameClientNum for edge case generating status
Utils::Hook(0x624DE2, QuickPatch::SVGameClientNum, HOOK_CALL).install()->quick();
Command::Add("unlockstats", [](Command::Params*)
{
QuickPatch::UnlockStats();

View File

@ -19,6 +19,7 @@ namespace Components
static void SelectStringTableEntryInDvarStub();
static int SVCanReplaceServerCommand(Game::client_t *client, const char *cmd);
static int SVGameClientNum();
static int MsgReadBitsCompressCheckSV(const char *from, char *to, int size);
static int MsgReadBitsCompressCheckCL(const char *from, char *to, int size);