diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b130dd74..b3b96c66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: uses: microsoft/setup-msbuild@v1.1.3 - name: Generate project files - run: tools/premake5 vs2022 --ci-build + run: tools/premake5 vs2022 - name: Set up problem matching uses: ammaraskar/msvc-problem-matcher@master diff --git a/premake5.lua b/premake5.lua index 5130f021..f1e054d5 100644 --- a/premake5.lua +++ b/premake5.lua @@ -77,11 +77,6 @@ newoption { description = "Enable development builds of the client." } -newoption { - trigger = "ci-build", - description = "Enable CI builds of the client." -} - newaction { trigger = "version", description = "Returns the version string for the current commit of the source code.", @@ -249,7 +244,7 @@ workspace "boiii" defines {"DEV_BUILD"} end - if _OPTIONS["ci-build"] then + if os.getenv("CI") then defines {"CI"} end @@ -262,7 +257,7 @@ workspace "boiii" filter "configurations:Release" optimize "Size" buildoptions {"/GL"} - linkoptions { "/IGNORE:4702", "/LTCG" } + linkoptions {"/IGNORE:4702", "/LTCG"} defines {"NDEBUG"} flags {"FatalCompileWarnings"} filter {} diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index d6167021..c56659be 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -77,7 +77,7 @@ namespace branding std::string str = "BOIII: " VERSION; //str += "\n\n" + get_connectivity_info(); - game::R_AddCmdDrawText(str.data(), 0x7FFFFFFF, font, static_cast(x), + game::R_AddCmdDrawText(str.data(), std::numeric_limits::max(), font, static_cast(x), y + static_cast(font[2]) * scale, scale, scale, 0.0f, color, game::ITEM_TEXTSTYLE_NORMAL); } diff --git a/src/client/component/network.cpp b/src/client/component/network.cpp index d2eba869..8379f9c4 100644 --- a/src/client/component/network.cpp +++ b/src/client/component/network.cpp @@ -1,5 +1,4 @@ #include -#include "network.hpp" #include "loader/component_loader.hpp" #include "scheduler.hpp" @@ -9,6 +8,8 @@ #include #include +#include "network.hpp" + namespace network { namespace diff --git a/src/client/component/network.hpp b/src/client/component/network.hpp index 3014cc15..aba46009 100644 --- a/src/client/component/network.hpp +++ b/src/client/component/network.hpp @@ -1,5 +1,4 @@ #pragma once -#include "game/game.hpp" namespace network { diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp index c843f170..57afa938 100644 --- a/src/client/component/party.cpp +++ b/src/client/component/party.cpp @@ -1,11 +1,11 @@ #include #include "loader/component_loader.hpp" +#include "game/game.hpp" +#include "steam/steam.hpp" #include "party.hpp" #include "network.hpp" #include "scheduler.hpp" -#include "game/game.hpp" -#include "steam/steam.hpp" #include #include diff --git a/src/client/component/party.hpp b/src/client/component/party.hpp index dfd278c7..b26ed164 100644 --- a/src/client/component/party.hpp +++ b/src/client/component/party.hpp @@ -1,6 +1,4 @@ #pragma once - -#include #include namespace party diff --git a/src/client/component/scheduler.cpp b/src/client/component/scheduler.cpp index 23978d64..0c75b321 100644 --- a/src/client/component/scheduler.cpp +++ b/src/client/component/scheduler.cpp @@ -5,7 +5,6 @@ #include "game/game.hpp" -#include #include #include #include diff --git a/src/client/component/splash.cpp b/src/client/component/splash.cpp index dd8aaa6b..70ac2855 100644 --- a/src/client/component/splash.cpp +++ b/src/client/component/splash.cpp @@ -1,5 +1,6 @@ #include #include "loader/component_loader.hpp" + #include "splash.hpp" #include "resource.hpp" diff --git a/src/client/component/steam_proxy.cpp b/src/client/component/steam_proxy.cpp index 9aae3f66..458db7bc 100644 --- a/src/client/component/steam_proxy.cpp +++ b/src/client/component/steam_proxy.cpp @@ -1,7 +1,5 @@ #include #include "loader/component_loader.hpp" -#include "steam_proxy.hpp" -#include "scheduler.hpp" #include #include @@ -12,6 +10,9 @@ #include "steam/interface.hpp" #include "steam/steam.hpp" +#include "steam_proxy.hpp" +#include "scheduler.hpp" + namespace steam_proxy { namespace @@ -152,7 +153,7 @@ namespace steam_proxy const auto self = utils::nt::library::get_by_address(start_mod_unsafe); const auto path = self.get_path(); - const std::string cmdline = utils::string::va("\"%s\" -proc %d", path.data(), GetCurrentProcessId()); + const auto* cmdline = utils::string::va("\"%s\" -proc %d", path.generic_string().data(), GetCurrentProcessId()); steam::game_id game_id; game_id.raw.type = 1; // k_EGameIDTypeGameMod @@ -161,7 +162,7 @@ namespace steam_proxy const auto* mod_id = "bo3"; game_id.raw.mod_id = *reinterpret_cast(mod_id) | 0x80000000; - client_user.invoke("SpawnProcess", path.data(), cmdline.data(), our_directory, + client_user.invoke("SpawnProcess", path.generic_string().data(), cmdline, our_directory, &game_id.bits, title.data(), 0, 0, 0); return ownership_state::success; diff --git a/src/client/component/steam_proxy.hpp b/src/client/component/steam_proxy.hpp index b9709aab..16b45e85 100644 --- a/src/client/component/steam_proxy.hpp +++ b/src/client/component/steam_proxy.hpp @@ -1,5 +1,4 @@ #pragma once -#include namespace steam_proxy { diff --git a/src/client/component/updater.cpp b/src/client/component/updater.cpp index dc54ae01..8c0d7eec 100644 --- a/src/client/component/updater.cpp +++ b/src/client/component/updater.cpp @@ -42,7 +42,7 @@ namespace updater std::string get_self_file() { const auto self = utils::nt::library::get_by_address(get_self_file); - return self.get_path(); + return self.get_path().generic_string(); } std::string get_leftover_file() diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 4cf6548b..acd5deb6 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -6,8 +6,7 @@ namespace game { -#define Com_Error(code, fmt, ...) \ - Com_Error_(__FILE__, __LINE__, code, fmt, ##__VA_ARGS__) +#define Com_Error(code, fmt, ...) Com_Error_(__FILE__, __LINE__, code, fmt, ##__VA_ARGS__) // CL WEAK symbol() const + { + return Sys_GetTLS()->cmdArgs; + } + }; + + // Re-implementations eModes Com_SessionMode_GetMode(); } diff --git a/src/client/main.cpp b/src/client/main.cpp index 531a50cc..7714b974 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -83,7 +83,7 @@ namespace auto game_path = std::filesystem::path(game_file); game_path.replace_extension(".start"); - utils::io::remove_file(game_path.generic_string()); + utils::io::remove_file(game_path); } PIMAGE_TLS_CALLBACK* get_tls_callbacks() diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index f6722d42..f0152758 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -85,7 +85,7 @@ #include #define RAPIDJSON_NOEXCEPT -#define RAPIDJSON_ASSERT(cond) if(cond); else throw std::runtime_error("rapidjson assert fail"); +#define RAPIDJSON_ASSERT(cond) if (cond); else throw std::runtime_error("rapidjson assert fail"); #include #include diff --git a/src/client/steam/interfaces/friends.cpp b/src/client/steam/interfaces/friends.cpp index 2d6f8c9d..14479d5f 100644 --- a/src/client/steam/interfaces/friends.cpp +++ b/src/client/steam/interfaces/friends.cpp @@ -1,8 +1,9 @@ #include #include "../steam.hpp" -#include "component/steam_proxy.hpp" -//#include +#include + +#include "component/steam_proxy.hpp" namespace steam { diff --git a/src/client/steam/interfaces/matchmaking_servers.cpp b/src/client/steam/interfaces/matchmaking_servers.cpp index 13ffbe28..cb2d612c 100644 --- a/src/client/steam/interfaces/matchmaking_servers.cpp +++ b/src/client/steam/interfaces/matchmaking_servers.cpp @@ -1,8 +1,12 @@ #include #include "../steam.hpp" + +#include "game/game.hpp" + #include "component/party.hpp" #include "component/network.hpp" -#include "utils/string.hpp" + +#include namespace steam { diff --git a/src/client/steam/interfaces/ugc.cpp b/src/client/steam/interfaces/ugc.cpp index eaacb52a..9f3eedca 100644 --- a/src/client/steam/interfaces/ugc.cpp +++ b/src/client/steam/interfaces/ugc.cpp @@ -1,5 +1,8 @@ #include #include "../steam.hpp" + +#include + #include "component/steam_proxy.hpp" namespace steam diff --git a/src/common/utils/info_string.cpp b/src/common/utils/info_string.cpp index 7b857926..cd3d6637 100644 --- a/src/common/utils/info_string.cpp +++ b/src/common/utils/info_string.cpp @@ -32,7 +32,7 @@ namespace utils return value->second; } - return ""; + return {}; } void info_string::parse(std::string buffer) diff --git a/src/common/utils/io.cpp b/src/common/utils/io.cpp index a03d1bb2..45f2ab91 100644 --- a/src/common/utils/io.cpp +++ b/src/common/utils/io.cpp @@ -4,9 +4,9 @@ namespace utils::io { - bool remove_file(const std::string& file) + bool remove_file(const std::filesystem::path& file) { - if(DeleteFileA(file.data()) != FALSE) + if(DeleteFileW(file.wstring().data()) != FALSE) { return true; } @@ -14,9 +14,9 @@ namespace utils::io return GetLastError() == ERROR_FILE_NOT_FOUND; } - bool move_file(const std::string& src, const std::string& target) + bool move_file(const std::filesystem::path& src, const std::filesystem::path& target) { - return MoveFileA(src.data(), target.data()) == TRUE; + return MoveFileW(src.wstring().data(), target.wstring().data()) == TRUE; } bool file_exists(const std::string& file) @@ -37,7 +37,7 @@ namespace utils::io if (stream.is_open()) { - stream.write(data.data(), data.size()); + stream.write(data.data(), static_cast(data.size())); stream.close(); return true; } @@ -68,8 +68,8 @@ namespace utils::io if (size > -1) { - data->resize(static_cast(size)); - stream.read(const_cast(data->data()), size); + data->resize(static_cast(size)); + stream.read(data->data(), size); stream.close(); return true; } @@ -78,7 +78,7 @@ namespace utils::io return false; } - size_t file_size(const std::string& file) + std::size_t file_size(const std::string& file) { if (file_exists(file)) { @@ -87,29 +87,29 @@ namespace utils::io if (stream.good()) { stream.seekg(0, std::ios::end); - return static_cast(stream.tellg()); + return static_cast(stream.tellg()); } } return 0; } - bool create_directory(const std::string& directory) + bool create_directory(const std::filesystem::path& directory) { return std::filesystem::create_directories(directory); } - bool directory_exists(const std::string& directory) + bool directory_exists(const std::filesystem::path& directory) { return std::filesystem::is_directory(directory); } - bool directory_is_empty(const std::string& directory) + bool directory_is_empty(const std::filesystem::path& directory) { return std::filesystem::is_empty(directory); } - std::vector list_files(const std::string& directory) + std::vector list_files(const std::filesystem::path& directory) { std::vector files; diff --git a/src/common/utils/io.hpp b/src/common/utils/io.hpp index ab4ebaa4..52476834 100644 --- a/src/common/utils/io.hpp +++ b/src/common/utils/io.hpp @@ -6,16 +6,16 @@ namespace utils::io { - bool remove_file(const std::string& file); - bool move_file(const std::string& src, const std::string& target); + bool remove_file(const std::filesystem::path& file); + bool move_file(const std::filesystem::path& src, const std::filesystem::path& target); bool file_exists(const std::string& file); bool write_file(const std::string& file, const std::string& data, bool append = false); bool read_file(const std::string& file, std::string* data); std::string read_file(const std::string& file); size_t file_size(const std::string& file); - bool create_directory(const std::string& directory); - bool directory_exists(const std::string& directory); - bool directory_is_empty(const std::string& directory); - std::vector list_files(const std::string& directory); + bool create_directory(const std::filesystem::path& directory); + bool directory_exists(const std::filesystem::path& directory); + bool directory_is_empty(const std::filesystem::path& directory); + std::vector list_files(const std::filesystem::path& directory); void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target); } diff --git a/src/common/utils/nt.cpp b/src/common/utils/nt.cpp index 671de23a..fa890e52 100644 --- a/src/common/utils/nt.cpp +++ b/src/common/utils/nt.cpp @@ -121,28 +121,28 @@ namespace utils::nt std::string library::get_name() const { - if (!this->is_valid()) return ""; + if (!this->is_valid()) return {}; - auto path = this->get_path(); - const auto pos = path.find_last_of("/\\"); - if (pos == std::string::npos) return path; + const auto path = this->get_path(); + const auto pos = path.generic_string().find_last_of("/\\"); + if (pos == std::string::npos) return path.generic_string(); - return path.substr(pos + 1); + return path.generic_string().substr(pos + 1); } - std::string library::get_path() const + std::filesystem::path library::get_path() const { - if (!this->is_valid()) return ""; + if (!this->is_valid()) return {}; - char name[MAX_PATH] = {0}; - GetModuleFileNameA(this->module_, name, sizeof name); + wchar_t name[MAX_PATH] = {0}; + GetModuleFileNameW(this->module_, name, MAX_PATH); - return name; + return {name}; } - std::string library::get_folder() const + std::filesystem::path library::get_folder() const { - if (!this->is_valid()) return ""; + if (!this->is_valid()) return {}; const auto path = std::filesystem::path(this->get_path()); return path.parent_path().generic_string(); @@ -265,7 +265,7 @@ namespace utils::nt GetCurrentDirectoryA(sizeof(current_dir), current_dir); auto* const command_line = GetCommandLineA(); - CreateProcessA(self.get_path().data(), command_line, nullptr, nullptr, false, NULL, nullptr, current_dir, + CreateProcessA(self.get_path().generic_string().data(), command_line, nullptr, nullptr, false, NULL, nullptr, current_dir, &startup_info, &process_info); if (process_info.hThread && process_info.hThread != INVALID_HANDLE_VALUE) CloseHandle(process_info.hThread); diff --git a/src/common/utils/nt.hpp b/src/common/utils/nt.hpp index 27b7df8d..71222007 100644 --- a/src/common/utils/nt.hpp +++ b/src/common/utils/nt.hpp @@ -41,27 +41,27 @@ namespace utils::nt operator HMODULE() const; void unprotect() const; - void* get_entry_point() const; - size_t get_relative_entry_point() const; + [[nodiscard]] void* get_entry_point() const; + [[nodiscard]] size_t get_relative_entry_point() const; - bool is_valid() const; - std::string get_name() const; - std::string get_path() const; - std::string get_folder() const; - std::uint8_t* get_ptr() const; + [[nodiscard]] bool is_valid() const; + [[nodiscard]] std::string get_name() const; + [[nodiscard]] std::filesystem::path get_path() const; + [[nodiscard]] std::filesystem::path get_folder() const; + [[nodiscard]] std::uint8_t* get_ptr() const; void free(); - HMODULE get_handle() const; + [[nodiscard]] HMODULE get_handle() const; template - T get_proc(const std::string& process) const + [[nodiscard]] T get_proc(const std::string& process) const { if (!this->is_valid()) T{}; return reinterpret_cast(GetProcAddress(this->module_, process.data())); } template - std::function get(const std::string& process) const + [[nodiscard]] std::function get(const std::string& process) const { if (!this->is_valid()) return std::function(); return static_cast(this->get_proc(process)); @@ -91,13 +91,13 @@ namespace utils::nt return T(); } - std::vector get_section_headers() const; + [[nodiscard]] std::vector get_section_headers() const; - PIMAGE_NT_HEADERS get_nt_headers() const; - PIMAGE_DOS_HEADER get_dos_header() const; - PIMAGE_OPTIONAL_HEADER get_optional_header() const; + [[nodiscard]] PIMAGE_NT_HEADERS get_nt_headers() const; + [[nodiscard]] PIMAGE_DOS_HEADER get_dos_header() const; + [[nodiscard]] PIMAGE_OPTIONAL_HEADER get_optional_header() const; - void** get_iat_entry(const std::string& module_name, const std::string& proc_name) const; + [[nodiscard]] void** get_iat_entry(const std::string& module_name, const std::string& proc_name) const; private: HMODULE module_; diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index 653ecff2..3313eca9 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -36,9 +36,9 @@ namespace utils::string std::string to_lower(std::string text) { - std::transform(text.begin(), text.end(), text.begin(), [](const char input) + std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input) { - return static_cast(tolower(input)); + return static_cast(std::tolower(input)); }); return text; @@ -46,9 +46,9 @@ namespace utils::string std::string to_upper(std::string text) { - std::transform(text.begin(), text.end(), text.begin(), [](const char input) + std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input) { - return static_cast(toupper(input)); + return static_cast(std::toupper(input)); }); return text; @@ -105,12 +105,12 @@ namespace utils::string return {}; } - void strip(const char* in, char* out, int max) + void strip(const char* in, char* out, size_t max) { if (!in || !out) return; max--; - auto current = 0; + size_t current = 0; while (*in != 0 && current < max) { const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48); @@ -128,11 +128,10 @@ namespace utils::string ++in; } + *out = '\0'; } -#pragma warning(push) -#pragma warning(disable: 4100) std::string convert(const std::wstring& wstr) { std::string result; @@ -158,7 +157,6 @@ namespace utils::string return result; } -#pragma warning(pop) std::string replace(std::string str, const std::string& from, const std::string& to) { diff --git a/src/common/utils/string.hpp b/src/common/utils/string.hpp index 04042cb9..8bdfe5c9 100644 --- a/src/common/utils/string.hpp +++ b/src/common/utils/string.hpp @@ -91,7 +91,7 @@ namespace utils::string std::string get_clipboard_data(); - void strip(const char* in, char* out, int max); + void strip(const char* in, char* out, size_t max); std::string convert(const std::wstring& wstr); std::wstring convert(const std::string& str);