diff options
Diffstat (limited to 'NorthstarDLL/engine')
-rw-r--r-- | NorthstarDLL/engine/hoststate.cpp | 33 | ||||
-rw-r--r-- | NorthstarDLL/engine/r2engine.h | 17 |
2 files changed, 50 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 diff --git a/NorthstarDLL/engine/r2engine.h b/NorthstarDLL/engine/r2engine.h index 68b762e1..a7ed62a3 100644 --- a/NorthstarDLL/engine/r2engine.h +++ b/NorthstarDLL/engine/r2engine.h @@ -157,12 +157,29 @@ namespace R2 READY_REMOTE }; + enum class eSignonState : int + { + NONE = 0, // no state yet; about to connect + CHALLENGE = 1, // client challenging server; all OOB packets + CONNECTED = 2, // client is connected to server; netchans ready + NEW = 3, // just got serverinfo and string tables + PRESPAWN = 4, // received signon buffers + GETTINGDATA = 5, // respawn-defined signonstate, assumedly this is for persistence + SPAWN = 6, // ready to receive entity packets + FIRSTSNAP = 7, // another respawn-defined one + FULL = 8, // we are fully connected; first non-delta packet received + CHANGELEVEL = 9, // server is changing level; please wait + }; + // clang-format off OFFSET_STRUCT(CBaseClient) { STRUCT_SIZE(0x2D728) FIELD(0x16, char m_Name[64]) FIELD(0x258, KeyValues* m_ConVars) + FIELD(0x2A0, eSignonState m_Signon) + FIELD(0x358, char m_ClanTag[16]) + FIELD(0x484, bool m_bFakePlayer) FIELD(0x4A0, ePersistenceReady m_iPersistenceReady) FIELD(0x4FA, char m_PersistenceBuffer[PERSISTENCE_MAX_SIZE]) FIELD(0xF500, char m_UID[32]) |