From c15aac546d0e73145287429227c39aa263206466 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 27 Jan 2017 14:43:52 +0100 Subject: [PATCH] [General] Prepare code for use with multiple projects --- src/Components/Modules/Console.cpp | 2 +- src/Components/Modules/Maps.cpp | 4 ++-- src/Components/Modules/ModelSurfs.cpp | 2 +- src/Components/Modules/News.cpp | 11 ++--------- src/Components/Modules/PlayerName.cpp | 4 ++-- src/STDInclude.hpp | 5 +++++ src/Utils/Cache.cpp | 2 +- src/Utils/String.cpp | 8 +++++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 713658da..d5bb5f66 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -507,7 +507,7 @@ namespace Components { "con_outputWindowColor", { 0.25f, 0.25f, 0.25f, 0.85f } }, }; - for (int i = 0; i < ARRAY_SIZE(patchedColors); ++i) + for (int i = 0; i < ARRAYSIZE(patchedColors); ++i) { if (std::string(name) == patchedColors[i].name) { diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 3c09608b..0cea2fb8 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -244,7 +244,7 @@ namespace Components Game::newMapArena_t* arena = &ArenaLength::NewArenas[i]; if (arena->mapName == map) { - for (int j = 0; j < ARRAY_SIZE(arena->keys); ++j) + for (int j = 0; j < ARRAYSIZE(arena->keys); ++j) { if (arena->keys[j] == "dependency"s) { @@ -267,7 +267,7 @@ namespace Components Game::newMapArena_t* arena = &ArenaLength::NewArenas[i]; if (arena->mapName == map) { - for (int j = 0; j < ARRAY_SIZE(arena->keys); ++j) + for (int j = 0; j < ARRAYSIZE(arena->keys); ++j) { if (arena->keys[j] == "allieschar"s) { diff --git a/src/Components/Modules/ModelSurfs.cpp b/src/Components/Modules/ModelSurfs.cpp index 3a9839ab..36a8121c 100644 --- a/src/Components/Modules/ModelSurfs.cpp +++ b/src/Components/Modules/ModelSurfs.cpp @@ -77,7 +77,7 @@ namespace Components header.sectionHeader[Game::SECTION_FIXUP].buffer = allocator.allocateArray(header.sectionHeader[Game::SECTION_FIXUP].size); // Load section data - for (int i = 0; i < ARRAY_SIZE(header.sectionHeader); ++i) + for (int i = 0; i < ARRAYSIZE(header.sectionHeader); ++i) { model.seek(header.sectionHeader[i].offset, FS_SEEK_SET); if (!model.read(header.sectionHeader[i].buffer, header.sectionHeader[i].size)) diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index cd133499..c0ae951a 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -53,15 +53,8 @@ namespace Components CreateProcessA("updater.exe", nullptr, nullptr, nullptr, false, NULL, nullptr, nullptr, &sInfo, &pInfo); - if (pInfo.hThread && pInfo.hThread != INVALID_HANDLE_VALUE) - { - CloseHandle(pInfo.hThread); - } - - if (pInfo.hProcess && pInfo.hProcess != INVALID_HANDLE_VALUE) - { - CloseHandle(pInfo.hProcess); - } + if (pInfo.hThread && pInfo.hThread != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hThread); + if (pInfo.hProcess && pInfo.hProcess != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hProcess); TerminateProcess(GetCurrentProcess(), exitCode); } diff --git a/src/Components/Modules/PlayerName.cpp b/src/Components/Modules/PlayerName.cpp index f3b16edc..5d62e904 100644 --- a/src/Components/Modules/PlayerName.cpp +++ b/src/Components/Modules/PlayerName.cpp @@ -14,7 +14,7 @@ namespace Components { #if(0) // Disabled for now { - for (int i = 0; i < ARRAY_SIZE(PlayerName::PlayerNames); ++i) + for (int i = 0; i < ARRAYSIZE(PlayerName::PlayerNames); ++i) { PlayerName::PlayerNames[i] = "mumu"; } @@ -26,7 +26,7 @@ namespace Components PlayerName::~PlayerName() { - for (int i = 0; i < ARRAY_SIZE(PlayerName::PlayerNames); ++i) + for (int i = 0; i < ARRAYSIZE(PlayerName::PlayerNames); ++i) { PlayerName::PlayerNames[i].clear(); } diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index be7a6293..fb6447fe 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -83,6 +83,11 @@ template class Sizer { }; #pragma warning(pop) +#define ENABLE_BASE64 +#ifndef DISABLE_BASE128 +#define ENABLE_BASE128 +#endif + #include "Utils/IO.hpp" #include "Utils/CSV.hpp" #include "Utils/Time.hpp" diff --git a/src/Utils/Cache.cpp b/src/Utils/Cache.cpp index 48de605e..cefdb0da 100644 --- a/src/Utils/Cache.cpp +++ b/src/Utils/Cache.cpp @@ -29,7 +29,7 @@ namespace Utils if (Cache::ValidUrl.empty()) { - for (int i = 0; i < ARRAY_SIZE(Cache::Urls); i++) + for (int i = 0; i < ARRAYSIZE(Cache::Urls); i++) { std::string result = Utils::WebIO(useragent, Cache::GetUrl(Cache::Urls[i], path)).setTimeout(timeout)->get(); diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 8fbfd180..0ce7a9df 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -1,5 +1,5 @@ #include "STDInclude.hpp" -#ifndef DISABLE_BASE128 +#ifdef ENABLE_BASE128 #include "base128.h" #endif @@ -158,7 +158,7 @@ namespace Utils double bytesPerSecond = (1000.0 / milliseconds) * bytes; int i; - for (i = 0; bytesPerSecond > 1000 && i < ARRAY_SIZE(sizes); ++i) // 1024 or 1000? + for (i = 0; bytesPerSecond > 1000 && i < ARRAYSIZE(sizes); ++i) // 1024 or 1000? { bytesPerSecond /= 1000; } @@ -166,6 +166,7 @@ namespace Utils return Utils::String::VA("%.2f %s/s", static_cast(bytesPerSecond), sizes[i]); } +#ifdef ENABLE_BASE64 // Encodes a given string in Base64 std::string EncodeBase64(const char* input, const unsigned long inputSize) { @@ -182,8 +183,9 @@ namespace Utils { return EncodeBase64(input.data(), input.size()); } +#endif -#ifndef DISABLE_BASE128 +#ifdef ENABLE_BASE128 // Encodes a given string in Base128 std::string EncodeBase128(const std::string& input) {