Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#436) Bug: game state not totally preserved in save
Home

[Freeciv-Dev] Re: (PR#436) Bug: game state not totally preserved in save

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: caz@xxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#436) Bug: game state not totally preserved in savegames
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Mon, 23 Aug 2004 10:23:36 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=436 >


  Attached patch saves unit (iteration) positions in tile.units and 
city.supported.


  - Caz

diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2004-08-22 13:33:06.671875000 +0300
+++ freeciv/server/savegame.c   2004-08-23 20:07:36.250985200 +0300
@@ -2414,6 +2414,34 @@
       secfile_insert_str(file, "-",
                         "player%d.u%d.dir_list", plrno, i);
     }
+    int unit_list_index = 0;
+    unit_list_iterate(map_get_tile(punit->x, punit->y)->units, tile_unit) {
+      if (punit->id == tile_unit->id) {
+        secfile_insert_int(file, unit_list_index, "player%d.u%d.tile_index",
+                           plrno, i);
+        break;
+      }
+      unit_list_index++;
+    }
+    unit_list_iterate_end;
+
+    struct city *pcity = find_city_by_id(punit->homecity);
+    if (pcity) {
+      unit_list_index = 0;
+      unit_list_iterate(pcity->units_supported, supported_unit) {
+        if (punit->id == supported_unit->id) {
+          secfile_insert_int(file, unit_list_index, "player%d.u%d.city_index",
+                             plrno, i);
+          break;
+        }
+        unit_list_index++;
+      }
+      unit_list_iterate_end;
+    } else {
+      /* Secfile format requires city_index entry for all units. */
+      secfile_insert_int(file, -1, "player%d.u%d.city_index",
+                         plrno, i);
+    }
   }
   unit_list_iterate_end;
 

[Prev in Thread] Current Thread [Next in Thread]