1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fixes for multiple new issues from Sonar

This commit is contained in:
Ivan Savenko
2025-02-20 16:57:52 +00:00
parent 0548f325e4
commit 2362c6da21
50 changed files with 190 additions and 223 deletions

View File

@@ -31,9 +31,6 @@
VCMI_LIB_NAMESPACE_BEGIN
namespace SiegeStuffThatShouldBeMovedToHandlers // <=== TODO
{
static BattleHex lineToWallHex(int line) //returns hex with wall in given line (y coordinate)
{
static const BattleHex lineToHex[] = {12, 29, 45, 62, 78, 96, 112, 130, 147, 165, 182};
@@ -90,9 +87,6 @@ static BattleHex WallPartToHex(EWallPart part)
return BattleHex::INVALID; //not found!
}
}
using namespace SiegeStuffThatShouldBeMovedToHandlers;
ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(const spells::Caster * caster, spells::Mode mode) const
{
@@ -1174,7 +1168,7 @@ std::pair<const battle::Unit *, BattleHex> CBattleInfoCallback::getNearestStack(
std::vector<DistStack> stackPairs;
battle::Units possible = battleGetUnitsIf([=](const battle::Unit * unit)
battle::Units possible = battleGetUnitsIf([closest](const battle::Unit * unit)
{
return unit->isValidTarget(false) && unit != closest;
});
@@ -1723,11 +1717,11 @@ battle::Units CBattleInfoCallback::battleAdjacentUnits(const battle::Unit * unit
const auto & hexes = unit->getSurroundingHexes();
const auto & units = battleGetUnitsIf([=](const battle::Unit * unit)
const auto & units = battleGetUnitsIf([&hexes](const battle::Unit * testedUnit)
{
if (unit->isDead())
if (testedUnit->isDead())
return false;
const auto & unitHexes = unit->getHexes();
const auto & unitHexes = testedUnit->getHexes();
for (const auto & hex : unitHexes)
if (hexes.contains(hex))
return true;