Author: cazfi
Date: Thu May 18 15:13:08 2017
New Revision: 35644

URL: http://svn.gna.org/viewcvs/freeciv?rev=35644&view=rev
Log:
Make sure unit vision radius is not negative

Reported by David Fernandez (bard)

See hrm Bug #661313

Modified:
    branches/S3_0/server/unittools.c

Modified: branches/S3_0/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/unittools.c?rev=35644&r1=35643&r2=35644&view=diff
==============================================================================
--- branches/S3_0/server/unittools.c    (original)
+++ branches/S3_0/server/unittools.c    Thu May 18 15:13:08 2017
@@ -4452,17 +4452,17 @@
   properly.
 ****************************************************************************/
 int get_unit_vision_at(struct unit *punit, struct tile *ptile,
-                      enum vision_layer vlayer)
+                       enum vision_layer vlayer)
 {
   const int base = (unit_type_get(punit)->vision_radius_sq
-                   + get_unittype_bonus(unit_owner(punit), ptile,
+                    + get_unittype_bonus(unit_owner(punit), ptile,
                                          unit_type_get(punit),
-                                        EFT_UNIT_VISION_RADIUS_SQ));
+                                         EFT_UNIT_VISION_RADIUS_SQ));
   switch (vlayer) {
   case V_MAIN:
-    return base;
+    return MAX(0, base);
   case V_INVIS:
-    return MIN(base, 2);
+    return CLIP(0, base, 2);
   case V_COUNT:
     break;
   }


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

Reply via email to