1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed some of the warnings detected by CI run

This commit is contained in:
Ivan Savenko 2022-12-08 23:20:42 +02:00
parent facf77b3ae
commit db2a40600d
16 changed files with 51 additions and 36 deletions

View File

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

View File

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

View File

@ -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
# 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 <Windows.h>. Use std::[min/max] from <algorithm> 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

View File

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

View File

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

View File

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

View File

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

View File

@ -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.

View File

@ -1247,7 +1247,7 @@ std::pair<const battle::Unit *, BattleHex> 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;
};

View File

@ -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<BattleHex> & 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

View File

@ -18,7 +18,7 @@ VCMI_LIB_NAMESPACE_BEGIN
// startPosition and perpective.
struct DLL_LINKAGE ReachabilityInfo
{
typedef std::array<int, GameConstants::BFIELD_SIZE> TDistances;
typedef std::array<uint32_t, GameConstants::BFIELD_SIZE> TDistances;
typedef std::array<BattleHex, GameConstants::BFIELD_SIZE> 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<BattleHex> & 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

View File

@ -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<VCMI_LIB_WRAP_NAMESPACE(FileBuf)>;
#ifdef _MSC_VER
#pragma warning (pop)
#endif
#endif
VCMI_LIB_NAMESPACE_BEGIN

View File

@ -981,14 +981,14 @@ void CMapLoaderJson::readTerrainTile(const std::string & src, TerrainTile & tile
{
tile.roadType = const_cast<RoadType*>(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<RiverType*>(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");
}

View File

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

View File

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

View File

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