mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Cache Pathfinding skill
This commit is contained in:
parent
627b63ca56
commit
77e43cb36f
@ -1019,6 +1019,7 @@ TurnInfo::BonusCache::BonusCache(TConstBonusListPtr bl)
|
||||
flyingMovementVal = bl->valOfBonuses(Selector::type()(Bonus::FLYING_MOVEMENT));
|
||||
waterWalking = static_cast<bool>(bl->getFirst(Selector::type()(Bonus::WATER_WALKING)));
|
||||
waterWalkingVal = bl->valOfBonuses(Selector::type()(Bonus::WATER_WALKING));
|
||||
pathfindingVal = bl->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING));
|
||||
}
|
||||
|
||||
TurnInfo::TurnInfo(const CGHeroInstance * Hero, const int turn)
|
||||
@ -1075,6 +1076,9 @@ int TurnInfo::valOfBonuses(Bonus::BonusType type, int subtype) const
|
||||
return bonusCache->flyingMovementVal;
|
||||
case Bonus::WATER_WALKING:
|
||||
return bonusCache->waterWalkingVal;
|
||||
case Bonus::SECONDARY_SKILL_PREMY:
|
||||
if (subtype == SecondarySkill::PATHFINDING)
|
||||
return bonusCache->pathfindingVal;
|
||||
}
|
||||
|
||||
return bonuses->valOfBonuses(Selector::type()(type).And(Selector::subtype()(subtype)));
|
||||
|
@ -513,6 +513,7 @@ struct DLL_LINKAGE TurnInfo
|
||||
int flyingMovementVal;
|
||||
bool waterWalking;
|
||||
int waterWalkingVal;
|
||||
int pathfindingVal;
|
||||
|
||||
BonusCache(TConstBonusListPtr bonusList);
|
||||
};
|
||||
|
@ -103,11 +103,9 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f
|
||||
&& !ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType.id()) //no special movement bonus
|
||||
)
|
||||
{
|
||||
static const CSelector selectorPATHFINDING = Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING);
|
||||
static const std::string keyPATHFINDING = "type_"+std::to_string((si32)Bonus::SECONDARY_SKILL_PREMY)+"s_"+std::to_string((si32)SecondarySkill::PATHFINDING);
|
||||
|
||||
ret = VLC->heroh->terrCosts[from.terType];
|
||||
ret -= valOfBonuses(selectorPATHFINDING, keyPATHFINDING);
|
||||
ret -= ti->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING);
|
||||
if(ret < GameConstants::BASE_MOVEMENT_COST)
|
||||
ret = GameConstants::BASE_MOVEMENT_COST;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user