Skip to content

Commit

Permalink
change round_damage function for what base_damage variable was double…
Browse files Browse the repository at this point in the history
… instead of int
  • Loading branch information
newfrenchy83 committed Dec 22, 2024
1 parent 3e36bb4 commit de16296
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/units/abilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ std::pair<int,map_location> 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<double>(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()) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(1, (base_damage * bonus + rounding) / divisor);
return std::max<int>(1, static_cast<int>((base_damage * bonus + rounding) / divisor));
}

template<typename Cmp>
Expand Down

0 comments on commit de16296

Please sign in to comment.