aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/engine/hoststate.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2023-01-04 00:36:51 +0000
committerGitHub <noreply@github.com>2023-01-04 00:36:51 +0000
commit4fb1ae07d8f078e7abde99900c6a8286148a380a (patch)
tree56014eed36f16df79aab2c5cee527303dd70662d /NorthstarDLL/engine/hoststate.cpp
parenta4aab8da64eded240867fbe51d272aa44a180a26 (diff)
downloadNorthstarLauncher-4fb1ae07d8f078e7abde99900c6a8286148a380a.tar.gz
NorthstarLauncher-4fb1ae07d8f078e7abde99900c6a8286148a380a.zip
generally cleanup authentication code and fix client state issues with rejection from local server (#360)
* generally cleanup authentication code and fix client state issues with rejection from local server * fix formatting * fix formatting * use client-provided uid for logging disconnect failure as it won't be copied to player if authentication fails * support loading savegame and use more reliable method for fixing client rejection issues * oops forgot to add rejectconnectionfixes.cpp * fixup formatting
Diffstat (limited to 'NorthstarDLL/engine/hoststate.cpp')
-rw-r--r--NorthstarDLL/engine/hoststate.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp
index f2318c78..d474b908 100644
--- a/NorthstarDLL/engine/hoststate.cpp
+++ b/NorthstarDLL/engine/hoststate.cpp
@@ -26,7 +26,12 @@ void ServerStartingOrChangingMap()
// net_data_block_enabled is required for sp, force it if we're on an sp map
// sucks for security but just how it be
if (!strncmp(g_pHostState->m_levelName, "sp_", 3))
+ {
g_pCVar->FindVar("net_data_block_enabled")->SetValue(true);
+ g_pServerAuthentication->m_bStartingLocalSPGame = true;
+ }
+ else
+ g_pServerAuthentication->m_bStartingLocalSPGame = false;
}
// clang-format off
@@ -60,6 +65,34 @@ void, __fastcall, (CHostState* self))
}
// clang-format off
+AUTOHOOK(CHostState__State_LoadGame, engine.dll + 0x16E730,
+void, __fastcall, (CHostState* self))
+// clang-format on
+{
+ // singleplayer server starting
+ // useless in 99% of cases but without it things could potentially break very much
+
+ spdlog::info("HostState: LoadGame");
+
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", cmd_source_t::kCommandSrcCode);
+ Cbuf_Execute();
+
+ // this is normally done in ServerStartingOrChangingMap(), but seemingly the map name isn't set at this point
+ g_pCVar->FindVar("net_data_block_enabled")->SetValue(true);
+ g_pServerAuthentication->m_bStartingLocalSPGame = true;
+
+ double dStartTime = Tier0::Plat_FloatTime();
+ CHostState__State_LoadGame(self);
+ spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+
+ // no server presence, can't do it because no map name in hoststate
+ // and also not super important for sp saves really
+
+ g_pServerAuthentication->StartPlayerAuthServer();
+ g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false;
+}
+
+// clang-format off
AUTOHOOK(CHostState__State_ChangeLevelMP, engine.dll + 0x16E520,
void, __fastcall, (CHostState* self))
// clang-format on