From 437ee48f8f603b22dc0d57c0e987298d7b4950d0 Mon Sep 17 00:00:00 2001 From: sr0 Date: Tue, 21 Feb 2017 21:39:40 +0100 Subject: [PATCH 1/7] [ConnectProtocol] Do not initialize when running as a dedicated server --- src/Components/Modules/ConnectProtocol.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 445f9b65..5ec53639 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -204,6 +204,8 @@ namespace Components ConnectProtocol::ConnectProtocol() { + if (Dedicated::Dedicated::IsEnabled()) return; + // IPC handler IPCPipe::On("connect", [] (std::string data) { From 6d151f77072126e6343a1816d20280acc6038215 Mon Sep 17 00:00:00 2001 From: sr0 Date: Tue, 21 Feb 2017 21:39:58 +0100 Subject: [PATCH 2/7] [ModList] Do not initialize when running as a dedicated server --- src/Components/Modules/ModList.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Components/Modules/ModList.cpp b/src/Components/Modules/ModList.cpp index 9cfcfdd9..3bd99b07 100644 --- a/src/Components/Modules/ModList.cpp +++ b/src/Components/Modules/ModList.cpp @@ -90,6 +90,8 @@ namespace Components ModList::ModList() { + if (Dedicated::Dedicated::IsEnabled()) return; + ModList::CurrentMod = 0; Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Perform a vid_restart when loading a mod."); From 151bb04a26e6c3d535e7bd09903032a00a235da3 Mon Sep 17 00:00:00 2001 From: sr0 Date: Tue, 21 Feb 2017 21:40:18 +0100 Subject: [PATCH 3/7] [News] Do not initialize when running as a dedicated server --- src/Components/Modules/News.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index 02b0c73c..ef4d57e0 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -121,7 +121,8 @@ namespace Components News::News() { News::UpdaterArgs.clear(); - if (ZoneBuilder::IsEnabled()) return; // Maybe also dedi? + + if (ZoneBuilder::IsEnabled() && Dedicated::Dedicated::IsEnabled()) return; // Maybe also dedi? Dvar::Register("g_firstLaunch", true, Game::DVAR_FLAG_SAVED, ""); @@ -174,7 +175,7 @@ namespace Components News::LaunchUpdater("-update -c"); }); - if (!Utils::IsWineEnvironment() && !Loader::PerformingUnitTests()) + if (!Utils::IsWineEnvironment() && !Loader::PerformingUnitTests() && !Dedicated::Dedicated::IsEnabled()) { News::Terminate = false; News::Thread = std::thread([]() From 6ab4dd7f9a338764e2c55ed14c7099d0d43d7084 Mon Sep 17 00:00:00 2001 From: sr0 Date: Tue, 21 Feb 2017 21:40:59 +0100 Subject: [PATCH 4/7] [QuickPatch] Disable several unneeded features when running as a dedicated server --- src/Components/Modules/QuickPatch.cpp | 65 ++++++++++++++++----------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 8bd4aa7b..56b87fa3 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -66,6 +66,8 @@ namespace Components void QuickPatch::UnlockStats() { + if (Dedicated::Dedicated::IsEnabled()) return; + if (Game::CL_IsCgameInitialized()) { Toast::Show("cardicon_locked", "^1Error", "Not allowed while ingame.", 3000); @@ -243,17 +245,20 @@ namespace Components // version string Utils::Hook::Set(0x60BD56, "IW4x (" VERSION ")"); - // version string color - static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f }; - Utils::Hook::Set(0x43F710, buildLocColor); - - // Shift ui version string to the left (ui_buildlocation) - Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar - Utils::Hook::Nop(0x6310B8, 5); // Don't write the result - Dvar::OnInit([] () + if (!Dedicated::Dedicated::IsEnabled()) { - *reinterpret_cast(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number"); - }); + // version string color + static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f }; + Utils::Hook::Set(0x43F710, buildLocColor); + + // Shift ui version string to the left (ui_buildlocation) + Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar + Utils::Hook::Nop(0x6310B8, 5); // Don't write the result + Dvar::OnInit([]() + { + *reinterpret_cast(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number"); + }); + } // console title if (ZoneBuilder::IsEnabled()) @@ -364,12 +369,15 @@ namespace Components Utils::Hook::Nop(0x5DF4F2, 5); // 'sending splash open' lines } - // intro stuff - Utils::Hook::Nop(0x60BEE9, 5); // Don't show legals - Utils::Hook::Nop(0x60BEF6, 5); // Don't reset the intro dvar - Utils::Hook::Set(0x60BED2, "unskippablecinematic IW_logo\n"); - Utils::Hook::Set(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik"); - Utils::Hook::Set(0x51C2C2, 0x78A0AC); + if (!Dedicated::Dedicated::IsEnabled()) + { + // intro stuff + Utils::Hook::Nop(0x60BEE9, 5); // Don't show legals + Utils::Hook::Nop(0x60BEF6, 5); // Don't reset the intro dvar + Utils::Hook::Set(0x60BED2, "unskippablecinematic IW_logo\n"); + Utils::Hook::Set(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik"); + Utils::Hook::Set(0x51C2C2, 0x78A0AC); + } // Redirect logs Utils::Hook::Set(0x5E44D8, "logs/games_mp.log"); @@ -420,19 +428,22 @@ namespace Components // Patch SV_IsClientUsingOnlineStatsOffline Utils::Hook::Set(0x46B710, 0x90C3C033); - // Fix mouse pitch adjustments - Dvar::Register("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); - UIScript::Add("updateui_mousePitch", [] (UIScript::Token) + if (!Dedicated::Dedicated::IsEnabled()) { - if (Dvar::Var("ui_mousePitch").get()) + // Fix mouse pitch adjustments + Dvar::Register("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); + UIScript::Add("updateui_mousePitch", [](UIScript::Token) { - Dvar::Var("m_pitch").set(-0.022f); - } - else - { - Dvar::Var("m_pitch").set(0.022f); - } - }); + if (Dvar::Var("ui_mousePitch").get()) + { + Dvar::Var("m_pitch").set(-0.022f); + } + else + { + Dvar::Var("m_pitch").set(0.022f); + } + }); + } // Rename stat file Utils::Hook::SetString(0x71C048, "iw4x.stat"); From c7f7f532dd06e13685874b7e580b810b3ac1e23b Mon Sep 17 00:00:00 2001 From: sr0 Date: Tue, 21 Feb 2017 21:47:02 +0100 Subject: [PATCH 5/7] [News] Remove unneeded dedicated check and fix another one --- src/Components/Modules/News.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index ef4d57e0..7fd60014 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -122,7 +122,7 @@ namespace Components { News::UpdaterArgs.clear(); - if (ZoneBuilder::IsEnabled() && Dedicated::Dedicated::IsEnabled()) return; // Maybe also dedi? + if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return; // Maybe also dedi? Dvar::Register("g_firstLaunch", true, Game::DVAR_FLAG_SAVED, ""); @@ -175,7 +175,7 @@ namespace Components News::LaunchUpdater("-update -c"); }); - if (!Utils::IsWineEnvironment() && !Loader::PerformingUnitTests() && !Dedicated::Dedicated::IsEnabled()) + if (!Utils::IsWineEnvironment() && !Loader::PerformingUnitTests()) { News::Terminate = false; News::Thread = std::thread([]() From 94429ed35f32b23172e55da72d664dd284d6773d Mon Sep 17 00:00:00 2001 From: sr0 Date: Tue, 21 Feb 2017 21:49:42 +0100 Subject: [PATCH 6/7] Revert "[QuickPatch] Disable several unneeded features when running as a dedicated server" --- src/Components/Modules/ConnectProtocol.cpp | 2 +- src/Components/Modules/ModList.cpp | 2 +- src/Components/Modules/QuickPatch.cpp | 65 ++++++++++------------ 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 5ec53639..a570a6fd 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -204,7 +204,7 @@ namespace Components ConnectProtocol::ConnectProtocol() { - if (Dedicated::Dedicated::IsEnabled()) return; + if (Dedicated::IsEnabled()) return; // IPC handler IPCPipe::On("connect", [] (std::string data) diff --git a/src/Components/Modules/ModList.cpp b/src/Components/Modules/ModList.cpp index 3bd99b07..d090b679 100644 --- a/src/Components/Modules/ModList.cpp +++ b/src/Components/Modules/ModList.cpp @@ -90,7 +90,7 @@ namespace Components ModList::ModList() { - if (Dedicated::Dedicated::IsEnabled()) return; + if (Dedicated::IsEnabled()) return; ModList::CurrentMod = 0; Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Perform a vid_restart when loading a mod."); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 56b87fa3..6691067b 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -66,7 +66,7 @@ namespace Components void QuickPatch::UnlockStats() { - if (Dedicated::Dedicated::IsEnabled()) return; + if (Dedicated::IsEnabled()) return; if (Game::CL_IsCgameInitialized()) { @@ -245,20 +245,17 @@ namespace Components // version string Utils::Hook::Set(0x60BD56, "IW4x (" VERSION ")"); - if (!Dedicated::Dedicated::IsEnabled()) - { - // version string color - static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f }; - Utils::Hook::Set(0x43F710, buildLocColor); + // version string color + static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f }; + Utils::Hook::Set(0x43F710, buildLocColor); - // Shift ui version string to the left (ui_buildlocation) - Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar - Utils::Hook::Nop(0x6310B8, 5); // Don't write the result - Dvar::OnInit([]() - { - *reinterpret_cast(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number"); - }); - } + // Shift ui version string to the left (ui_buildlocation) + Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar + Utils::Hook::Nop(0x6310B8, 5); // Don't write the result + Dvar::OnInit([] () + { + *reinterpret_cast(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number"); + }); // console title if (ZoneBuilder::IsEnabled()) @@ -369,15 +366,12 @@ namespace Components Utils::Hook::Nop(0x5DF4F2, 5); // 'sending splash open' lines } - if (!Dedicated::Dedicated::IsEnabled()) - { - // intro stuff - Utils::Hook::Nop(0x60BEE9, 5); // Don't show legals - Utils::Hook::Nop(0x60BEF6, 5); // Don't reset the intro dvar - Utils::Hook::Set(0x60BED2, "unskippablecinematic IW_logo\n"); - Utils::Hook::Set(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik"); - Utils::Hook::Set(0x51C2C2, 0x78A0AC); - } + // intro stuff + Utils::Hook::Nop(0x60BEE9, 5); // Don't show legals + Utils::Hook::Nop(0x60BEF6, 5); // Don't reset the intro dvar + Utils::Hook::Set(0x60BED2, "unskippablecinematic IW_logo\n"); + Utils::Hook::Set(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik"); + Utils::Hook::Set(0x51C2C2, 0x78A0AC); // Redirect logs Utils::Hook::Set(0x5E44D8, "logs/games_mp.log"); @@ -428,22 +422,19 @@ namespace Components // Patch SV_IsClientUsingOnlineStatsOffline Utils::Hook::Set(0x46B710, 0x90C3C033); - if (!Dedicated::Dedicated::IsEnabled()) + // Fix mouse pitch adjustments + Dvar::Register("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); + UIScript::Add("updateui_mousePitch", [] (UIScript::Token) { - // Fix mouse pitch adjustments - Dvar::Register("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); - UIScript::Add("updateui_mousePitch", [](UIScript::Token) + if (Dvar::Var("ui_mousePitch").get()) { - if (Dvar::Var("ui_mousePitch").get()) - { - Dvar::Var("m_pitch").set(-0.022f); - } - else - { - Dvar::Var("m_pitch").set(0.022f); - } - }); - } + Dvar::Var("m_pitch").set(-0.022f); + } + else + { + Dvar::Var("m_pitch").set(0.022f); + } + }); // Rename stat file Utils::Hook::SetString(0x71C048, "iw4x.stat"); From 46c054e7a89c5692364b7da6459a14acf4c0c415 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 25 Feb 2017 12:54:26 +0100 Subject: [PATCH 7/7] [General] Disable certain components when running as dedi - Changelog - D3D9Ex - Renderer - UIScript - UIFeeder --- src/Components/Modules/Changelog.cpp | 2 ++ src/Components/Modules/D3D9Ex.cpp | 2 ++ src/Components/Modules/Friends.cpp | 1 + src/Components/Modules/Renderer.cpp | 2 ++ src/Components/Modules/UIFeeder.cpp | 2 ++ src/Components/Modules/UIScript.cpp | 2 ++ 6 files changed, 11 insertions(+) diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 4e7ee826..6dc2d719 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -51,6 +51,8 @@ namespace Components Changelog::Changelog() { + if (Dedicated::IsEnabled()) return; + // Changelog UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog); } diff --git a/src/Components/Modules/D3D9Ex.cpp b/src/Components/Modules/D3D9Ex.cpp index 6526cf30..d5281324 100644 --- a/src/Components/Modules/D3D9Ex.cpp +++ b/src/Components/Modules/D3D9Ex.cpp @@ -745,6 +745,8 @@ namespace Components D3D9Ex::D3D9Ex() { + if (Dedicated::IsEnabled()) return; + Dvar::Register("r_useD3D9Ex", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Use extended d3d9 interface!"); // Hook Interface creation diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 1a113903..3444a341 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -535,6 +535,7 @@ namespace Components Friends::LoggedOn = false; if (Dedicated::IsEnabled() ||ZoneBuilder::IsEnabled()) return; + Dvar::Register("cl_anonymous", false, Game::DVAR_FLAG_SAVED, ""); Dvar::Register("cl_notifyFriendState", 1, -1, 1, Game::DVAR_FLAG_SAVED, ""); diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index f6af1fcb..3f190679 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -94,6 +94,8 @@ namespace Components Renderer::Renderer() { + if (Dedicated::IsEnabled()) return; + // Renderer::OnBackendFrame([] (IDirect3DDevice9* device) // { // if (Game::Sys_Milliseconds() % 2) diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index ad39e43d..8d6e7dc6 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -379,6 +379,8 @@ namespace Components UIFeeder::UIFeeder() { + if (Dedicated::IsEnabled()) return; + Dvar::OnInit([]() { Dvar::Register("ui_map_long", "Afghan", Game::dvar_flag::DVAR_FLAG_NONE, ""); diff --git a/src/Components/Modules/UIScript.cpp b/src/Components/Modules/UIScript.cpp index 95f118e8..923772b4 100644 --- a/src/Components/Modules/UIScript.cpp +++ b/src/Components/Modules/UIScript.cpp @@ -116,6 +116,8 @@ namespace Components UIScript::UIScript() { + if (Dedicated::IsEnabled()) return; + // Install handler Utils::Hook::RedirectJump(0x45EC59, UIScript::RunMenuScriptStub);