This commit is contained in:
FutureRave 2022-03-10 13:54:10 +00:00
parent d739b1c6f9
commit 8cbd353e15
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
3 changed files with 29 additions and 11 deletions

View File

@ -374,15 +374,18 @@ namespace game
return SL_GetStringOfSize(str, user, strlen(str) + 1, 7);
}
__declspec(naked) void sv_send_client_game_state_mp(mp::client_t* client)
constexpr auto sv_send_client_game_state_mp_addr = 0x570FC0;
__declspec(naked) void sv_send_client_game_state_mp(mp::client_t* /*client*/)
{
static DWORD func = 0x570FC0;
__asm
{
mov esi, client
call func
retn
pushad
mov esi, [esp + 0x20 + 0x4]
call sv_send_client_game_state_mp_addr
popad
ret
}
}
@ -443,6 +446,11 @@ namespace game
{
return 0x507C;
}
void NetAdr_SetType(netadr_s* addr, netadrtype_t type)
{
addr->type = type;
}
}
launcher::mode mode = launcher::mode::none;

View File

@ -136,6 +136,8 @@ namespace game
void SV_DropAllBots();
int GetProtocolVersion();
void NetAdr_SetType(netadr_s* addr, netadrtype_t type);
}
bool is_mp();

View File

@ -42,18 +42,20 @@ game::native::gentity_s* test_clients::sv_add_test_client()
// Most basic string the game will accept.
_snprintf_s(user_info, _TRUNCATE,
"connect bot%d \"\\invited\\0\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\bot%d\\xuid\\%s\\xnaddr\\%s\\natType\\2\\protocol\\%d\\checksum\\%u\\statver\\%d %u\"",
"connect bot%d \"\\invited\\0\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\bot%d\\xuid\\%s\\xnaddr\\%s\\natType\\2\\protocol\\%d\\checksum\\%u\\statver\\%d %u\\qport\\%d\"",
bot_port, bot_port, xuid, "", game::native::GetProtocolVersion(), game::native::BG_NetDataChecksum(),
game::native::LiveStorage_GetPersistentDataDefVersion(), game::native::LiveStorage_GetPersistentDataDefFormatChecksum());
game::native::LiveStorage_GetPersistentDataDefVersion(), game::native::LiveStorage_GetPersistentDataDefFormatChecksum(), bot_port);
game::native::netadr_s adr;
std::memset(&adr, 0, sizeof(game::native::netadr_s));
adr.type = game::native::netadrtype_t::NA_BOT;
adr.port = static_cast<std::uint16_t>(bot_port);
++bot_port;
game::native::SV_Cmd_TokenizeString(user_info);
adr.port = static_cast<std::uint16_t>(bot_port++);
game::native::NetAdr_SetType(&adr, game::native::netadrtype_t::NA_BOT);
game::native::SV_DirectConnect(adr);
game::native::SV_Cmd_EndTokenizedString();
// Find the bot
@ -182,6 +184,12 @@ void test_clients::post_load()
void test_clients::patch_mp()
{
utils::hook::nop(0x639803, 5); // LiveSteamServer_RunFrame
utils::hook::nop(0x5CD65A, 5); // Do not crash for silly fatal error
utils::hook::set<BYTE>(0x572879, 0xEB); // Skip checks in SV_DirectConnect
utils::hook::set<BYTE>(0x5728D4, 0xEB);
utils::hook::set<BYTE>(0x57293D, 0xEB);
utils::hook(0x50C147, &test_clients::scr_shutdown_system_mp_stub, HOOK_CALL).install()->quick(); // G_ShutdownGame
utils::hook(0x57BBF9, &test_clients::reset_reliable_mp, HOOK_CALL).install()->quick(); // SV_SendMessageToClient
utils::hook(0x576DCC, &test_clients::check_timeouts_stub_mp, HOOK_JUMP).install()->quick(); // SV_CheckTimeouts