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);
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.second, defenderState->getAvailableHealth());

View File

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

View File

@ -211,8 +211,6 @@ MoveTarget BattleExchangeEvaluator::findMoveTowardsUnreachable(const battle::Uni
for(const battle::Unit * enemy : targets.unreachableEnemies)
{
int64_t stackScore = EvaluationResult::INEFFECTIVE_SCORE;
std::vector<const battle::Unit *> adjacentStacks = getAdjacentUnits(enemy);
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);
if(text.find("guarded") >= 0 && (dangerUnknown || dangerTooHigh))
if(text.find("guarded") != std::string::npos && (dangerUnknown || dangerTooHigh))
answer = 0; // no
}
}

View File

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

View File

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

View File

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

View File

@ -83,6 +83,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#endif
// Each compiler uses own way to supress fall through warning. Try to find it.
// TODO: replace with c++17 [[fallthrough]]
#ifdef __has_cpp_attribute
# if __has_cpp_attribute(fallthrough)
# define FALLTHROUGH [[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]));
if(args[tagPoint] == username)
{
if(args[tagPoint + 1] == "True")
ui->buttonReady->setText("Not ready");
else
ui->buttonReady->setText("Ready");
}
}
break;

View File

@ -18,7 +18,6 @@ namespace
{
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,
VCMI_VERSION_MINOR,
VCMI_VERSION_PATCH);
@ -26,8 +25,10 @@ bool isCompatible(const QString & verMin, const QString & verMax)
auto versionMin = QVersionNumber::fromString(verMin);
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)
{
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
//and in the CGHeroInstance::getNativeTerrain() to setup mevement bonuses or/and penalties.
return hasBonus(selectorNoTerrainPenalty, selectorNoTerrainPenalty)
? Terrain::ANY_TERRAIN
? TerrainId(Terrain::ANY_TERRAIN)
: (*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 bothNumeric = sourceNumeric && destNumeric;
MAYBE_UNUSED(hasNull);
MAYBE_UNUSED(sameType);
MAYBE_UNUSED(sourceNumeric);
MAYBE_UNUSED(destNumeric);
MAYBE_UNUSED(bothNumeric);
assert( hasNull || sameType || bothNumeric );
switch (source.getType())

View File

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

View File

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

View File

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

View File

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