mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Compute creature speed only once during evaluation
This commit is contained in:
parent
a3f9450d83
commit
9b8145f522
@ -890,11 +890,12 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb
|
||||
auto ratio = blockedUnitDamage / (blockedUnitDamage + activeUnitDamage);
|
||||
|
||||
auto unitReachability = turnBattle.getReachability(unit);
|
||||
auto unitSpeed = unit->speed(turn); // Cached value, to avoid performance hit
|
||||
|
||||
for(BattleHex hex = BattleHex::TOP_LEFT; hex.isValid(); hex = hex + 1)
|
||||
{
|
||||
bool enemyUnit = false;
|
||||
bool reachable = unitReachability.distances[hex] <= unit->speed(turn);
|
||||
bool reachable = unitReachability.distances[hex] <= unitSpeed;
|
||||
|
||||
if(!reachable && unitReachability.accessibility[hex] == EAccessibility::ALIVE_STACK)
|
||||
{
|
||||
@ -906,7 +907,7 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb
|
||||
|
||||
for(BattleHex neighbor : hex.neighbouringTiles())
|
||||
{
|
||||
reachable = unitReachability.distances[neighbor] <= unit->speed(turn);
|
||||
reachable = unitReachability.distances[neighbor] <= unitSpeed;
|
||||
|
||||
if(reachable) break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user