From 43e162711e94293935e5eacf017c6cd0fa4c948b Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 9 Nov 2024 01:22:43 +0100 Subject: [PATCH] Core: add option to run the game fully offline The game can now be ran fully offline by providing '-offline' to the command line arguments. The engine will auto execute 'system/autoexec_offline.cfg' which overrides other autoexecs to ensure the game runs offline. The system/autoexec_offline.cfg file only overrides the variables it sets. --- src/core/init.cpp | 12 +++++++++++- src/engine/host_state.cpp | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/init.cpp b/src/core/init.cpp index 7b867923..8017a3fb 100644 --- a/src/core/init.cpp +++ b/src/core/init.cpp @@ -250,7 +250,17 @@ void Systems_Init() #ifdef DEDICATED InitCommandLineParameters(); -#endif // DEDICATED +#else + // Must append these here if user specified the -offline parameter so the + // engine can take care of disabling the platform systems on time. The + // dedicated server already has these disabled, so we don't need to check + // for it here. + if (CommandLine()->CheckParm("-offline")) + { + CommandLine()->AppendParm("-noorigin", ""); + CommandLine()->AppendParm("-nodiscord", ""); + } +#endif// DEDICATED // Script context registration callbacks. ScriptConstantRegister_Callback = ScriptConstantRegistrationCallback; diff --git a/src/engine/host_state.cpp b/src/engine/host_state.cpp index a3042ffe..075f8a4b 100644 --- a/src/engine/host_state.cpp +++ b/src/engine/host_state.cpp @@ -421,6 +421,10 @@ void CHostState::LoadConfig(void) const Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec tools/rcon_client_dev.cfg\n", cmd_source_t::kCommandSrcCode); #endif // !DEDICATED } + if (CommandLine()->CheckParm("-offline")) + { + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec system/autoexec_offline.cfg\n", cmd_source_t::kCommandSrcCode); + } #ifndef CLIENT_DLL Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec liveapi.cfg\n", cmd_source_t::kCommandSrcCode); #endif //!CLIENT_DLL