mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Merge pull request #6294 from mrhaandi/fix-ai-dividebyzero
Fix division by zero in RewardEvaluator::getArmyReward
This commit is contained in:
@@ -281,7 +281,9 @@ uint64_t RewardEvaluator::getArmyReward(
|
|||||||
for(const auto & stackInfo : info.reward.creatures)
|
for(const auto & stackInfo : info.reward.creatures)
|
||||||
rewardValue += stackInfo.getType()->getAIValue() * stackInfo.getCount();
|
rewardValue += stackInfo.getType()->getAIValue() * stackInfo.getCount();
|
||||||
|
|
||||||
totalValue += rewardValue > 0 ? rewardValue / (info.reward.grantedArtifacts.size() + info.reward.creatures.size()) : 0;
|
auto combined_size = std::min(static_cast<size_t>(1), info.reward.grantedArtifacts.size() + info.reward.creatures.size() + info.reward.grantedScrolls.size());
|
||||||
|
|
||||||
|
totalValue += rewardValue > 0 ? rewardValue / combined_size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalValue;
|
return totalValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user