aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2021-12-28 12:18:58 +0300
committerHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2021-12-28 12:18:58 +0300
commite49f026c92c75c4f10afd7f8895d8ebe2a01e97d (patch)
treec7350f3f743b9a429b72538d41121c557fb20a2b
parentbea776a8f6bcba5f702483d868d6fb6c4a069416 (diff)
downloadNorthstarLauncher-e49f026c92c75c4f10afd7f8895d8ebe2a01e97d.tar.gz
NorthstarLauncher-e49f026c92c75c4f10afd7f8895d8ebe2a01e97d.zip
implement svc_Print, copy NS hostname to source cvar
-rw-r--r--NorthstarDedicatedTest/logging.cpp18
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp12
2 files changed, 29 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/logging.cpp b/NorthstarDedicatedTest/logging.cpp
index 6525df27..0e72cc80 100644
--- a/NorthstarDedicatedTest/logging.cpp
+++ b/NorthstarDedicatedTest/logging.cpp
@@ -331,6 +331,21 @@ void Status_ConMsg_Hook(const char* text, ...)
spdlog::info(formatted);
}
+typedef bool(*CClientState_ProcessPrint_Type)(__int64 thisptr, __int64 msg);
+CClientState_ProcessPrint_Type CClientState_ProcessPrint_Original;
+
+bool CClientState_ProcessPrint_Hook(__int64 thisptr, __int64 msg)
+{
+ char* text = *(char**)(msg + 0x20);
+
+ auto endpos = strlen(text);
+ if (text[endpos - 1] == '\n')
+ text[endpos - 1] = '\0'; // cut off repeated newline
+
+ spdlog::info(text);
+ return true;
+}
+
void InitialiseEngineSpewFuncHooks(HMODULE baseAddress)
{
HookEnabler hook;
@@ -339,4 +354,7 @@ void InitialiseEngineSpewFuncHooks(HMODULE baseAddress)
// Hook print function that status concmd uses to actually print data
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x15ABD0, Status_ConMsg_Hook, reinterpret_cast<LPVOID*>(&Status_ConMsg_Original));
+
+ // Hook CClientState::ProcessPrint
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x1A1530, CClientState_ProcessPrint_Hook, reinterpret_cast<LPVOID*>(&CClientState_ProcessPrint_Original));
} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index 706f60ec..d7fea6d1 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -21,6 +21,9 @@ ConVar* Cvar_ns_server_name;
ConVar* Cvar_ns_server_desc;
ConVar* Cvar_ns_server_password;
+// Source ConVar
+ConVar* Cvar_hostname;
+
MasterServerManager* g_MasterServerManager;
typedef void(*CHostState__State_NewGameType)(CHostState* hostState);
@@ -127,7 +130,7 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or
if (originAuthInfo.HasParseError())
{
- spdlog::error("Failed reading origin auth info response: encountered parse error \{}\"", rapidjson::GetParseError_En(originAuthInfo.GetParseError()));
+ spdlog::error("Failed reading origin auth info response: encountered parse error \"{}\"", rapidjson::GetParseError_En(originAuthInfo.GetParseError()));
goto REQUEST_END_CLEANUP;
}
@@ -852,6 +855,10 @@ void CHostState__State_NewGameHook(CHostState* hostState)
if (maxPlayersVar) // GetCurrentPlaylistVar can return null so protect against this
maxPlayers = std::stoi(maxPlayersVar);
+ // Copy new server name cvar to source
+ Cvar_hostname->m_pszString = Cvar_ns_server_name->m_pszString;
+ Cvar_hostname->m_StringLength = Cvar_ns_server_name->m_StringLength;
+
g_MasterServerManager->AddSelfToServerList(Cvar_hostport->m_nValue, Cvar_ns_player_auth_port->m_nValue, Cvar_ns_server_name->m_pszString, Cvar_ns_server_desc->m_pszString, hostState->m_levelName, (char*)GetCurrentPlaylistName(), maxPlayers, Cvar_ns_server_password->m_pszString);
g_ServerAuthenticationManager->StartPlayerAuthServer();
g_ServerAuthenticationManager->m_bNeedLocalAuthForNewgame = false;
@@ -898,6 +905,9 @@ void InitialiseSharedMasterServer(HMODULE baseAddress)
Cvar_ns_server_password = RegisterConVar("ns_server_password", "", FCVAR_GAMEDLL, "");
Cvar_ns_report_server_to_masterserver = RegisterConVar("ns_report_server_to_masterserver", "1", FCVAR_GAMEDLL, "");
Cvar_ns_report_sp_server_to_masterserver = RegisterConVar("ns_report_sp_server_to_masterserver", "0", FCVAR_GAMEDLL, "");
+
+ Cvar_hostname = *(ConVar**)((char*)baseAddress + 0x1315bae8);
+
g_MasterServerManager = new MasterServerManager;
RegisterConCommand("ns_fetchservers", ConCommand_ns_fetchservers, "", FCVAR_CLIENTDLL);