Allow to have attack with damage=0...

(rounding of other attacks continue to be >0)

This also fix round_damage() which was supposed to round towards
base_damage, but was incorrect for 2 cases: when dividing by 1 (D/1
give D-1, but currently not used) and when base_damage was 0.
This commit is contained in:
Ali El Gariani 2009-05-11 20:04:00 +00:00
parent 2defaf7211
commit 125f186aaa

View file

@ -45,7 +45,8 @@ inline int div100rounded(int num) {
* but up or down towards base_damage
*/
inline int round_damage(int base_damage, int bonus, int divisor) {
const int rounding = divisor / 2 - (bonus < divisor ? 0 : 1);
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);
}