[QuickPatch] Disable several unneeded features when running as a dedicated server

This commit is contained in:
sr0 2017-02-21 21:40:59 +01:00
parent 151bb04a26
commit 6ab4dd7f9a

View File

@ -66,6 +66,8 @@ namespace Components
void QuickPatch::UnlockStats() void QuickPatch::UnlockStats()
{ {
if (Dedicated::Dedicated::IsEnabled()) return;
if (Game::CL_IsCgameInitialized()) if (Game::CL_IsCgameInitialized())
{ {
Toast::Show("cardicon_locked", "^1Error", "Not allowed while ingame.", 3000); Toast::Show("cardicon_locked", "^1Error", "Not allowed while ingame.", 3000);
@ -243,6 +245,8 @@ namespace Components
// version string // version string
Utils::Hook::Set<char*>(0x60BD56, "IW4x (" VERSION ")"); Utils::Hook::Set<char*>(0x60BD56, "IW4x (" VERSION ")");
if (!Dedicated::Dedicated::IsEnabled())
{
// version string color // version string color
static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f }; static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f };
Utils::Hook::Set(0x43F710, buildLocColor); Utils::Hook::Set(0x43F710, buildLocColor);
@ -254,6 +258,7 @@ namespace Components
{ {
*reinterpret_cast<Game::dvar_t**>(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number"); *reinterpret_cast<Game::dvar_t**>(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 // console title
if (ZoneBuilder::IsEnabled()) if (ZoneBuilder::IsEnabled())
@ -364,12 +369,15 @@ namespace Components
Utils::Hook::Nop(0x5DF4F2, 5); // 'sending splash open' lines Utils::Hook::Nop(0x5DF4F2, 5); // 'sending splash open' lines
} }
if (!Dedicated::Dedicated::IsEnabled())
{
// intro stuff // intro stuff
Utils::Hook::Nop(0x60BEE9, 5); // Don't show legals Utils::Hook::Nop(0x60BEE9, 5); // Don't show legals
Utils::Hook::Nop(0x60BEF6, 5); // Don't reset the intro dvar Utils::Hook::Nop(0x60BEF6, 5); // Don't reset the intro dvar
Utils::Hook::Set<char*>(0x60BED2, "unskippablecinematic IW_logo\n"); Utils::Hook::Set<char*>(0x60BED2, "unskippablecinematic IW_logo\n");
Utils::Hook::Set<char*>(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik"); Utils::Hook::Set<char*>(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik");
Utils::Hook::Set<DWORD>(0x51C2C2, 0x78A0AC); Utils::Hook::Set<DWORD>(0x51C2C2, 0x78A0AC);
}
// Redirect logs // Redirect logs
Utils::Hook::Set<char*>(0x5E44D8, "logs/games_mp.log"); Utils::Hook::Set<char*>(0x5E44D8, "logs/games_mp.log");
@ -420,6 +428,8 @@ namespace Components
// Patch SV_IsClientUsingOnlineStatsOffline // Patch SV_IsClientUsingOnlineStatsOffline
Utils::Hook::Set<DWORD>(0x46B710, 0x90C3C033); Utils::Hook::Set<DWORD>(0x46B710, 0x90C3C033);
if (!Dedicated::Dedicated::IsEnabled())
{
// Fix mouse pitch adjustments // Fix mouse pitch adjustments
Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, "");
UIScript::Add("updateui_mousePitch", [](UIScript::Token) UIScript::Add("updateui_mousePitch", [](UIScript::Token)
@ -433,6 +443,7 @@ namespace Components
Dvar::Var("m_pitch").set(0.022f); Dvar::Var("m_pitch").set(0.022f);
} }
}); });
}
// Rename stat file // Rename stat file
Utils::Hook::SetString(0x71C048, "iw4x.stat"); Utils::Hook::SetString(0x71C048, "iw4x.stat");