[General] Prepare code for use with multiple projects

This commit is contained in:
momo5502 2017-01-27 14:43:52 +01:00
parent b0d863e28d
commit c15aac546d
8 changed files with 19 additions and 19 deletions

View File

@ -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)
{

View File

@ -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)
{

View File

@ -77,7 +77,7 @@ namespace Components
header.sectionHeader[Game::SECTION_FIXUP].buffer = allocator.allocateArray<char>(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))

View File

@ -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);
}

View File

@ -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();
}

View File

@ -83,6 +83,11 @@ template <size_t S> 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"

View File

@ -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();

View File

@ -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<float>(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)
{