Author: cazfi
Date: Sat Nov 14 19:01:32 2015
New Revision: 30612

URL: http://svn.gna.org/viewcvs/freeciv?rev=30612&view=rev
Log:
Make a savegame loading time check if player has multiple units of a type that 
should
never have more than one instance (unique unit).

See patch #6561

Modified:
    branches/S2_5/server/savegame2.c

Modified: branches/S2_5/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/savegame2.c?rev=30612&r1=30611&r2=30612&view=diff
==============================================================================
--- branches/S2_5/server/savegame2.c    (original)
+++ branches/S2_5/server/savegame2.c    Sat Nov 14 19:01:32 2015
@@ -6329,6 +6329,25 @@
         ds->max_state = ds->type;
       }
     } players_iterate_end;
+  } players_iterate_end;
+
+  /* Check if some player has more than one of some UTYF_UNIQUE unit type */
+  players_iterate(pplayer) {
+    int utype_count[U_LAST];
+
+    memset(utype_count, 0, sizeof(utype_count));
+
+    unit_list_iterate(pplayer->units, punit) {
+      utype_count[utype_index(unit_type(punit))]++;
+    } unit_list_iterate_end;
+
+    unit_type_iterate(ut) {
+      if (utype_count[utype_index(ut)] > 1 && utype_has_flag(ut, UTYF_UNIQUE)) 
{
+        log_sg(_("%s has multiple units of type %s though it should be 
possible "
+                 "to have only one."),
+               player_name(pplayer), utype_name_translation(ut));
+      }
+    } unit_type_iterate_end;
   } players_iterate_end;
 
   /* Restore game random state, just in case various initialization code


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

Reply via email to