From 0228f59062f96624f1312b55f703917e75dbfa68 Mon Sep 17 00:00:00 2001 From: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Tue, 28 Dec 2021 02:23:13 +0100 Subject: [PATCH] Added indev Pylon(MasterServer) broadcasting to dedi. Read description for further information. Dedicated RemoteFunctionCallsChecksum needs fixing because its currently always null. Hidden needs to be implemented. I wouldn't say its needed currently till the Pylon re-write hits indev branch. --- r5dev/engine/host_state.cpp | 38 +++++++++++++++++++++++++++++++++++++ r5dev/tier0/IConVar.cpp | 3 ++- r5dev/tier0/IConVar.h | 28 +++++++++++++++++++++++++++ r5dev/tier0/cvar.cpp | 1 + r5dev/tier0/cvar.h | 1 + 5 files changed, 70 insertions(+), 1 deletion(-) diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index 7470390d..8122b1d1 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -4,6 +4,35 @@ #include "engine/net_chan.h" #include "tier0/cvar.h" #include "client/IVEngineClient.h" +#include "networksystem/r5net.h" +#include "squirrel/sqinit.h" + +//----------------------------------------------------------------------------- +// Purpose: Send keep alive request to Pylon Master Server. +// NOTE: When Pylon update reaches indev remove this and implement properly. +//----------------------------------------------------------------------------- +void KeepAliveToPylon() +{ + if (g_pHostState->m_bActiveGame && sv_pylonvisibility->m_iValue == 1) // Check for active game. + { + std::string m_szHostToken = std::string(); + std::string m_szHostRequestMessage = std::string(); + DevMsg(eDLL_T::CLIENT, "Sending PostServerHost request\n"); + bool result = g_pR5net->PostServerHost(m_szHostRequestMessage, m_szHostToken, + ServerListing{ + g_pCvar->FindVar("hostname")->m_pzsCurrentValue, + std::string(g_pHostState->m_levelName), + "", + g_pCvar->FindVar("hostport")->m_pzsCurrentValue, + g_pCvar->FindVar("mp_gamemode")->m_pzsCurrentValue, + false, + std::to_string(*g_nRemoteFunctionCallsChecksum), // BUG BUG: Checksum is null on dedi + std::string(), + g_szNetKey.c_str() + } + ); + } +} //----------------------------------------------------------------------------- // Purpose: state machine's main processing loop @@ -48,6 +77,15 @@ void HCHostState_FrameUpdate(void* rcx, void* rdx, float time) ConCommandBase* disconnect = (ConCommandBase*)g_pCvar->FindCommand("disconnect"); disconnect->AddFlags(FCVAR_SERVER_CAN_EXECUTE); // Make sure server is not restricted to this. + static std::thread PylonThread([]() // Pylon request thread. + { + while (true) + { + KeepAliveToPylon(); + std::this_thread::sleep_for(std::chrono::milliseconds(5000)); + } + }); + if (net_userandomkey->m_pParent->m_iValue == 1) { HNET_GenerateKey(); diff --git a/r5dev/tier0/IConVar.cpp b/r5dev/tier0/IConVar.cpp index 5d6d452e..6488ff4a 100644 --- a/r5dev/tier0/IConVar.cpp +++ b/r5dev/tier0/IConVar.cpp @@ -101,7 +101,8 @@ void IConVar_InitConVar() cm_return_false_cmdquery_cheats = IConVar_RegisterConVar("cm_return_false_cmdquery_cheats", "0", FCVAR_RELEASE, "Returns false on all FCVAR_DEVELOPMENTONLY and FCVAR_CHEAT ConVar/ConCommand queries ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr); //------------------------------------------------------------------------- // SERVER | - sv_showconnecting = IConVar_RegisterConVar("sv_showconnecting", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_showconnecting = IConVar_RegisterConVar("sv_showconnecting", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_pylonvisibility = IConVar_RegisterConVar("sv_pylonvisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon Master Server, 0 = Not visible, 1 = Visible, 2 = Hidden BUG BUG: not implemented yet.", false, 0.f, false, 0.f, nullptr, nullptr); //------------------------------------------------------------------------- // CLIENT | cl_drawconsoleoverlay = IConVar_RegisterConVar("cl_drawconsoleoverlay", "1", FCVAR_RELEASE, "Draw the console overlay at the top of the screen.", false, 0.f, false, 0.f, nullptr, nullptr); diff --git a/r5dev/tier0/IConVar.h b/r5dev/tier0/IConVar.h index bc64759f..e19f3753 100644 --- a/r5dev/tier0/IConVar.h +++ b/r5dev/tier0/IConVar.h @@ -52,6 +52,34 @@ #define FCVAR_SERVER_CANNOT_QUERY (1<<29) // If this is set, then the server is not allowed to query this cvar's value (via IServerPluginHelpers::StartQueryCvarValue). #define FCVAR_CLIENTCMD_CAN_EXECUTE (1<<30) // IVEngineClient::ClientCmd is allowed to execute this command. +/* +class ConVar : ConCommandBase, IConVar; [MI] (#classinformer) +dq offset ? ? _R4ConVar@@6B@; const ConVar::`RTTI Complete Object Locator' + +dq offset ??_G__ExceptionPtr@@QEAAPEAXI@Z_0; 0 Index +dq offset sub_1401F9930 +dq offset loc_14046FE90 +dq offset ConVar__AddFlags +dq offset ConVar__RemoveFlags +dq offset sub_14046FEA0 +dq offset loc_14046FF70 +dq offset ConVar__GetHelpString +dq offset sub_14046FEC0 +dq offset sub_14046FEE0 +dq offset ConVar__IsRegistered +dq offset ConVar__GetDllIdentifier +dq offset sub_14046F3F0 +dq offset sub_14046F470 +dq offset ConVar__InternalSetFloatValue; The one below also does something similar +dq offset sub_140470340 +dq offset sub_140470420; Seems to be InternalSetInt below maybe ? +dq offset sub_140470510 +dq offset nullsub +dq offset sub_140470300 +dq offset sub_1404701A0 +dq offset RegisterConVar; #STR: "Convar '%s' is flagged as both FCVAR_ARCHIVE and FCVAR_ARC +*/ + class ConVar { public: diff --git a/r5dev/tier0/cvar.cpp b/r5dev/tier0/cvar.cpp index e7ab5658..9fa93a6d 100644 --- a/r5dev/tier0/cvar.cpp +++ b/r5dev/tier0/cvar.cpp @@ -11,6 +11,7 @@ ConVar* cm_return_false_cmdquery_cheats = new ConVar(); //------------------------------------------------------------------------- // SERVER | ConVar* sv_showconnecting = new ConVar(); +ConVar* sv_pylonvisibility = new ConVar(); //------------------------------------------------------------------------- // CLIENT | ConVar* cl_drawconsoleoverlay = new ConVar(); diff --git a/r5dev/tier0/cvar.h b/r5dev/tier0/cvar.h index b283a121..e7806094 100644 --- a/r5dev/tier0/cvar.h +++ b/r5dev/tier0/cvar.h @@ -22,6 +22,7 @@ extern ConVar* cm_return_false_cmdquery_cheats; //------------------------------------------------------------------------- // SERVER | extern ConVar* sv_showconnecting; +extern ConVar* sv_pylonvisibility; //------------------------------------------------------------------------- // CLIENT | extern ConVar* cl_drawconsoleoverlay;