Author: cazfi
Date: Thu May 18 11:16:11 2017
New Revision: 35634

URL: http://svn.gna.org/viewcvs/freeciv?rev=35634&view=rev
Log:
Make sure veterancy of the newly built unit is not negative

Reported by David Fernandez (bard)

See hrm Bug #661193

Modified:
    branches/S3_0/server/citytools.c

Modified: branches/S3_0/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/citytools.c?rev=35634&r1=35633&r2=35634&view=diff
==============================================================================
--- branches/S3_0/server/citytools.c    (original)
+++ branches/S3_0/server/citytools.c    Thu May 18 11:16:11 2017
@@ -571,9 +571,13 @@
 int do_make_unit_veteran(struct city *pcity,
                          const struct unit_type *punittype)
 {
-  return MIN(get_unittype_bonus(city_owner(pcity), pcity->tile, punittype,
-                                EFT_VETERAN_BUILD),
-             utype_veteran_levels(punittype) - 1);
+  int levels = get_unittype_bonus(city_owner(pcity), pcity->tile, punittype,
+                                  EFT_VETERAN_BUILD);
+  int max_levels = utype_veteran_levels(punittype) - 1;
+
+  levels = CLIP(0, levels, max_levels);
+
+  return levels;
 }
 
 /*********************************************************************


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

Reply via email to