1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-07 07:10:04 +02:00

Fixed crash in pathfinder

This commit is contained in:
Tomasz Zieliński 2022-09-21 21:44:39 +02:00
parent fa31309eed
commit e53613caa7
3 changed files with 6 additions and 7 deletions

View File

@ -1027,7 +1027,7 @@ TurnInfo::TurnInfo(const CGHeroInstance * Hero, const int turn)
{ {
bonuses = hero->getAllBonuses(Selector::days(turn), Selector::all, nullptr, ""); bonuses = hero->getAllBonuses(Selector::days(turn), Selector::all, nullptr, "");
bonusCache = make_unique<BonusCache>(bonuses); bonusCache = make_unique<BonusCache>(bonuses);
nativeTerrain = VLC->terrainTypeHandler->terrains()[hero->getNativeTerrain()]; nativeTerrain = hero->getNativeTerrain();
} }
bool TurnInfo::isLayerAvailable(const EPathfindingLayer layer) const bool TurnInfo::isLayerAvailable(const EPathfindingLayer layer) const

View File

@ -523,7 +523,7 @@ struct DLL_LINKAGE TurnInfo
TConstBonusListPtr bonuses; TConstBonusListPtr bonuses;
mutable int maxMovePointsLand; mutable int maxMovePointsLand;
mutable int maxMovePointsWater; mutable int maxMovePointsWater;
const TerrainType * nativeTerrain; TTerrain nativeTerrain;
TurnInfo(const CGHeroInstance * Hero, const int Turn = 0); TurnInfo(const CGHeroInstance * Hero, const int Turn = 0);
bool isLayerAvailable(const EPathfindingLayer layer) const; bool isLayerAvailable(const EPathfindingLayer layer) const;

View File

@ -98,10 +98,9 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f
break; break;
} }
} }
else if(ti->nativeTerrain->id != from.terType->id //the terrain is not native else if(ti->nativeTerrain != from.terType->id &&//the terrain is not native
&& ti->nativeTerrain != nullptr //no special creature bonus ti->nativeTerrain != Terrain::ANY_TERRAIN && //no special creature bonus
&& !ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType->id) //no special movement bonus !ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType->id)) //no special movement bonus
)
{ {
ret = VLC->heroh->terrCosts[from.terType->id]; ret = VLC->heroh->terrCosts[from.terType->id];
@ -128,7 +127,7 @@ TTerrain CGHeroInstance::getNativeTerrain() const
if(stackNativeTerrain == Terrain::BORDER) //where does this value come from? if(stackNativeTerrain == Terrain::BORDER) //where does this value come from?
continue; continue;
if(nativeTerrain == Terrain::BORDER) //FIXME: this statement is always true if(nativeTerrain == Terrain::BORDER)
nativeTerrain = stackNativeTerrain; nativeTerrain = stackNativeTerrain;
else if(nativeTerrain != stackNativeTerrain) else if(nativeTerrain != stackNativeTerrain)
return Terrain::BORDER; return Terrain::BORDER;