fix #7821: all cases of the calculation should be cached

in the previous logic some cases return from the function and others
would set a return variable that would be set later.

this commit, changes all the cases into all assignment.
This commit is contained in:
Goncalo Gomes 2023-09-13 10:35:01 +01:00 committed by Gunter Labes
parent e0b130434a
commit cab2a1b8f1

View File

@ -933,11 +933,11 @@ double recruitment::compare_unit_types(const std::string& a, const std::string&
double value_of_b = damage_to_a / (a_max_hp * b_cost);
if (value_of_a > value_of_b) {
return value_of_a / value_of_b;
retval = value_of_a / value_of_b;
} else if (value_of_a < value_of_b) {
return -value_of_b / value_of_a;
retval = -value_of_b / value_of_a;
} else {
return 0.;
retval = 0.;
}
}