[General]: Remove unnecessary global header (#600)

* [General]: Remove unnecessary global header

* [ServerList]: Fix comp
This commit is contained in:
Edo
2022-11-26 17:38:34 +00:00
committed by GitHub
parent 62c5211a94
commit 44098c51cd
12 changed files with 66 additions and 43 deletions

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
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<const char*>(0x4289E8, "IW4x (" VERSION "): ZoneBuilder");
}
else if (Dedicated::IsEnabled())
{
Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): Dedicated");
}
else
{
Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): Console");
}
}
}

View File

@ -1,5 +1,11 @@
#include <STDInclude.hpp>
#undef MOUSE_MOVED
#include <version.hpp>
#ifdef MOUSE_MOVED
#undef MOUSE_MOVED
#endif
#include <curses.h>
#define REMOVE_HEADERBAR 1

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
namespace Components
{
Utils::Hook Exception::SetFilterHook;

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
#define NEWS_MOTD_DEFAULT "Welcome to IW4x Multiplayer!"
namespace Components

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
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<int>();
const auto password = Dvar::Var("g_password").get<std::string>();
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<int>();
maxClientCount = Dvar::Var("party_maxplayers").get<int>();
clientCount = Game::PartyHost_CountMembers(reinterpret_cast<Game::PartyData*>(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<const char*>());
info.set("isPrivate", (Dvar::Var("g_password").get<std::string>().size() ? "1" : "0"));
info.set("checksum", std::to_string(Game::Sys_Milliseconds()));
info.set("mapname", Dvar::Var("mapname").get<std::string>());
info.set("isPrivate", password.empty() ? "1" : "0");
info.set("hc", (Dvar::Var("g_hardcore").get<bool>() ? "1" : "0"));
info.set("securityLevel", Utils::String::VA("%i", Dvar::Var("sv_securityLevel").get<int>()));
info.set("securityLevel", std::to_string(securityLevel));
info.set("sv_running", (Dedicated::IsRunning() ? "1" : "0"));
info.set("aimAssist", (Gamepad::sv_allowAimAssist.get<bool>() ? "1" : "0"));
info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0"));

View File

@ -367,20 +367,6 @@ namespace Components
// fs_basegame
Utils::Hook::Set<const char*>(0x6431D1, BASEGAME);
// console title
if (ZoneBuilder::IsEnabled())
{
Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): ZoneBuilder");
}
else if (Dedicated::IsEnabled())
{
Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): Dedicated");
}
else
{
Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): Console");
}
// window title
Utils::Hook::Set<const char*>(0x5076A0, "IW4x: Multiplayer");

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
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<std::string>();
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<std::string>().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<bool>() ? "1" : "0"));
info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0"));

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
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

View File

@ -1,19 +1,21 @@
#include <STDInclude.hpp>
#include <version.hpp>
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);
}

View File

@ -1,4 +1,7 @@
#include <STDInclude.hpp>
#include <version.hpp>
#include "AssetInterfaces/ILocalizeEntry.hpp"
namespace Components