diff --git a/src/Components/Modules/Branding.cpp b/src/Components/Modules/Branding.cpp index 6f1c3fbf..63d766e2 100644 --- a/src/Components/Modules/Branding.cpp +++ b/src/Components/Modules/Branding.cpp @@ -1,5 +1,7 @@ #include +#include + namespace Components { Dvar::Var Branding::CGDrawVersion; @@ -125,5 +127,19 @@ namespace Components // Hook CG_DrawFullScreenDebugOverlays so we may render the version when it's appropriate Utils::Hook(0x5AC975, Branding::CG_DrawVersion_Hk, HOOK_CALL).install()->quick(); + + // Console title + if (ZoneBuilder::IsEnabled()) + { + Utils::Hook::Set(0x4289E8, "IW4x (" VERSION "): ZoneBuilder"); + } + else if (Dedicated::IsEnabled()) + { + Utils::Hook::Set(0x4289E8, "IW4x (" VERSION "): Dedicated"); + } + else + { + Utils::Hook::Set(0x4289E8, "IW4x (" VERSION "): Console"); + } } } diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 7f501d0b..1a4e105a 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -1,5 +1,11 @@ #include -#undef MOUSE_MOVED + +#include + +#ifdef MOUSE_MOVED + #undef MOUSE_MOVED +#endif + #include #define REMOVE_HEADERBAR 1 diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index 4234b081..f1d84b3d 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -1,5 +1,7 @@ #include +#include + namespace Components { Utils::Hook Exception::SetFilterHook; diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index 6816d8e2..9d70ef35 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -1,5 +1,7 @@ #include +#include + #define NEWS_MOTD_DEFAULT "Welcome to IW4x Multiplayer!" namespace Components diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index fbf30e6c..a43d1d2e 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -1,5 +1,7 @@ #include +#include + namespace Components { Party::JoinContainer Party::Container; @@ -313,13 +315,15 @@ namespace Components // Basic info handler Network::OnClientPacket("getInfo", [](const Network::Address& address, [[maybe_unused]] const std::string& data) { - int botCount = 0; - int clientCount = 0; - int maxclientCount = *Game::svs_clientCount; + auto botCount = 0; + auto clientCount = 0; + auto maxClientCount = *Game::svs_clientCount; + const auto securityLevel = Dvar::Var("sv_securityLevel").get(); + const auto password = Dvar::Var("g_password").get(); - if (maxclientCount) + if (maxClientCount) { - for (int i = 0; i < maxclientCount; ++i) + for (int i = 0; i < maxClientCount; ++i) { if (Game::svs_clients[i].header.state >= Game::CS_CONNECTED) { @@ -330,7 +334,7 @@ namespace Components } else { - maxclientCount = Dvar::Var("party_maxplayers").get(); + maxClientCount = Dvar::Var("party_maxplayers").get(); clientCount = Game::PartyHost_CountMembers(reinterpret_cast(0x1081C00)); } @@ -341,16 +345,16 @@ namespace Components info.set("gametype", (*Game::sv_gametype)->current.string); info.set("fs_game", (*Game::fs_gameDirVar)->current.string); info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().bits)); - info.set("clients", Utils::String::VA("%i", clientCount)); - info.set("bots", Utils::String::VA("%i", botCount)); - info.set("sv_maxclients", Utils::String::VA("%i", maxclientCount)); - info.set("protocol", Utils::String::VA("%i", PROTOCOL)); + info.set("clients", std::to_string(clientCount)); + info.set("bots", std::to_string(botCount)); + info.set("sv_maxclients", std::to_string(maxClientCount)); + info.set("protocol", std::to_string(PROTOCOL)); info.set("shortversion", SHORTVERSION); - info.set("checksum", Utils::String::VA("%d", Game::Sys_Milliseconds())); - info.set("mapname", Dvar::Var("mapname").get()); - info.set("isPrivate", (Dvar::Var("g_password").get().size() ? "1" : "0")); + info.set("checksum", std::to_string(Game::Sys_Milliseconds())); + info.set("mapname", Dvar::Var("mapname").get()); + info.set("isPrivate", password.empty() ? "1" : "0"); info.set("hc", (Dvar::Var("g_hardcore").get() ? "1" : "0")); - info.set("securityLevel", Utils::String::VA("%i", Dvar::Var("sv_securityLevel").get())); + info.set("securityLevel", std::to_string(securityLevel)); info.set("sv_running", (Dedicated::IsRunning() ? "1" : "0")); info.set("aimAssist", (Gamepad::sv_allowAimAssist.get() ? "1" : "0")); info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0")); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index fc8889e4..b68e267e 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -367,20 +367,6 @@ namespace Components // fs_basegame Utils::Hook::Set(0x6431D1, BASEGAME); - // console title - if (ZoneBuilder::IsEnabled()) - { - Utils::Hook::Set(0x4289E8, "IW4x (" VERSION "): ZoneBuilder"); - } - else if (Dedicated::IsEnabled()) - { - Utils::Hook::Set(0x4289E8, "IW4x (" VERSION "): Dedicated"); - } - else - { - Utils::Hook::Set(0x4289E8, "IW4x (" VERSION "): Console"); - } - // window title Utils::Hook::Set(0x5076A0, "IW4x: Multiplayer"); diff --git a/src/Components/Modules/ServerInfo.cpp b/src/Components/Modules/ServerInfo.cpp index ff90f9b4..e161ab5c 100644 --- a/src/Components/Modules/ServerInfo.cpp +++ b/src/Components/Modules/ServerInfo.cpp @@ -1,5 +1,7 @@ #include +#include + namespace Components { ServerInfo::Container ServerInfo::PlayerContainer; @@ -129,6 +131,7 @@ namespace Components Utils::InfoString ServerInfo::GetInfo() { auto maxClientCount = *Game::svs_clientCount; + const auto password = Dvar::Var("g_password").get(); if (!maxClientCount) { @@ -137,12 +140,12 @@ namespace Components Utils::InfoString info(Game::Dvar_InfoString_Big(Game::DVAR_SERVERINFO)); info.set("gamename", "IW4"); - info.set("sv_maxclients", Utils::String::VA("%i", maxClientCount)); - info.set("protocol", Utils::String::VA("%i", PROTOCOL)); + info.set("sv_maxclients", std::to_string(maxClientCount)); + info.set("protocol", std::to_string(PROTOCOL)); info.set("shortversion", SHORTVERSION); info.set("version", (*Game::version)->current.string); info.set("mapname", (*Game::sv_mapname)->current.string); - info.set("isPrivate", (Dvar::Var("g_password").get().empty() ? "0" : "1")); + info.set("isPrivate", password.empty() ? "0" : "1"); info.set("checksum", Utils::String::VA("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(Utils::String::VA("%u", Game::Sys_Milliseconds())))); info.set("aimAssist", (Gamepad::sv_allowAimAssist.get() ? "1" : "0")); info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0")); diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 18ef579f..6f06ef46 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -1,5 +1,7 @@ #include +#include + namespace Components { bool ServerList::SortAsc = true; @@ -574,8 +576,7 @@ namespace Components } } - if (info.get("gamename") == "IW4" - && server.matchType + if (info.get("gamename") == "IW4"s && server.matchType #if !defined(DEBUG) && defined(VERSION_FILTER) && ServerList::CompareVersion(server.shortversion, SHORTVERSION) #endif diff --git a/src/Components/Modules/Singleton.cpp b/src/Components/Modules/Singleton.cpp index 148bc825..d0b0cefd 100644 --- a/src/Components/Modules/Singleton.cpp +++ b/src/Components/Modules/Singleton.cpp @@ -1,19 +1,21 @@ #include +#include + namespace Components { bool Singleton::FirstInstance = true; bool Singleton::IsFirstInstance() { - return Singleton::FirstInstance; + return FirstInstance; } Singleton::Singleton() { if (Flags::HasFlag("version")) { - printf("IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n"); + printf("%s", "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n"); printf("%d\n", REVISION); ExitProcess(0); } @@ -22,9 +24,9 @@ namespace Components if (Loader::IsPerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return; - Singleton::FirstInstance = (CreateMutexA(nullptr, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS); + FirstInstance = (CreateMutexA(nullptr, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS); - if (!Singleton::FirstInstance && !ConnectProtocol::Used() && MessageBoxA(nullptr, "Do you want to start another instance?\nNot all features will be available!", "Game already running", MB_ICONEXCLAMATION | MB_YESNO) == IDNO) + if (!FirstInstance && !ConnectProtocol::Used() && MessageBoxA(nullptr, "Do you want to start another instance?\nNot all features will be available!", "Game already running", MB_ICONEXCLAMATION | MB_YESNO) == IDNO) { ExitProcess(0); } diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 8b55e5f8..2b64618d 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1,4 +1,7 @@ #include + +#include + #include "AssetInterfaces/ILocalizeEntry.hpp" namespace Components diff --git a/src/Resource.rc b/src/Resource.rc index b04f455f..cda9e955 100644 --- a/src/Resource.rc +++ b/src/Resource.rc @@ -2,7 +2,8 @@ // #pragma code_page(65001) -#include "STDInclude.hpp" +#include +#include #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -70,7 +71,7 @@ BEGIN #endif VALUE "FileVersion", SHORTVERSION VALUE "InternalName", "iw4x" - VALUE "LegalCopyright", "Copyright 2017 The IW4x Team. All rights reserved." + VALUE "LegalCopyright", "Copyright 2022 The IW4x Team. All rights reserved." VALUE "OriginalFilename", "iw4x.dll" VALUE "ProductName", "IW4x" VALUE "ProductVersion", SHORTVERSION diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index e1f4d8cc..2e994240 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -1,8 +1,5 @@ #pragma once -// Version number -#include "version.h" - #ifndef RC_INVOKED #define VC_EXTRALEAN