1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Fixes warnings about possibly dangling references

This commit is contained in:
Joakim Thorén 2023-12-27 22:24:58 +01:00
parent bb6179d05e
commit 406d136cdc
2 changed files with 6 additions and 9 deletions

View File

@ -265,10 +265,11 @@ uint64_t DangerHitMapAnalyzer::enemyCanKillOurHeroesAlongThePath(const AIPath &
{ {
int3 tile = path.targetTile(); int3 tile = path.targetTile();
int turn = path.turn(); int turn = path.turn();
const HitMapNode & info = hitMap[tile.x][tile.y][tile.z]; const auto & fastestDanger = hitMap[tile.x][tile.y][tile.z].fastestDanger;
const auto & maximumDanger = hitMap[tile.x][tile.y][tile.z].fastestDanger;
return (info.fastestDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.fastestDanger.danger)) return (fastestDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, fastestDanger.danger))
|| (info.maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.maximumDanger.danger)); || (maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, maximumDanger.danger));
} }
const HitMapNode & DangerHitMapAnalyzer::getObjectThreat(const CGObjectInstance * obj) const const HitMapNode & DangerHitMapAnalyzer::getObjectThreat(const CGObjectInstance * obj) const
@ -280,9 +281,7 @@ const HitMapNode & DangerHitMapAnalyzer::getObjectThreat(const CGObjectInstance
const HitMapNode & DangerHitMapAnalyzer::getTileThreat(const int3 & tile) const const HitMapNode & DangerHitMapAnalyzer::getTileThreat(const int3 & tile) const
{ {
const HitMapNode & info = hitMap[tile.x][tile.y][tile.z]; return hitMap[tile.x][tile.y][tile.z];
return info;
} }
const std::set<const CGObjectInstance *> empty = {}; const std::set<const CGObjectInstance *> empty = {};

View File

@ -321,9 +321,7 @@ bool AINodeStorage::hasBetterChain(const PathNodeInfo & source, CDestinationNode
bool AINodeStorage::isTileAccessible(const int3 & pos, const EPathfindingLayer layer) const bool AINodeStorage::isTileAccessible(const int3 & pos, const EPathfindingLayer layer) const
{ {
const AIPathNode & node = nodes[layer][pos.z][pos.x][pos.y][0]; return nodes[layer][pos.z][pos.x][pos.y][0].action != EPathNodeAction::UNKNOWN;
return node.action != EPathNodeAction::UNKNOWN;
} }
std::vector<AIPath> AINodeStorage::getChainInfo(const int3 & pos, bool isOnLand) const std::vector<AIPath> AINodeStorage::getChainInfo(const int3 & pos, bool isOnLand) const