[Dedicated] Updated friend discovery hook

This commit is contained in:
RektInator 2017-05-31 01:51:06 +02:00
parent 0661972f68
commit f798af7840
2 changed files with 17 additions and 54 deletions

View File

@ -185,56 +185,6 @@ namespace Components
Game::Com_Error(code, message); Game::Com_Error(code, message);
} }
__declspec(naked) void Dedicated::OnServerCommandStub()
{
__asm
{
push eax
pushad
call Dedicated::OnServerCommand
mov [esp + 20h], eax
popad
pop eax
test al, al
jnz returnSafe
push 5944AEh
retn
returnSafe:
push 594536h
retn
}
}
int Dedicated::OnServerCommand()
{
Command::ClientParams params;
ZeroMemory(Dedicated::PlayerGuids, sizeof(Dedicated::PlayerGuids));
if (params.length() >= (18 * 2 + 1) && params.get(0)[0] == 20)
{
for (int client = 0; client < 18; client++)
{
Dedicated::PlayerGuids[client][0].bits = strtoull(params.get(2 * client + 1), nullptr, 16);
Dedicated::PlayerGuids[client][1].bits = strtoull(params.get(2 * client + 2), nullptr, 16);
if(Steam::Proxy::SteamFriends && Dedicated::PlayerGuids[client][1].bits != 0)
{
Steam::Proxy::SteamFriends->SetPlayedWith(Dedicated::PlayerGuids[client][1]);
}
}
return 1;
}
return 0;
}
void Dedicated::MapRotate() void Dedicated::MapRotate()
{ {
if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get<bool>()) if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get<bool>())
@ -577,7 +527,23 @@ namespace Components
} }
// Intercept server commands // Intercept server commands
Utils::Hook(0x59449F, Dedicated::OnServerCommandStub, HOOK_JUMP).install()->quick(); ServerCommands::OnCommand(20, [](Command::Params* params) {
for (int client = 0; client < 18; client++)
{
Dedicated::PlayerGuids[client][0].bits = strtoull(params.get(2 * client + 1), nullptr, 16);
Dedicated::PlayerGuids[client][1].bits = strtoull(params.get(2 * client + 2), nullptr, 16);
if (Steam::Proxy::SteamFriends && Dedicated::PlayerGuids[client][1].bits != 0)
{
Steam::Proxy::SteamFriends->SetPlayedWith(Dedicated::PlayerGuids[client][1]);
}
}
return true;
});
} }
QuickPatch::OnFrame([]() QuickPatch::OnFrame([]()

View File

@ -29,9 +29,6 @@ namespace Components
static bool SendChat; static bool SendChat;
static void OnServerCommandStub();
static int OnServerCommand();
static void MapRotate(); static void MapRotate();
static void FrameHandler(); static void FrameHandler();
static void FrameStub(); static void FrameStub();