diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index 36df5eaeb..2ad9efeef 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -28,8 +28,8 @@ namespace NKAI { // our to enemy strength ratio constants -const float SAFE_ATTACK_CONSTANT = 1.2; -const float RETREAT_THRESHOLD = 0.3; +const float SAFE_ATTACK_CONSTANT = 1.2f; +const float RETREAT_THRESHOLD = 0.3f; const double RETREAT_ABSOLUTE_THRESHOLD = 10000.; //one thread may be turn of AI and another will be handling a side effect for AI2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b3381bde..1a137d575 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,9 +206,12 @@ if(MINGW OR MSVC) add_definitions(-D_SCL_SECURE_NO_WARNINGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") # 4250: 'class1' : inherits 'class2::member' via dominance + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") # 4250: 'class1' : inherits 'class2::member' via dominance set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") # 4251: class 'xxx' needs to have dll-interface to be used by clients of class 'yyy' + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # 4244: conversion from 'xxx' to 'yyy', possible loss of data + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") # 4267: conversion from 'xxx' to 'yyy', possible loss of data set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4275") # 4275: non dll-interface class 'xxx' used as base for dll-interface class + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") # 4800: implicit conversion from 'xxx' to bool. Possible information loss if(ENABLE_STRICT_COMPILATION) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wx") # Treats all compiler warnings as errors @@ -258,6 +261,11 @@ if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # low chance of any significant issues set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-varargs") # emitted in fuzzylite headers, disabled + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") # emitted only by ancient gcc 5.5 in MXE build, remove after upgrade + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") # emitted only by ancient gcc 5.5 in MXE build, remove after upgrade + endif() + if(ENABLE_STRICT_COMPILATION) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds") # false positives in boost::multiarray during release build, keep as warning-only diff --git a/Global.h b/Global.h index 371ece6ca..c88087d0a 100644 --- a/Global.h +++ b/Global.h @@ -27,13 +27,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # error This GCC version has buggy std::array::at version and should not be used. Please update to 4.7.2 or later #endif -/* ---------------------------------------------------------------------------- */ -/* Suppress some compiler warnings */ -/* ---------------------------------------------------------------------------- */ -#ifdef _MSC_VER -# pragma warning (disable : 4800 ) /* disable conversion to bool warning -- I think it's intended in all places */ -#endif - /* ---------------------------------------------------------------------------- */ /* System detection. */ /* ---------------------------------------------------------------------------- */ @@ -102,9 +95,15 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); /* Commonly used C++, Boost headers */ /* ---------------------------------------------------------------------------- */ #ifdef VCMI_WINDOWS -# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - delete this line if something is missing. -# define NOMINMAX // Exclude min/max macros from . Use std::[min/max] from instead. -# define _NO_W32_PSEUDO_MODIFIERS // Exclude more macros for compiling with MinGW on Linux. +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - delete this line if something is missing. +# endif +# ifndef NOMINMAX +# define NOMINMAX // Exclude min/max macros from . Use std::[min/max] from instead. +# endif +# ifndef _NO_W32_PSEUDO_MODIFIERS +# define _NO_W32_PSEUDO_MODIFIERS // Exclude more macros for compiling with MinGW on Linux. +# endif #endif #ifdef VCMI_ANDROID diff --git a/client/windows/CAdvmapInterface.cpp b/client/windows/CAdvmapInterface.cpp index a7846f4e9..b67704d72 100644 --- a/client/windows/CAdvmapInterface.cpp +++ b/client/windows/CAdvmapInterface.cpp @@ -54,10 +54,6 @@ #include "../../lib/StartInfo.h" #include "../../lib/mapping/CMapInfo.h" -#ifdef _MSC_VER -#pragma warning (disable : 4355) -#endif - #define ADVOPT (conf.go()->ac) using namespace CSDL_Ext; diff --git a/launcher/main.cpp b/launcher/main.cpp index 7180cb1d9..2b6660898 100644 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -48,9 +48,11 @@ void startGame(const QStringList & args) logGlobal->warn("Starting game with the arguments: %s", args.join(" ").toStdString()); #ifdef Q_OS_IOS + static const char clientName[] = "vcmiclient"; argcForClient = args.size() + 1; //first argument is omitted - argvForClient = new char*[argcForClient]; - argvForClient[0] = "vcmiclient"; + argvForClient = new char*[argcForClient]; + argvForClient[0] = new char[strlen(clientName)+1]; + strcpy(argvForClient[0], clientName); for(int i = 1; i < argcForClient; ++i) { std::string s = args.at(i - 1).toStdString(); diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index fbae12bec..0d34a8e09 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -135,6 +135,8 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex) const auto screens = qGuiApp->screens(); const auto currentScreen = screenIndex < screens.size() ? screens[screenIndex] : qGuiApp->primaryScreen(); const auto screenSize = currentScreen->size(); + MAYBE_UNUSED(screenSize); + for(const auto & entry : resolutions) { const auto resolutionMap = entry.toMap().value(QLatin1String{"resolution"}).toMap(); diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index aae7cffa1..8989ac8ac 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -576,7 +576,7 @@ CModInfo::Version CModInfo::Version::fromString(std::string from) patch = std::stoi(from.substr(pointPos + 1)); } } - catch(const std::invalid_argument & e) + catch(const std::invalid_argument &) { return Version(); } diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 12024696c..062976ee2 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -1220,7 +1220,7 @@ int CPathfinderHelper::getMovementCost( /// TODO: by the original game rules hero shouldn't be affected by terrain penalty while flying. /// Also flying movement only has penalty when player moving over blocked tiles. /// So if you only have base flying with 40% penalty you can still ignore terrain penalty while having zero flying penalty. - ui32 ret = hero->getTileCost(*dt, *ct, ti); + int ret = hero->getTileCost(*dt, *ct, ti); /// Unfortunately this can't be implemented yet as server don't know when player flying and when he's not. /// Difference in cost calculation on client and server is much worse than incorrect cost. /// So this one is waiting till server going to use pathfinder rules for path validation. diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 7f309e876..2df6f4377 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -1247,7 +1247,7 @@ std::pair CBattleInfoCallback::getNearestStack( // I hate std::pairs with their undescriptive member names first / second struct DistStack { - int distanceToPred; + uint32_t distanceToPred; BattleHex destination; const battle::Unit * stack; }; diff --git a/lib/battle/ReachabilityInfo.cpp b/lib/battle/ReachabilityInfo.cpp index 4e16fbe28..d61e294a8 100644 --- a/lib/battle/ReachabilityInfo.cpp +++ b/lib/battle/ReachabilityInfo.cpp @@ -43,17 +43,17 @@ bool ReachabilityInfo::isReachable(BattleHex hex) const return distances[hex] < INFINITE_DIST; } -int ReachabilityInfo::distToNearestNeighbour( +uint32_t ReachabilityInfo::distToNearestNeighbour( const std::vector & targetHexes, BattleHex * chosenHex) const { - int ret = 1000000; + uint32_t ret = 1000000; for(auto targetHex : targetHexes) { for(auto & n : targetHex.neighbouringTiles()) { - if(distances[n] >= 0 && distances[n] < ret) + if(distances[n] < ret) { ret = distances[n]; if(chosenHex) @@ -65,7 +65,7 @@ int ReachabilityInfo::distToNearestNeighbour( return ret; } -int ReachabilityInfo::distToNearestNeighbour( +uint32_t ReachabilityInfo::distToNearestNeighbour( const battle::Unit * attacker, const battle::Unit * defender, BattleHex * chosenHex) const diff --git a/lib/battle/ReachabilityInfo.h b/lib/battle/ReachabilityInfo.h index 502a269ec..1e4e03e27 100644 --- a/lib/battle/ReachabilityInfo.h +++ b/lib/battle/ReachabilityInfo.h @@ -18,7 +18,7 @@ VCMI_LIB_NAMESPACE_BEGIN // startPosition and perpective. struct DLL_LINKAGE ReachabilityInfo { - typedef std::array TDistances; + typedef std::array TDistances; typedef std::array TPredecessors; enum { INFINITE_DIST = 1000000 }; @@ -46,16 +46,14 @@ struct DLL_LINKAGE ReachabilityInfo bool isReachable(BattleHex hex) const; - int distToNearestNeighbour( + uint32_t distToNearestNeighbour( const std::vector & targetHexes, BattleHex * chosenHex = nullptr) const; - int distToNearestNeighbour( + uint32_t distToNearestNeighbour( const battle::Unit * attacker, const battle::Unit * defender, BattleHex * chosenHex = nullptr) const; }; - - VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/FileStream.h b/lib/filesystem/FileStream.h index 145a2e067..edad65a38 100644 --- a/lib/filesystem/FileStream.h +++ b/lib/filesystem/FileStream.h @@ -40,7 +40,14 @@ struct zlib_filefunc64_def_s; typedef zlib_filefunc64_def_s zlib_filefunc64_def; #ifdef VCMI_DLL +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable : 4910) +#endif extern template struct DLL_LINKAGE boost::iostreams::stream; +#ifdef _MSC_VER +#pragma warning (pop) +#endif #endif VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapping/MapFormatJson.cpp b/lib/mapping/MapFormatJson.cpp index 34fbe339e..4ed38c955 100644 --- a/lib/mapping/MapFormatJson.cpp +++ b/lib/mapping/MapFormatJson.cpp @@ -981,14 +981,14 @@ void CMapLoaderJson::readTerrainTile(const std::string & src, TerrainTile & tile { tile.roadType = const_cast(VLC->terrainTypeHandler->getRoadByCode(typeCode)); } - catch (const std::exception& e) //it's not a road, it's a river + catch (const std::exception&) //it's not a road, it's a river { try { tile.riverType = const_cast(VLC->terrainTypeHandler->getRiverByCode(typeCode)); hasRoad = false; } - catch (const std::exception& e) + catch (const std::exception&) { throw std::runtime_error("Invalid river type in " + src); } @@ -1042,7 +1042,7 @@ void CMapLoaderJson::readTerrainTile(const std::string & src, TerrainTile & tile tile.extTileFlags |= (flip << 2); } } - catch (const std::exception & e) + catch (const std::exception &) { logGlobal->error("Failed to read terrain tile: %s"); } diff --git a/lib/minizip/ioapi.h b/lib/minizip/ioapi.h index 4683e36cd..124d78686 100644 --- a/lib/minizip/ioapi.h +++ b/lib/minizip/ioapi.h @@ -111,6 +111,8 @@ typedef uint64_t ZPOS64_T; #endif #if defined(_MSC_VER) +#pragma warning (push) +#pragma warning (disable : 4005) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ @@ -121,6 +123,7 @@ typedef uint64_t ZPOS64_T; # define ZEXPORT __declspec(dllimport) # endif # endif /* ZLIB_DLL */ +#pragma warning (pop) #ifdef MINIZIP_DLL #define MINIZIP_EXPORT __declspec(dllexport) diff --git a/lib/rmg/Functions.cpp b/lib/rmg/Functions.cpp index c73184bd9..04846ebe4 100644 --- a/lib/rmg/Functions.cpp +++ b/lib/rmg/Functions.cpp @@ -58,7 +58,7 @@ void createModificators(RmgMap & map) rmg::Tileset collectDistantTiles(const Zone& zone, int distance) { - int distanceSq = distance * distance; + uint32_t distanceSq = distance * distance; auto subarea = zone.getArea().getSubarea([&zone, distanceSq](const int3 & t) { return t.dist2dSQ(zone.getPos()) > distanceSq; diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp index 96ae2a9b6..74e1707c4 100644 --- a/mapeditor/mainwindow.cpp +++ b/mapeditor/mainwindow.cpp @@ -698,7 +698,7 @@ void MainWindow::loadObjectsTree() addGroupIntoCatalog("OBSTACLES", true); addGroupIntoCatalog("OTHER", false); } - catch(const std::exception & e) + catch(const std::exception &) { QMessageBox::critical(this, "Mods loading problem", "Critical error during Mods loading. Disable invalid mods and restart."); }