Author: alink
Date: Mon May 11 22:04:00 2009
New Revision: 35575
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35575&view=rev
Log:
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.
Modified:
trunk/src/util.hpp
Modified: trunk/src/util.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/util.hpp?rev=35575&r1=35574&r2=35575&view=diff
==============================================================================
--- trunk/src/util.hpp (original)
+++ trunk/src/util.hpp Mon May 11 22:04:00 2009
@@ -45,7 +45,8 @@
* 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);
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits