Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14167) Alliances check in savegame.c
Home

[Freeciv-Dev] (PR#14167) Alliances check in savegame.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14167) Alliances check in savegame.c
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Sun, 2 Oct 2005 23:55:19 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14167 >

The code which checks alliances works on uninitialized data. The
attached patch fixes it.
--
mateusz
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.279
diff -u -r1.279 savegame.c
--- server/savegame.c   3 Oct 2005 02:50:47 -0000       1.279
+++ server/savegame.c   3 Oct 2005 06:50:36 -0000
@@ -1934,17 +1934,6 @@
     secfile_lookup_int_default(file, 0,
                           "player%d.diplstate%d.contact_turns_left", plrno, i);
   }
-  /* Sanity check alliances, prevent allied-with-ally-of-enemy */
-  players_iterate(aplayer) {
-    if (pplayers_allied(plr, aplayer)
-        && !pplayer_can_ally(plr, aplayer)) {
-      freelog(LOG_ERROR, _("Illegal alliance structure detected: "
-              "%s's alliance to %s reduced to peace treaty."),
-              plr->name, aplayer->name);
-      plr->diplstates[aplayer->player_no].type = DS_PEACE;
-      aplayer->diplstates[plr->player_no].type = DS_PEACE;
-    }
-  } players_iterate_end;
 
   { /* spacerace */
     struct player_spaceship *ship = &plr->spaceship;
@@ -3605,6 +3594,21 @@
        team_add_player(pplayer, find_empty_team());
       }
     } players_iterate_end;
+    
+    /* Sanity check alliances, prevent allied-with-ally-of-enemy */
+    players_iterate(plr) {
+      players_iterate(aplayer) {
+        if (pplayers_allied(plr, aplayer)
+            && !pplayer_can_ally(plr, aplayer)) {
+          freelog(LOG_ERROR, _("Illegal alliance structure detected: "
+                  "%s's alliance to %s reduced to peace treaty."),
+                  plr->name, aplayer->name);
+          plr->diplstates[aplayer->player_no].type = DS_PEACE;
+          aplayer->diplstates[plr->player_no].type = DS_PEACE;
+        }
+      } players_iterate_end;
+    } players_iterate_end;
+
 
     /* Update all city information.  This must come after all cities are
      * loaded (in player_load) but before player (dumb) cities are loaded

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#14167) Alliances check in savegame.c, Mateusz Stefek <=