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

Fixed all non-silenced gcc/clang warnings

This commit is contained in:
Ivan Savenko 2022-12-07 18:05:47 +02:00
parent fb1a6b734f
commit 3219e322ae
17 changed files with 36 additions and 32 deletions

View File

@ -156,7 +156,6 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf
TDmgRange retaliation(0, 0); TDmgRange retaliation(0, 0);
auto attackDmg = state.battleEstimateDamage(ap.attack, &retaliation); auto attackDmg = state.battleEstimateDamage(ap.attack, &retaliation);
TDmgRange defenderDamageBeforeAttack = state.battleEstimateDamage(BattleAttackInfo(u, attacker, u->canShoot()));
vstd::amin(attackDmg.first, defenderState->getAvailableHealth()); vstd::amin(attackDmg.first, defenderState->getAvailableHealth());
vstd::amin(attackDmg.second, defenderState->getAvailableHealth()); vstd::amin(attackDmg.second, defenderState->getAvailableHealth());

View File

@ -186,7 +186,6 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
if(evaluationResult.score > score) if(evaluationResult.score > score)
{ {
auto & target = bestAttack;
score = evaluationResult.score; score = evaluationResult.score;
std::string action; std::string action;

View File

@ -211,8 +211,6 @@ MoveTarget BattleExchangeEvaluator::findMoveTowardsUnreachable(const battle::Uni
for(const battle::Unit * enemy : targets.unreachableEnemies) for(const battle::Unit * enemy : targets.unreachableEnemies)
{ {
int64_t stackScore = EvaluationResult::INEFFECTIVE_SCORE;
std::vector<const battle::Unit *> adjacentStacks = getAdjacentUnits(enemy); std::vector<const battle::Unit *> adjacentStacks = getAdjacentUnits(enemy);
auto closestStack = *vstd::minElementByFun(adjacentStacks, [&](const battle::Unit * u) -> int64_t auto closestStack = *vstd::minElementByFun(adjacentStacks, [&](const battle::Unit * u) -> int64_t
{ {

View File

@ -594,7 +594,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
logAi->trace("Guarded object query hook: %s by %s danger ratio %f", target.toString(), hero.name, ratio); logAi->trace("Guarded object query hook: %s by %s danger ratio %f", target.toString(), hero.name, ratio);
if(text.find("guarded") >= 0 && (dangerUnknown || dangerTooHigh)) if(text.find("guarded") != std::string::npos && (dangerUnknown || dangerTooHigh))
answer = 0; // no answer = 0; // no
} }
} }

View File

@ -329,7 +329,7 @@ public:
if(!poolIsEmpty) pool.pop_back(); if(!poolIsEmpty) pool.pop_back();
return std::move(tmp); return tmp;
} }
bool empty() const bool empty() const

View File

@ -122,10 +122,8 @@ ui64 FuzzyHelper::evaluateDanger(const CGObjectInstance * obj)
case Obj::RESOURCE: case Obj::RESOURCE:
{ {
if(!vstd::contains(ai->memory->alreadyVisited, obj)) if(!vstd::contains(ai->memory->alreadyVisited, obj))
{
return 0; return 0;
} FALLTHROUGH;
// passthrough
} }
case Obj::MONSTER: case Obj::MONSTER:
case Obj::HERO: case Obj::HERO:

View File

@ -127,7 +127,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
continue; continue;
} }
} }
catch(cannotFulfillGoalException) catch(const cannotFulfillGoalException &)
{ {
if(!heroPtr.validAndSet()) if(!heroPtr.validAndSet())
{ {
@ -173,7 +173,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN); ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
blockedIndexes.insert(node.parentIndex); blockedIndexes.insert(node.parentIndex);
} }
catch(goalFulfilledException) catch(const goalFulfilledException &)
{ {
if(!heroPtr.validAndSet()) if(!heroPtr.validAndSet())
{ {

View File

@ -80,12 +80,13 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
# endif # endif
#else #else
# error "VCMI supports only Windows, OSX, Linux and Android targets" # error "VCMI supports only Windows, OSX, Linux and Android targets"
#endif #endif
// Each compiler uses own way to supress fall through warning. Try to find it. // Each compiler uses own way to supress fall through warning. Try to find it.
#ifdef __has_cpp_attribute // TODO: replace with c++17 [[fallthrough]]
# if __has_cpp_attribute(fallthrough) #ifdef __has_cpp_attribute
# define FALLTHROUGH [[fallthrough]]; # if __has_cpp_attribute(fallthrough)
# define FALLTHROUGH [[fallthrough]];
# elif __has_cpp_attribute(gnu::fallthrough) # elif __has_cpp_attribute(gnu::fallthrough)
# define FALLTHROUGH [[gnu::fallthrough]]; # define FALLTHROUGH [[gnu::fallthrough]];
# elif __has_cpp_attribute(clang::fallthrough) # elif __has_cpp_attribute(clang::fallthrough)

View File

@ -202,10 +202,12 @@ void Lobby::serverCommand(const ServerCommand & command) try
ui->playersList->addItem(new QListWidgetItem(QIcon("icons:mod-disabled.png"), args[tagPoint])); ui->playersList->addItem(new QListWidgetItem(QIcon("icons:mod-disabled.png"), args[tagPoint]));
if(args[tagPoint] == username) if(args[tagPoint] == username)
{
if(args[tagPoint + 1] == "True") if(args[tagPoint + 1] == "True")
ui->buttonReady->setText("Not ready"); ui->buttonReady->setText("Not ready");
else else
ui->buttonReady->setText("Ready"); ui->buttonReady->setText("Ready");
}
} }
break; break;

View File

@ -18,7 +18,6 @@ namespace
{ {
bool isCompatible(const QString & verMin, const QString & verMax) bool isCompatible(const QString & verMin, const QString & verMax)
{ {
const int maxSections = 3; // versions consist from up to 3 sections, major.minor.patch
QVersionNumber vcmiVersion(VCMI_VERSION_MAJOR, QVersionNumber vcmiVersion(VCMI_VERSION_MAJOR,
VCMI_VERSION_MINOR, VCMI_VERSION_MINOR,
VCMI_VERSION_PATCH); VCMI_VERSION_PATCH);
@ -26,8 +25,10 @@ bool isCompatible(const QString & verMin, const QString & verMax)
auto versionMin = QVersionNumber::fromString(verMin); auto versionMin = QVersionNumber::fromString(verMin);
auto versionMax = QVersionNumber::fromString(verMax); auto versionMax = QVersionNumber::fromString(verMax);
auto buildVersion = [maxSections](QVersionNumber & ver) auto buildVersion = [](QVersionNumber & ver)
{ {
const int maxSections = 3; // versions consist from up to 3 sections, major.minor.patch
if(ver.segmentCount() < maxSections) if(ver.segmentCount() < maxSections)
{ {
auto segments = ver.segments(); auto segments = ver.segments();

View File

@ -299,7 +299,7 @@ TerrainId CCreature::getNativeTerrain() const
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses //this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
//and in the CGHeroInstance::getNativeTerrain() to setup mevement bonuses or/and penalties. //and in the CGHeroInstance::getNativeTerrain() to setup mevement bonuses or/and penalties.
return hasBonus(selectorNoTerrainPenalty, selectorNoTerrainPenalty) return hasBonus(selectorNoTerrainPenalty, selectorNoTerrainPenalty)
? Terrain::ANY_TERRAIN ? TerrainId(Terrain::ANY_TERRAIN)
: (*VLC->townh)[faction]->nativeTerrain; : (*VLC->townh)[faction]->nativeTerrain;
} }

View File

@ -1028,6 +1028,12 @@ void JsonUtils::merge(JsonNode & dest, JsonNode & source, bool ignoreOverride, b
bool destNumeric = dest.getType() == JsonNode::JsonType::DATA_FLOAT || dest.getType() == JsonNode::JsonType::DATA_INTEGER; bool destNumeric = dest.getType() == JsonNode::JsonType::DATA_FLOAT || dest.getType() == JsonNode::JsonType::DATA_INTEGER;
bool bothNumeric = sourceNumeric && destNumeric; bool bothNumeric = sourceNumeric && destNumeric;
MAYBE_UNUSED(hasNull);
MAYBE_UNUSED(sameType);
MAYBE_UNUSED(sourceNumeric);
MAYBE_UNUSED(destNumeric);
MAYBE_UNUSED(bothNumeric);
assert( hasNull || sameType || bothNumeric ); assert( hasNull || sameType || bothNumeric );
switch (source.getType()) switch (source.getType())

View File

@ -46,8 +46,8 @@ std::string IVCMIDirs::genHelpString() const
" user cache: " + userCachePath().string() + "\n" " user cache: " + userCachePath().string() + "\n"
" user config: " + userConfigPath().string() + "\n" " user config: " + userConfigPath().string() + "\n"
" user logs: " + userLogsPath().string() + "\n" " user logs: " + userLogsPath().string() + "\n"
" user saves: " + userSavePath().string() + "\n"; " user saves: " + userSavePath().string() + "\n"
" user extracted: " + userExtractedPath().string() + "\n"; // Should end without new-line? " user extracted: " + userExtractedPath().string() + "\n";
} }
void IVCMIDirs::init() void IVCMIDirs::init()

View File

@ -331,12 +331,12 @@ void CMapGenerator::findZonesForQuestArts()
if (zoneA->getId() > zoneB->getId()) if (zoneA->getId() > zoneB->getId())
{ {
if(auto * m = zoneB->getModificator<TreasurePlacer>()) if(auto * m = zoneB->getModificator<TreasurePlacer>())
zoneB->getModificator<TreasurePlacer>()->setQuestArtZone(zoneA.get()); m->setQuestArtZone(zoneA.get());
} }
else if (zoneA->getId() < zoneB->getId()) else if (zoneA->getId() < zoneB->getId())
{ {
if(auto * m = zoneA->getModificator<TreasurePlacer>()) if(auto * m = zoneA->getModificator<TreasurePlacer>())
zoneA->getModificator<TreasurePlacer>()->setQuestArtZone(zoneB.get()); m->setQuestArtZone(zoneB.get());
} }
} }
} }

View File

@ -906,7 +906,7 @@ void MainWindow::on_terrainFilterCombo_currentTextChanged(const QString &arg1)
if(!objectBrowser) if(!objectBrowser)
return; return;
objectBrowser->terrain = arg1.isEmpty() ? Terrain::ANY_TERRAIN : VLC->terrainTypeHandler->getInfoByName(arg1.toStdString())->id; objectBrowser->terrain = arg1.isEmpty() ? TerrainId(Terrain::ANY_TERRAIN) : VLC->terrainTypeHandler->getInfoByName(arg1.toStdString())->id;
objectBrowser->invalidate(); objectBrowser->invalidate();
objectBrowser->sort(0); objectBrowser->sort(0);
} }

View File

@ -202,7 +202,7 @@ std::unique_ptr<CMap> generateEmptyMap(CMapGenOptions & options)
map->initTerrain(); map->initTerrain();
map->getEditManager()->clearTerrain(&CRandomGenerator::getDefault()); map->getEditManager()->clearTerrain(&CRandomGenerator::getDefault());
return std::move(map); return map;
} }
void WindowNewMap::on_okButton_clicked() void WindowNewMap::on_okButton_clicked()

View File

@ -46,7 +46,7 @@
<property name="title"> <property name="title">
<string>Map size</string> <string>Map size</string>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget1">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -204,7 +204,7 @@
<property name="title"> <property name="title">
<string>Players</string> <string>Players</string>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -421,7 +421,7 @@
<property name="title"> <property name="title">
<string>Monster strength</string> <string>Monster strength</string>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -562,7 +562,7 @@
<property name="title"> <property name="title">
<string>Water content</string> <string>Water content</string>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget4">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -667,7 +667,7 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget5">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -754,7 +754,7 @@
<string>Generate random map</string> <string>Generate random map</string>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget6">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>310</x> <x>310</x>