From 6253e8321b0537530bcd0817372914e4d6d58ddf Mon Sep 17 00:00:00 2001 From: Andrej Dudenhefner Date: Thu, 6 Nov 2025 12:23:15 +0100 Subject: [PATCH] Fix division by zero in RewardEvaluator::getArmyReward --- AI/Nullkiller/Engine/PriorityEvaluator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index 4335570bf..da7e94079 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -281,7 +281,9 @@ uint64_t RewardEvaluator::getArmyReward( for(const auto & stackInfo : info.reward.creatures) 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(1), info.reward.grantedArtifacts.size() + info.reward.creatures.size() + info.reward.grantedScrolls.size()); + + totalValue += rewardValue > 0 ? rewardValue / combined_size : 0; } return totalValue;