Fixed compile errors on C++20

This commit is contained in:
INeedBots 2020-12-09 13:13:34 -06:00
parent 7d8050a7c6
commit eeb70a7da4
24 changed files with 64 additions and 64 deletions

View File

@ -13,7 +13,7 @@ namespace Components
~ClanTags(); ~ClanTags();
private: private:
static std::string ClanTags::Tags[18]; static std::string Tags[18];
static void DrawPlayerNameOnScoreboard(); static void DrawPlayerNameOnScoreboard();

View File

@ -31,7 +31,7 @@ namespace Components
if (mode != "append"s && mode != "write"s) if (mode != "append"s && mode != "write"s)
{ {
Game::Com_Printf(0, "^3fileWrite: mode not defined or was wrong, defaulting to 'write'\n"); Game::Com_Printf(0, "^3fileWrite: mode not defined or was wrong, defaulting to 'write'\n");
mode = "write"; mode = const_cast<char*>("write");
} }
if (mode == "write"s) if (mode == "write"s)

View File

@ -25,7 +25,7 @@ namespace Components
char* Command::ClientParams::get(size_t index) char* Command::ClientParams::get(size_t index)
{ {
if (index >= this->length()) return ""; if (index >= this->length()) return const_cast<char*>("");
return Game::cmd_argv[this->commandId][index]; return Game::cmd_argv[this->commandId][index];
} }
@ -36,7 +36,7 @@ namespace Components
char* Command::ServerParams::get(size_t index) char* Command::ServerParams::get(size_t index)
{ {
if (index >= this->length()) return ""; if (index >= this->length()) return const_cast<char*>("");
return Game::cmd_argv_sv[this->commandId][index]; return Game::cmd_argv_sv[this->commandId][index];
} }

View File

@ -537,7 +537,7 @@ namespace Components
Console::Console() Console::Console()
{ {
// Console '%s: %s> ' string // Console '%s: %s> ' string
Utils::Hook::Set<char*>(0x5A44B4, "IW4x: " VERSION "> "); Utils::Hook::Set<const char*>(0x5A44B4, "IW4x: " VERSION "> ");
// Patch console color // Patch console color
static float consoleColor[] = { 0.70f, 1.00f, 0.00f, 1.00f }; static float consoleColor[] = { 0.70f, 1.00f, 0.00f, 1.00f };

View File

@ -27,7 +27,7 @@ namespace Components
return const_cast<char*>(this->dvar->current.string); return const_cast<char*>(this->dvar->current.string);
} }
return ""; return const_cast<char*>("");
} }
template <> const char* Dvar::Var::get() template <> const char* Dvar::Var::get()
{ {

View File

@ -186,7 +186,7 @@ namespace Components
{ {
std::lock_guard<std::recursive_mutex> _(Friends::Mutex); std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
const unsigned int modId = *reinterpret_cast<unsigned int*>("IW4x") | 0x80000000; const unsigned int modId = *reinterpret_cast<unsigned int*>(const_cast<char*>("IW4x")) | 0x80000000;
// Split up the list // Split up the list
for (auto entry : Friends::FriendsList) for (auto entry : Friends::FriendsList)

View File

@ -15,7 +15,7 @@ namespace Components
static void Add(const std::string& menu); static void Add(const std::string& menu);
static Game::MenuList* Menus::LoadCustomMenuList(const std::string& menu, Utils::Memory::Allocator* allocator); static Game::MenuList* LoadCustomMenuList(const std::string& menu, Utils::Memory::Allocator* allocator);
static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(Game::menuDef_t* menudef); static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(Game::menuDef_t* menudef);
static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(const std::string& file); static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(const std::string& file);

View File

@ -364,7 +364,7 @@ namespace Components
Utils::Hook::Set<BYTE>(0x4050A5, 125); Utils::Hook::Set<BYTE>(0x4050A5, 125);
// Parse port as short in Net_AddrToString // Parse port as short in Net_AddrToString
Utils::Hook::Set<char*>(0x4698E3, "%u.%u.%u.%u:%hu"); Utils::Hook::Set<const char*>(0x4698E3, "%u.%u.%u.%u:%hu");
// Install startup handler // Install startup handler
Utils::Hook(0x4FD4D4, Network::NetworkStartStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x4FD4D4, Network::NetworkStartStub, HOOK_JUMP).install()->quick();

View File

@ -210,7 +210,7 @@ namespace Components
// Force xblive_privatematch 0 and rename it // Force xblive_privatematch 0 and rename it
//Utils::Hook::Set<BYTE>(0x420A6A, 4); //Utils::Hook::Set<BYTE>(0x420A6A, 4);
Utils::Hook::Set<BYTE>(0x420A6C, 0); Utils::Hook::Set<BYTE>(0x420A6C, 0);
Utils::Hook::Set<char*>(0x420A6E, "xblive_privateserver"); Utils::Hook::Set<const char*>(0x420A6E, "xblive_privateserver");
// Remove migration shutdown, it causes crashes and will be destroyed when erroring anyways // Remove migration shutdown, it causes crashes and will be destroyed when erroring anyways
Utils::Hook::Nop(0x5A8E1C, 12); Utils::Hook::Nop(0x5A8E1C, 12);
@ -244,9 +244,9 @@ namespace Components
//Utils::Hook(0x4D5D51, Party::RegisterMinPlayers, HOOK_CALL).install()->quick(); //Utils::Hook(0x4D5D51, Party::RegisterMinPlayers, HOOK_CALL).install()->quick();
// Set ui_maxclients to sv_maxclients // Set ui_maxclients to sv_maxclients
Utils::Hook::Set<char*>(0x42618F, "sv_maxclients"); Utils::Hook::Set<const char*>(0x42618F, "sv_maxclients");
Utils::Hook::Set<char*>(0x4D3756, "sv_maxclients"); Utils::Hook::Set<const char*>(0x4D3756, "sv_maxclients");
Utils::Hook::Set<char*>(0x5E3772, "sv_maxclients"); Utils::Hook::Set<const char*>(0x5E3772, "sv_maxclients");
// Unlatch maxclient dvars // Unlatch maxclient dvars
Utils::Hook::Xor<BYTE>(0x426187, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<BYTE>(0x426187, Game::dvar_flag::DVAR_FLAG_LATCHED);

View File

@ -150,7 +150,7 @@ namespace Components
Playlist::Playlist() Playlist::Playlist()
{ {
// Default playlists // Default playlists
Utils::Hook::Set<char*>(0x60B06E, "playlists_default.info"); Utils::Hook::Set<const char*>(0x60B06E, "playlists_default.info");
// disable playlist download function // disable playlist download function
Utils::Hook::Set<BYTE>(0x4D4790, 0xC3); Utils::Hook::Set<BYTE>(0x4D4790, 0xC3);

View File

@ -159,7 +159,7 @@ namespace Components
__declspec(naked) void QuickPatch::InvalidNameStub() __declspec(naked) void QuickPatch::InvalidNameStub()
{ {
static char* kick_reason = "Invalid name detected."; static const char* kick_reason = "Invalid name detected.";
__asm __asm
{ {
@ -216,11 +216,11 @@ namespace Components
{ {
static std::vector < char * > values = static std::vector < char * > values =
{ {
"auto", const_cast<char*>("auto"),
"standard", const_cast<char*>("standard"),
"wide 16:10", const_cast<char*>("wide 16:10"),
"wide 16:9", const_cast<char*>("wide 16:9"),
"custom", const_cast<char*>("custom"),
nullptr, nullptr,
}; };
@ -443,16 +443,16 @@ namespace Components
Utils::Hook::Set<DWORD>(0x45ACE0, 0xC301B0); Utils::Hook::Set<DWORD>(0x45ACE0, 0xC301B0);
// fs_basegame // fs_basegame
Utils::Hook::Set<char*>(0x6431D1, BASEGAME); Utils::Hook::Set<const char*>(0x6431D1, BASEGAME);
// UI version string // UI version string
Utils::Hook::Set<char*>(0x43F73B, "IW4x: " VERSION); Utils::Hook::Set<const char*>(0x43F73B, "IW4x: " VERSION);
// console version string // console version string
Utils::Hook::Set<char*>(0x4B12BB, "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")"); Utils::Hook::Set<const char*>(0x4B12BB, "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")");
// version string // version string
Utils::Hook::Set<char*>(0x60BD56, "IW4x (" VERSION ")"); Utils::Hook::Set<const char*>(0x60BD56, "IW4x (" VERSION ")");
// 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 };
@ -469,33 +469,33 @@ namespace Components
// console title // console title
if (ZoneBuilder::IsEnabled()) if (ZoneBuilder::IsEnabled())
{ {
Utils::Hook::Set<char*>(0x4289E8, "IW4x (" VERSION "): ZoneBuilder"); Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): ZoneBuilder");
} }
else if (Dedicated::IsEnabled()) else if (Dedicated::IsEnabled())
{ {
Utils::Hook::Set<char*>(0x4289E8, "IW4x (" VERSION "): Dedicated"); Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): Dedicated");
} }
else else
{ {
Utils::Hook::Set<char*>(0x4289E8, "IW4x (" VERSION "): Console"); Utils::Hook::Set<const char*>(0x4289E8, "IW4x (" VERSION "): Console");
} }
// window title // window title
Utils::Hook::Set<char*>(0x5076A0, "IW4x: Multiplayer"); Utils::Hook::Set<const char*>(0x5076A0, "IW4x: Multiplayer");
// sv_hostname // sv_hostname
Utils::Hook::Set<char*>(0x4D378B, "IW4Host"); Utils::Hook::Set<const char*>(0x4D378B, "IW4Host");
// shortversion // shortversion
Utils::Hook::Set<char*>(0x60BD91, SHORTVERSION); Utils::Hook::Set<const char*>(0x60BD91, SHORTVERSION);
// console logo // console logo
Utils::Hook::Set<char*>(0x428A66, BASEGAME "/images/logo.bmp"); Utils::Hook::Set<const char*>(0x428A66, BASEGAME "/images/logo.bmp");
// splash logo // splash logo
Utils::Hook::Set<char*>(0x475F9E, BASEGAME "/images/splash.bmp"); Utils::Hook::Set<const char*>(0x475F9E, BASEGAME "/images/splash.bmp");
Utils::Hook::Set<char*>(0x4876C6, "Successfully read stats data\n"); Utils::Hook::Set<const char*>(0x4876C6, "Successfully read stats data\n");
// Numerical ping (cg_scoreboardPingText 1) // Numerical ping (cg_scoreboardPingText 1)
Utils::Hook::Set<BYTE>(0x45888E, 1); Utils::Hook::Set<BYTE>(0x45888E, 1);
@ -596,21 +596,21 @@ namespace Components
// 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<const char*>(0x60BED2, "unskippablecinematic IW_logo\n");
Utils::Hook::Set<char*>(0x51C2A4, "%s\\" BASEGAME "\\video\\%s.bik"); Utils::Hook::Set<const 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<const char*>(0x5E44D8, "logs/games_mp.log");
Utils::Hook::Set<char*>(0x60A90C, "logs/console_mp.log"); Utils::Hook::Set<const char*>(0x60A90C, "logs/console_mp.log");
Utils::Hook::Set<char*>(0x60A918, "logs/console_mp.log"); Utils::Hook::Set<const char*>(0x60A918, "logs/console_mp.log");
// Rename config // Rename config
Utils::Hook::Set<char*>(0x461B4B, CLIENT_CONFIG); Utils::Hook::Set<const char*>(0x461B4B, CLIENT_CONFIG);
Utils::Hook::Set<char*>(0x47DCBB, CLIENT_CONFIG); Utils::Hook::Set<const char*>(0x47DCBB, CLIENT_CONFIG);
Utils::Hook::Set<char*>(0x6098F8, CLIENT_CONFIG); Utils::Hook::Set<const char*>(0x6098F8, CLIENT_CONFIG);
Utils::Hook::Set<char*>(0x60B279, CLIENT_CONFIG); Utils::Hook::Set<const char*>(0x60B279, CLIENT_CONFIG);
Utils::Hook::Set<char*>(0x60BBD4, CLIENT_CONFIG); Utils::Hook::Set<const char*>(0x60BBD4, CLIENT_CONFIG);
// Disable profile system // Disable profile system
// Utils::Hook::Nop(0x60BEB1, 5); // GamerProfile_InitAllProfiles - Causes an error, when calling a harrier killstreak. // Utils::Hook::Nop(0x60BEB1, 5); // GamerProfile_InitAllProfiles - Causes an error, when calling a harrier killstreak.

View File

@ -7,6 +7,6 @@ namespace Components
public: public:
RawFiles(); RawFiles();
static void* RawFiles::LoadModdableRawfileFunc(const char* filename); static void* LoadModdableRawfileFunc(const char* filename);
}; };
} }

View File

@ -371,7 +371,7 @@ namespace Components
UIFeeder::Add(10.0f, Theatre::GetDemoCount, Theatre::GetDemoText, Theatre::SelectDemo); UIFeeder::Add(10.0f, Theatre::GetDemoCount, Theatre::GetDemoText, Theatre::SelectDemo);
// set the configstrings stuff to load the default (empty) string table; this should allow demo recording on all gametypes/maps // set the configstrings stuff to load the default (empty) string table; this should allow demo recording on all gametypes/maps
if (!Dedicated::IsEnabled()) Utils::Hook::Set<char*>(0x47440B, "mp/defaultStringTable.csv"); if (!Dedicated::IsEnabled()) Utils::Hook::Set<const char*>(0x47440B, "mp/defaultStringTable.csv");
// Change font size // Change font size
Utils::Hook::Set<BYTE>(0x5AC854, 2); Utils::Hook::Set<BYTE>(0x5AC854, 2);

View File

@ -22,7 +22,7 @@ namespace Components
return this->token; return this->token;
} }
return ""; return const_cast<char*>("");
} }
template<> const char* UIScript::Token::get() template<> const char* UIScript::Token::get()

View File

@ -510,7 +510,7 @@ namespace Components
// Add branding asset // Add branding asset
void ZoneBuilder::Zone::addBranding() void ZoneBuilder::Zone::addBranding()
{ {
char* data = "FastFile built using the IW4x ZoneBuilder!"; const char* data = "FastFile built using the IW4x ZoneBuilder!";
this->branding = { this->zoneName.data(), static_cast<int>(strlen(data)), 0, data }; this->branding = { this->zoneName.data(), static_cast<int>(strlen(data)), 0, data };
if (this->findAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, this->branding.name) != -1) if (this->findAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, this->branding.name) != -1)
@ -1306,7 +1306,7 @@ namespace Components
// HACK: set language to 'techsets' to load from that dir // HACK: set language to 'techsets' to load from that dir
char* language = Utils::Hook::Get<char*>(0x649E740); char* language = Utils::Hook::Get<char*>(0x649E740);
Utils::Hook::Set<char*>(0x649E740, "techsets"); Utils::Hook::Set<const char*>(0x649E740, "techsets");
// load generated techset fastfiles // load generated techset fastfiles
auto list = Utils::IO::ListFiles("zone/techsets"); auto list = Utils::IO::ListFiles("zone/techsets");
@ -1366,7 +1366,7 @@ namespace Components
info.freeFlags = Game::DB_ZONE_MOD; info.freeFlags = Game::DB_ZONE_MOD;
Game::DB_LoadXAssets(&info, 1, true); Game::DB_LoadXAssets(&info, 1, true);
Utils::Hook::Set<char*>(0x649E740, "techsets"); Utils::Hook::Set<const char*>(0x649E740, "techsets");
i = 0; i = 0;
subCount++; subCount++;

View File

@ -693,7 +693,7 @@ namespace Game
void Vec3Normalize(vec3_t& vec) void Vec3Normalize(vec3_t& vec)
{ {
const auto length = std::sqrt(std::pow(vec[0], 2) + std::pow(vec[1], 2) + std::pow(vec[2], 2)); const float length = static_cast<float>(std::sqrt(std::pow(vec[0], 2) + std::pow(vec[1], 2) + std::pow(vec[2], 2)));
vec[0] /= length; vec[0] /= length;
vec[1] /= length; vec[1] /= length;
vec[2] /= length; vec[2] /= length;

View File

@ -24,7 +24,7 @@ namespace Steam
{ {
if (Components::Dedicated::IsEnabled() || Components::ZoneBuilder::IsEnabled()) // Dedi guid if (Components::Dedicated::IsEnabled() || Components::ZoneBuilder::IsEnabled()) // Dedi guid
{ {
idBits = *reinterpret_cast<unsigned __int64*>(static_cast<char*>("DEDICATE")); idBits = *reinterpret_cast<unsigned __int64*>(const_cast<char*>("DEDICATE"));
} }
else if (Components::Singleton::IsFirstInstance()) // ECDSA guid else if (Components::Singleton::IsFirstInstance()) // ECDSA guid
{ {

View File

@ -154,7 +154,7 @@ namespace Steam
gameID.type = 1; // k_EGameIDTypeGameMod gameID.type = 1; // k_EGameIDTypeGameMod
gameID.appID = Proxy::AppId & 0xFFFFFF; gameID.appID = Proxy::AppId & 0xFFFFFF;
char* modId = "IW4x"; char* modId = const_cast<char*>("IW4x");
gameID.modID = *reinterpret_cast<unsigned int*>(modId) | 0x80000000; gameID.modID = *reinterpret_cast<unsigned int*>(modId) | 0x80000000;
Interface clientUtils(Proxy::ClientEngine->GetIClientUtils(Proxy::SteamPipe)); Interface clientUtils(Proxy::ClientEngine->GetIClientUtils(Proxy::SteamPipe));
@ -194,7 +194,7 @@ namespace Steam
void Proxy::RunMod() void Proxy::RunMod()
{ {
char* command = "-proc "; const char* command = "-proc ";
char* parentProc = strstr(GetCommandLineA(), command); char* parentProc = strstr(GetCommandLineA(), command);
if (parentProc) if (parentProc)

View File

@ -18,7 +18,7 @@ namespace Utils
{ {
if (this->tokenString.empty()) if (this->tokenString.empty())
{ {
this->tokenString.append(reinterpret_cast<uint8_t*>("\0"), 1); this->tokenString.append(reinterpret_cast<uint8_t*>(const_cast<char *>("\0")), 1);
} }
else else
{ {
@ -31,7 +31,7 @@ namespace Utils
if (!i) if (!i)
{ {
// Prepend here, as /dev/urandom says so ;) https://github.com/IW4x/iw4x-client-node/wikis/technical-information#incrementing-the-token // Prepend here, as /dev/urandom says so ;) https://github.com/IW4x/iw4x-client-node/wikis/technical-information#incrementing-the-token
this->tokenString = std::basic_string<uint8_t>(reinterpret_cast<uint8_t*>("\0"), 1) + this->tokenString; this->tokenString = std::basic_string<uint8_t>(reinterpret_cast<uint8_t*>(const_cast<char*>("\0")), 1) + this->tokenString;
break; break;
} }
} }

View File

@ -2,9 +2,9 @@
namespace Utils namespace Utils
{ {
Library::Library(const std::string& buffer, bool _freeOnDestroy) : module(nullptr), freeOnDestroy(_freeOnDestroy) Library::Library(const std::string& buffer, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy)
{ {
this->module = LoadLibraryExA(buffer.data(), nullptr, 0); this->_module = LoadLibraryExA(buffer.data(), nullptr, 0);
} }
Library::~Library() Library::~Library()
@ -22,7 +22,7 @@ namespace Utils
HMODULE Library::getModule() HMODULE Library::getModule()
{ {
return this->module; return this->_module;
} }
void Library::free() void Library::free()
@ -32,6 +32,6 @@ namespace Utils
FreeLibrary(this->getModule()); FreeLibrary(this->getModule());
} }
this->module = nullptr; this->_module = nullptr;
} }
} }

View File

@ -5,7 +5,7 @@ namespace Utils
class Library class Library
{ {
public: public:
Library() : module(nullptr), freeOnDestroy(false) {}; Library() : _module(nullptr), freeOnDestroy(false) {};
Library(const std::string& buffer, bool freeOnDestroy = true); Library(const std::string& buffer, bool freeOnDestroy = true);
~Library(); ~Library();
@ -26,7 +26,7 @@ namespace Utils
void free(); void free();
private: private:
HMODULE module; HMODULE _module;
bool freeOnDestroy; bool freeOnDestroy;
}; };
} }

View File

@ -149,7 +149,7 @@ namespace Utils
std::string FormatBandwidth(size_t bytes, int milliseconds) std::string FormatBandwidth(size_t bytes, int milliseconds)
{ {
static char* sizes[] = static const char* sizes[] =
{ {
"B", "B",
"KB", "KB",

View File

@ -13,7 +13,7 @@ namespace Utils
VAProvider() : currentBuffer(0) {} VAProvider() : currentBuffer(0) {}
~VAProvider() {} ~VAProvider() {}
char* get(const char* format, va_list ap) const char* get(const char* format, va_list ap)
{ {
++this->currentBuffer %= ARRAYSIZE(this->stringPool); ++this->currentBuffer %= ARRAYSIZE(this->stringPool);
auto entry = &this->stringPool[this->currentBuffer]; auto entry = &this->stringPool[this->currentBuffer];

View File

@ -15,7 +15,7 @@ namespace Utils
bool IsWineEnvironment(); bool IsWineEnvironment();
unsigned long GetParentProcessId(); unsigned long GetParentProcessId();
size_t GetModuleSize(HMODULE module); size_t GetModuleSize(HMODULE);
void* GetThreadStartAddress(HANDLE hThread); void* GetThreadStartAddress(HANDLE hThread);
HMODULE GetNTDLL(); HMODULE GetNTDLL();