[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 66 additions and 43 deletions

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <version.hpp>
namespace Components namespace Components
{ {
Dvar::Var Branding::CGDrawVersion; Dvar::Var Branding::CGDrawVersion;
@ -125,5 +127,19 @@ namespace Components
// Hook CG_DrawFullScreenDebugOverlays so we may render the version when it's appropriate // Hook CG_DrawFullScreenDebugOverlays so we may render the version when it's appropriate
Utils::Hook(0x5AC975, Branding::CG_DrawVersion_Hk, HOOK_CALL).install()->quick(); 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> #include <STDInclude.hpp>
#undef MOUSE_MOVED
#include <version.hpp>
#ifdef MOUSE_MOVED
#undef MOUSE_MOVED
#endif
#include <curses.h> #include <curses.h>
#define REMOVE_HEADERBAR 1 #define REMOVE_HEADERBAR 1

View File

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

View File

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

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <version.hpp>
namespace Components namespace Components
{ {
Party::JoinContainer Party::Container; Party::JoinContainer Party::Container;
@ -313,13 +315,15 @@ namespace Components
// Basic info handler // Basic info handler
Network::OnClientPacket("getInfo", [](const Network::Address& address, [[maybe_unused]] const std::string& data) Network::OnClientPacket("getInfo", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
{ {
int botCount = 0; auto botCount = 0;
int clientCount = 0; auto clientCount = 0;
int maxclientCount = *Game::svs_clientCount; 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) if (Game::svs_clients[i].header.state >= Game::CS_CONNECTED)
{ {
@ -330,7 +334,7 @@ namespace Components
} }
else else
{ {
maxclientCount = Dvar::Var("party_maxplayers").get<int>(); maxClientCount = Dvar::Var("party_maxplayers").get<int>();
clientCount = Game::PartyHost_CountMembers(reinterpret_cast<Game::PartyData*>(0x1081C00)); 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("gametype", (*Game::sv_gametype)->current.string);
info.set("fs_game", (*Game::fs_gameDirVar)->current.string); info.set("fs_game", (*Game::fs_gameDirVar)->current.string);
info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().bits)); info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().bits));
info.set("clients", Utils::String::VA("%i", clientCount)); info.set("clients", std::to_string(clientCount));
info.set("bots", Utils::String::VA("%i", botCount)); info.set("bots", std::to_string(botCount));
info.set("sv_maxclients", Utils::String::VA("%i", maxclientCount)); info.set("sv_maxclients", std::to_string(maxClientCount));
info.set("protocol", Utils::String::VA("%i", PROTOCOL)); info.set("protocol", std::to_string(PROTOCOL));
info.set("shortversion", SHORTVERSION); info.set("shortversion", SHORTVERSION);
info.set("checksum", Utils::String::VA("%d", Game::Sys_Milliseconds())); info.set("checksum", std::to_string(Game::Sys_Milliseconds()));
info.set("mapname", Dvar::Var("mapname").get<const char*>()); info.set("mapname", Dvar::Var("mapname").get<std::string>());
info.set("isPrivate", (Dvar::Var("g_password").get<std::string>().size() ? "1" : "0")); info.set("isPrivate", password.empty() ? "1" : "0");
info.set("hc", (Dvar::Var("g_hardcore").get<bool>() ? "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("sv_running", (Dedicated::IsRunning() ? "1" : "0"));
info.set("aimAssist", (Gamepad::sv_allowAimAssist.get<bool>() ? "1" : "0")); info.set("aimAssist", (Gamepad::sv_allowAimAssist.get<bool>() ? "1" : "0"));
info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0")); info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0"));

View File

@ -367,20 +367,6 @@ namespace Components
// fs_basegame // fs_basegame
Utils::Hook::Set<const char*>(0x6431D1, 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 // window title
Utils::Hook::Set<const char*>(0x5076A0, "IW4x: Multiplayer"); Utils::Hook::Set<const char*>(0x5076A0, "IW4x: Multiplayer");

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <version.hpp>
namespace Components namespace Components
{ {
ServerInfo::Container ServerInfo::PlayerContainer; ServerInfo::Container ServerInfo::PlayerContainer;
@ -129,6 +131,7 @@ namespace Components
Utils::InfoString ServerInfo::GetInfo() Utils::InfoString ServerInfo::GetInfo()
{ {
auto maxClientCount = *Game::svs_clientCount; auto maxClientCount = *Game::svs_clientCount;
const auto password = Dvar::Var("g_password").get<std::string>();
if (!maxClientCount) if (!maxClientCount)
{ {
@ -137,12 +140,12 @@ namespace Components
Utils::InfoString info(Game::Dvar_InfoString_Big(Game::DVAR_SERVERINFO)); Utils::InfoString info(Game::Dvar_InfoString_Big(Game::DVAR_SERVERINFO));
info.set("gamename", "IW4"); info.set("gamename", "IW4");
info.set("sv_maxclients", Utils::String::VA("%i", maxClientCount)); info.set("sv_maxclients", std::to_string(maxClientCount));
info.set("protocol", Utils::String::VA("%i", PROTOCOL)); info.set("protocol", std::to_string(PROTOCOL));
info.set("shortversion", SHORTVERSION); info.set("shortversion", SHORTVERSION);
info.set("version", (*Game::version)->current.string); info.set("version", (*Game::version)->current.string);
info.set("mapname", (*Game::sv_mapname)->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("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("aimAssist", (Gamepad::sv_allowAimAssist.get<bool>() ? "1" : "0"));
info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0")); info.set("voiceChat", (Voice::SV_VoiceEnabled() ? "1" : "0"));

View File

@ -1,5 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <version.hpp>
namespace Components namespace Components
{ {
bool ServerList::SortAsc = true; bool ServerList::SortAsc = true;
@ -574,8 +576,7 @@ namespace Components
} }
} }
if (info.get("gamename") == "IW4" if (info.get("gamename") == "IW4"s && server.matchType
&& server.matchType
#if !defined(DEBUG) && defined(VERSION_FILTER) #if !defined(DEBUG) && defined(VERSION_FILTER)
&& ServerList::CompareVersion(server.shortversion, SHORTVERSION) && ServerList::CompareVersion(server.shortversion, SHORTVERSION)
#endif #endif

View File

@ -1,19 +1,21 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <version.hpp>
namespace Components namespace Components
{ {
bool Singleton::FirstInstance = true; bool Singleton::FirstInstance = true;
bool Singleton::IsFirstInstance() bool Singleton::IsFirstInstance()
{ {
return Singleton::FirstInstance; return FirstInstance;
} }
Singleton::Singleton() Singleton::Singleton()
{ {
if (Flags::HasFlag("version")) if (Flags::HasFlag("version"))
{ {
printf("IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n"); printf("%s", "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n");
printf("%d\n", REVISION); printf("%d\n", REVISION);
ExitProcess(0); ExitProcess(0);
} }
@ -22,9 +24,9 @@ namespace Components
if (Loader::IsPerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return; 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); ExitProcess(0);
} }

View File

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

View File

@ -2,7 +2,8 @@
// //
#pragma code_page(65001) #pragma code_page(65001)
#include "STDInclude.hpp" #include <STDInclude.hpp>
#include <version.hpp>
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -70,7 +71,7 @@ BEGIN
#endif #endif
VALUE "FileVersion", SHORTVERSION VALUE "FileVersion", SHORTVERSION
VALUE "InternalName", "iw4x" 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 "OriginalFilename", "iw4x.dll"
VALUE "ProductName", "IW4x" VALUE "ProductName", "IW4x"
VALUE "ProductVersion", SHORTVERSION VALUE "ProductVersion", SHORTVERSION

View File

@ -1,8 +1,5 @@
#pragma once #pragma once
// Version number
#include "version.h"
#ifndef RC_INVOKED #ifndef RC_INVOKED
#define VC_EXTRALEAN #define VC_EXTRALEAN