From 0a54d940bbea65668c5ef691705cc6d089934906 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 7 Feb 2016 02:31:30 +0100 Subject: [PATCH] Fix compiler warnings. --- premake5.lua | 2 +- src/Components/Modules/FastFiles.cpp | 4 ++-- src/Components/Modules/StructuredData.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/premake5.lua b/premake5.lua index 7036726c..5e7d36ae 100644 --- a/premake5.lua +++ b/premake5.lua @@ -97,7 +97,7 @@ workspace "iw4x" -- Pre-compiled header pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives pchsource "src/STDInclude.cpp" -- real path - buildoptions { "-Zm200" } -- allocate ~150mb memory for the precompiled header. This should be enough, increase if necessary + buildoptions { "-Zm88" } -- Dependency on zlib, json11 and asio links { "zlib", "json11", "pdcurses", "libtomcrypt", "libtommath" } diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index ce6dcda3..c736ca54 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -86,7 +86,7 @@ namespace Components path.append(".ff"); } - return (GetFileAttributes(path.data()) != INVALID_FILE_ATTRIBUTES); + return std::ifstream(path.data()).good(); } const char* FastFiles::GetZoneLocation(const char* file) @@ -104,7 +104,7 @@ namespace Components } // Check if FastFile exists - if (GetFileAttributes(absoluteFile.data()) != INVALID_FILE_ATTRIBUTES) + if (std::ifstream(absoluteFile.data()).good()) { return Utils::VA("%s", path.data()); } diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index ae25684d..20fd9f7f 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -26,7 +26,7 @@ namespace Components void StructuredData::PatchPlayerDataEnum(Game::structuredDataDef_t* data, StructuredData::PlayerDataType type, std::vector& entries) { - if (!data || !data->data) return; + if (!data || !data->data || type >= StructuredData::ENUM_MAX) return; Game::structuredDataEnum_t* dataEnum = &data->data->enums[type]; @@ -74,9 +74,9 @@ namespace Components } } - for (unsigned int j = dataEnum->numIndices + i; j > pos; j--) + for (unsigned int j = dataEnum->numIndices + i; j > pos && j < static_cast(StructuredData::IndexCount[type]); j--) { - StructuredData::Indices[type][j] = StructuredData::Indices[type][j - 1]; + memcpy(&StructuredData::Indices[type][j], &StructuredData::Indices[type][j - 1], sizeof(Game::structuredDataEnumIndex_t)); } StructuredData::Indices[type][pos].index = entries[i].statOffset + lastIndex;