[RCon]: Address rare crash (#834)

This commit is contained in:
Edo 2023-03-15 18:50:23 +00:00 committed by GitHub
parent 0266d8aa2d
commit e3c86dfd7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -35,6 +35,24 @@ namespace Components
Game::FS_FreeFile(file);
}
int NetworkDebug::I_stricmp_Stub(const char* s0, const char* s1)
{
assert(s0);
assert(s1);
if (!s0)
{
return -1;
}
if (!s1)
{
return 1;
}
return Utils::Hook::Call<int(const char*, const char*, int)>(0x426080)(s0, s1, std::numeric_limits<int>::max()); // I_strnicmp
}
NetworkDebug::NetworkDebug()
{
#ifdef _DEBUG
@ -42,6 +60,9 @@ namespace Components
Command::Add("parseBadPacket", CL_ParseBadPacket_f);
#endif
// Address "race" condition where commands received from RCon can be null
Utils::Hook(0x6094DA, I_stricmp_Stub, HOOK_CALL).install()->quick(); // Cmd_ExecuteServerString
// Backport updates from IW5
Utils::Hook::Set<const char*>(0x45D112, "CL_PacketEvent - ignoring illegible message\n");
}

View File

@ -11,5 +11,7 @@ namespace Components
static void CL_ParseServerMessage_Hk(Game::msg_t* msg);
static void CL_ParseBadPacket_f();
static int I_stricmp_Stub(const char* s0, const char* s1);
};
}