Author: sveinung
Date: Fri Nov  4 13:10:56 2016
New Revision: 34386

URL: http://svn.gna.org/viewcvs/freeciv?rev=34386&view=rev
Log:
Keep attack action probability in range.

Fix a rounding error that could result in "Attack"'s action probability to
go outside the act_prob struct's range for non signal values.

See bug #25261

Modified:
    trunk/common/actions.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=34386&r1=34385&r2=34386&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Fri Nov  4 13:10:56 2016
@@ -2915,8 +2915,10 @@
       if (can_player_see_unit(actor_player, defender_unit)) {
         double unconverted = unit_win_chance(actor_unit, defender_unit);
 
-        chance.min = floor((double)ACTPROB_VAL_MAX * unconverted);
-        chance.max = ceil((double)ACTPROB_VAL_MAX * unconverted);
+        chance.min = MAX(ACTPROB_VAL_MIN,
+                         floor((double)ACTPROB_VAL_MAX * unconverted));
+        chance.max = MIN(ACTPROB_VAL_MAX,
+                         ceil((double)ACTPROB_VAL_MAX * unconverted));
       } else if (known == TRI_YES) {
         known = TRI_MAYBE;
       }


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to