Merge pull request #30 from RaidMax/bug/fix-sv-game-client-num

Fix issue that causes crash when retrieving client score on status ge…
This commit is contained in:
RektInator 2020-05-12 19:23:50 +02:00 committed by GitHub
commit 4f2e7d4fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) bool QuickPatch::InvalidNameCheck(char *dest, char *source, int size)
{ {
strncpy(dest, source, size - 1); strncpy(dest, source, size - 1);
@ -589,6 +609,9 @@ namespace Components
// Patch selectStringTableEntryInDvar // Patch selectStringTableEntryInDvar
Utils::Hook::Set(0x405959, QuickPatch::SelectStringTableEntryInDvarStub); 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*) Command::Add("unlockstats", [](Command::Params*)
{ {
QuickPatch::UnlockStats(); QuickPatch::UnlockStats();

View File

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