Author: cazfi
Date: Thu May 18 11:02:52 2017
New Revision: 35630

URL: http://svn.gna.org/viewcvs/freeciv?rev=35630&view=rev
Log:
Fix division by zero when unit activity rate is zero

Reported by David Fernandez (bard)

See hrm Bug #660342

Modified:
    branches/S3_0/common/unit.c

Modified: branches/S3_0/common/unit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/unit.c?rev=35630&r1=35629&r2=35630&view=diff
==============================================================================
--- branches/S3_0/common/unit.c (original)
+++ branches/S3_0/common/unit.c Thu May 18 11:02:52 2017
@@ -414,8 +414,8 @@
   already done by this unit.
 **************************************************************************/
 int get_turns_for_activity_at(const struct unit *punit,
-                             enum unit_activity activity,
-                             const struct tile *ptile,
+                              enum unit_activity activity,
+                              const struct tile *ptile,
                               struct extra_type *tgt)
 {
   /* FIXME: This is just an approximation since we don't account for
@@ -423,7 +423,7 @@
   int speed = get_activity_rate(punit);
   int points_needed = tile_activity_time(activity, ptile, tgt);
 
-  if (points_needed >= 0 && speed >= 0) {
+  if (points_needed >= 0 && speed > 0) {
     return (points_needed - 1) / speed + 1; /* round up */
   } else {
     return FC_INFINITY;


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

Reply via email to