Author: sveinung
Date: Tue Jun 28 12:39:31 2016
New Revision: 33081

URL: http://svn.gna.org/viewcvs/freeciv?rev=33081&view=rev
Log:
Allow unlikely to win attacks.

Round the "Attack" action probability up. If an action probability is
rounded down to 0% the action is seen as disabled.

Reported by Marko Lindqvist <cazfi>

See bug #24802

Modified:
    trunk/common/actions.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33081&r1=33080&r2=33081&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Tue Jun 28 12:39:31 2016
@@ -14,6 +14,8 @@
 #ifdef HAVE_CONFIG_H
 #include <fc_config.h>
 #endif
+
+#include <math.h> /* ceil */
 
 /* utility */
 #include "astring.h"
@@ -2423,7 +2425,9 @@
       if (can_player_see_unit(actor_player, defender_unit)) {
         double unconverted = unit_win_chance(actor_unit, defender_unit);
 
-        chance = (int)((double)200 * unconverted);
+        /* Action is seen as disabled by anyone that relies on action
+         * probability if it is rounded down to 0%. */
+        chance = ceil((double)200 * 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