diff --git a/r5dev/engine/host_cmd.cpp b/r5dev/engine/host_cmd.cpp index 30fc0c4c..199ddece 100644 --- a/r5dev/engine/host_cmd.cpp +++ b/r5dev/engine/host_cmd.cpp @@ -1,7 +1,17 @@ #include "core/stdafx.h" #include "tier0/commandline.h" -#include "engine/host_cmd.h" +#include "host_cmd.h" +#include "common.h" +#include "client/client.h" +/* +================== +DFS_InitializeFeatureFlagDefinitions + +Initialize feature +flag definitions +================== +*/ bool DFS_InitializeFeatureFlagDefinitions(const char* pszFeatureFlags) { if (CommandLine()->CheckParm("-nodfs")) @@ -10,15 +20,55 @@ bool DFS_InitializeFeatureFlagDefinitions(const char* pszFeatureFlags) return v_DFS_InitializeFeatureFlagDefinitions(pszFeatureFlags); } +/* +================== +Host_Status_PrintClient + +Print client info +to console +================== +*/ +void Host_Status_PrintClient(CClient* client, bool bShowAddress, void (*print) (const char* fmt, ...)) +{ + CNetChan* nci = client->GetNetChan(); + const char* state = "challenging"; + + if (client->IsActive()) + state = "active"; + else if (client->IsSpawned()) + state = "spawning"; + else if (client->IsConnected()) + state = "connecting"; + + if (nci != NULL) + { + print("# %i \"%s\" %llu %s %i %i %s %d", client->GetHandle(), client->GetServerName(), client->GetNucleusID(), COM_FormatSeconds(nci->GetTimeConnected()), + static_cast(1000.0f * nci->GetAvgLatency(FLOW_OUTGOING)), static_cast(100.0f * nci->GetAvgLoss(FLOW_INCOMING)), state, nci->GetDataRate()); + + if (bShowAddress) + { + print(" %s", nci->GetAddress()); + } + } + else + { + print("#%2i \"%s\" %s %llu", client->GetUserID() + 1, client->GetServerName(), client->GetNucleusID(), state); + } + + print("\n"); +} + /////////////////////////////////////////////////////////////////////////////// void VHostCmd::Attach() const { DetourAttach(&v_DFS_InitializeFeatureFlagDefinitions, &DFS_InitializeFeatureFlagDefinitions); + DetourAttach(&v_Host_Status_PrintClient, &Host_Status_PrintClient); } void VHostCmd::Detach() const { DetourDetach(&v_DFS_InitializeFeatureFlagDefinitions, &DFS_InitializeFeatureFlagDefinitions); + DetourDetach(&v_Host_Status_PrintClient, &Host_Status_PrintClient); } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/engine/host_cmd.h b/r5dev/engine/host_cmd.h index ba4a6a55..4a9a626b 100644 --- a/r5dev/engine/host_cmd.h +++ b/r5dev/engine/host_cmd.h @@ -2,6 +2,11 @@ #include "tier1/cmd.h" #include "launcher/IApplication.h" +//------------------------------------------------------------------------------------- +// Forward declarations +//------------------------------------------------------------------------------------- +class CClient; + struct EngineParms_t { char* baseDirectory; @@ -22,6 +27,9 @@ inline auto Host_NewGame = p_Host_NewGame.RCast(); +inline CMemory p_Host_Status_PrintClient; +inline auto v_Host_Status_PrintClient = p_Host_Status_PrintClient.RCast(); + inline CMemory p_SetLaunchOptions; inline auto v_SetLaunchOptions = p_SetLaunchOptions.RCast(); @@ -40,6 +48,7 @@ class VHostCmd : public IDetour LogFunAdr("Host_Init", p_Host_Init.GetPtr()); LogFunAdr("Host_NewGame", p_Host_NewGame.GetPtr()); LogFunAdr("Host_ChangeLevel", p_Host_ChangeLevel.GetPtr()); + LogFunAdr("Host_Status_PrintClient", p_Host_Status_PrintClient.GetPtr()); LogFunAdr("SetLaunchOptions", p_SetLaunchOptions.GetPtr()); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) LogFunAdr("DFS_InitializeFeatureFlagDefinitions", p_DFS_InitializeFeatureFlagDefinitions.GetPtr()); @@ -59,6 +68,7 @@ class VHostCmd : public IDetour p_Host_ChangeLevel = g_GameDll.FindPatternSIMD("40 56 57 41 56 48 81 EC ?? ?? ?? ??"); p_SetLaunchOptions = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 48 8B E9 48 85 DB"); #endif + p_Host_Status_PrintClient = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 60 48 8B A9 ?? ?? ?? ??"); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) p_DFS_InitializeFeatureFlagDefinitions = g_GameDll.FindPatternSIMD("48 8B C4 55 53 48 8D 68 E8"); v_DFS_InitializeFeatureFlagDefinitions = p_DFS_InitializeFeatureFlagDefinitions.RCast(); /*48 8B C4 55 53 48 8D 68 E8*/ @@ -66,6 +76,7 @@ class VHostCmd : public IDetour Host_Init = p_Host_Init.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9*/ Host_NewGame = p_Host_NewGame.RCast(); /*48 8B C4 ?? 41 54 41 55 48 81 EC 70 04 00 00 F2 0F 10 05 ?? ?? ?? 0B*/ Host_ChangeLevel = p_Host_ChangeLevel.RCast(); /*40 56 57 41 56 48 81 EC ?? ?? ?? ??*/ + v_Host_Status_PrintClient = p_Host_Status_PrintClient.RCast(); v_SetLaunchOptions = p_SetLaunchOptions.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 48 8B E9 48 85 DB*/ } virtual void GetVar(void) const