Skip to content

Commit

Permalink
change math for use std::round() intead of rounding variable
Browse files Browse the repository at this point in the history
else, final value ever truncated, and don't round damage before bonus calculation(leadership and Tod) make a UI bug(damage colored like if leadership used same if not)
  • Loading branch information
newfrenchy83 committed Dec 22, 2024
1 parent 895bdcf commit e1203f3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/utils/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ constexpr T modulo(T num, int mod, T min = 0)
*/
constexpr int round_damage(double base_damage, int bonus, int divisor) {
if (base_damage==0) return 0;
const int rounding = divisor / 2 - (bonus < divisor || divisor==1 ? 0 : 1);
return std::max<int>(1, static_cast<int>((base_damage * bonus + rounding) / divisor));
return std::max<int>(1, std::round((base_damage * bonus) / divisor));
}

template<typename Cmp>
Expand Down

0 comments on commit e1203f3

Please sign in to comment.