Author: cazfi
Date: Sat Nov 14 19:01:26 2015
New Revision: 30611

URL: http://svn.gna.org/viewcvs/freeciv?rev=30611&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_6/server/savegame2.c

Modified: branches/S2_6/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=30611&r1=30610&r2=30611&view=diff
==============================================================================
--- branches/S2_6/server/savegame2.c    (original)
+++ branches/S2_6/server/savegame2.c    Sat Nov 14 19:01:26 2015
@@ -7280,6 +7280,25 @@
                                sizeof(server.game_identifier));
   }
 
+  /* 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_get(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
    * inexplicably altered the previously existing state. */
   if (!game.info.is_new_game) {


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

Reply via email to