diff --git a/src/units/abilities.cpp b/src/units/abilities.cpp index 2aaa71b891d1e..5ab5912207913 100644 --- a/src/units/abilities.cpp +++ b/src/units/abilities.cpp @@ -701,7 +701,7 @@ std::pair unit_ability_list::get_extremum(const std::string& k for (const unit_ability& p : cfgs_) { int value = std::round(get_single_ability_value((*p.ability_cfg)[key], static_cast(def), p, loc(), const_attack_ptr(), [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { - return formula.evaluate(callable).as_int() / 1.0; + return std::round(formula.evaluate(callable).as_int()); })); if ((*p.ability_cfg)["cumulative"].to_bool()) { diff --git a/src/utils/math.hpp b/src/utils/math.hpp index e9c1ed44f5f60..4198530f1256d 100644 --- a/src/utils/math.hpp +++ b/src/utils/math.hpp @@ -77,10 +77,10 @@ constexpr T modulo(T num, int mod, T min = 0) * round (base_damage * bonus / divisor) to the closest integer, * but up or down towards base_damage */ -constexpr int round_damage(int base_damage, int bonus, int divisor) { +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(1, (base_damage * bonus + rounding) / divisor); + return std::max(1, static_cast((base_damage * bonus + rounding) / divisor)); } template