[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]
<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;
|
|