aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-09 20:45:00 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-09 20:45:00 +0100
commit44034d69a54e2ef9e56cac06abf80a10fd3dcfcf (patch)
treeaa137a8154afe9fdc7639fd53cc1dabecdf5b903 /NorthstarDedicatedTest
parent5ce8343bcced9e92ab2b3c1b80382cffa0281629 (diff)
downloadNorthstarLauncher-44034d69a54e2ef9e56cac06abf80a10fd3dcfcf.tar.gz
NorthstarLauncher-44034d69a54e2ef9e56cac06abf80a10fd3dcfcf.zip
use cvar change callbacks for unescaping ns_server_name and ns_server_desc
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/convar.cpp2
-rw-r--r--NorthstarDedicatedTest/convar.h4
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp16
3 files changed, 10 insertions, 12 deletions
diff --git a/NorthstarDedicatedTest/convar.cpp b/NorthstarDedicatedTest/convar.cpp
index 69653bf0..c8e76e47 100644
--- a/NorthstarDedicatedTest/convar.cpp
+++ b/NorthstarDedicatedTest/convar.cpp
@@ -73,7 +73,7 @@ ConVar::ConVar(
float fMin,
bool bMax,
float fMax,
- void* pCallback)
+ FnChangeCallback_t pCallback)
{
spdlog::info("Registering Convar {}", pszName);
diff --git a/NorthstarDedicatedTest/convar.h b/NorthstarDedicatedTest/convar.h
index 9b27aabe..f316562b 100644
--- a/NorthstarDedicatedTest/convar.h
+++ b/NorthstarDedicatedTest/convar.h
@@ -74,6 +74,8 @@ class ConCommandBase;
class ConCommand;
class ConVar;
+typedef void (*FnChangeCallback_t)(ConVar* var, const char* pOldValue, float flOldValue);
+
//-----------------------------------------------------------------------------
// Purpose: A console variable
//-----------------------------------------------------------------------------
@@ -91,7 +93,7 @@ class ConVar
float fMin,
bool bMax,
float fMax,
- void* pCallback);
+ FnChangeCallback_t pCallback);
~ConVar(void);
const char* GetBaseName(void) const;
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index 1ef53c7d..96a07030 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -110,12 +110,6 @@ std::string unescape_unicode(const std::string& str)
return result;
}
-void UpdateServerInfoFromUnicodeToUTF8()
-{
- g_MasterServerManager->m_sUnicodeServerName = unescape_unicode(Cvar_ns_server_name->GetString());
- g_MasterServerManager->m_sUnicodeServerDesc = unescape_unicode(Cvar_ns_server_desc->GetString());
-}
-
RemoteServerInfo::RemoteServerInfo(
const char* newId,
const char* newName,
@@ -1240,8 +1234,6 @@ void CHostState__State_NewGameHook(CHostState* hostState)
// Copy new server name cvar to source
Cvar_hostname->SetValue(Cvar_ns_server_name->GetString());
- // This calls the function that converts unicode strings from servername and serverdesc to UTF-8
- UpdateServerInfoFromUnicodeToUTF8();
g_MasterServerManager->AddSelfToServerList(
Cvar_hostport->GetInt(),
@@ -1309,8 +1301,12 @@ ON_DLL_LOAD_RELIESON("engine.dll", MasterServer, ConCommand, [](HMODULE baseAddr
// unfortunately lib doesn't let us specify a port and still have https work
// Cvar_ns_masterserver_port = new ConVar("ns_masterserver_port", "8080", FCVAR_NONE, "");
- Cvar_ns_server_name = new ConVar("ns_server_name", "Unnamed Northstar Server", FCVAR_GAMEDLL, "");
- Cvar_ns_server_desc = new ConVar("ns_server_desc", "Default server description", FCVAR_GAMEDLL, "");
+ Cvar_ns_server_name = new ConVar("ns_server_name", "Unnamed Northstar Server", FCVAR_GAMEDLL, "", false, 0, false, 0, [](ConVar* cvar, const char* pOldValue, float flOldValue) {
+ g_MasterServerManager->m_sUnicodeServerName = unescape_unicode(Cvar_ns_server_name->GetString());
+ });
+ Cvar_ns_server_desc = new ConVar("ns_server_desc", "Default server description", FCVAR_GAMEDLL, "", false, 0, false, 0, [](ConVar* cvar, const char* pOldValue, float flOldValue) {
+ g_MasterServerManager->m_sUnicodeServerName = unescape_unicode(Cvar_ns_server_desc->GetString());
+ });
Cvar_ns_server_password = new ConVar("ns_server_password", "", FCVAR_GAMEDLL, "");
Cvar_ns_report_server_to_masterserver = new ConVar("ns_report_server_to_masterserver", "1", FCVAR_GAMEDLL, "");
Cvar_ns_report_sp_server_to_masterserver = new ConVar("ns_report_sp_server_to_masterserver", "0", FCVAR_GAMEDLL, "");