[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 >
Marko Lindqvist wrote:
> Attached patch saves unit (iteration) positions in tile.units and
> city.supported.
This version also avoids unused entry warnings while loading such
savegames. I'm working on loading part, but it will probably take some
time before it is in shape to be committed into CVS. I'd like this
saving part to go in before next release anyway. So stock 1.15.0 would
provide unit list order information in savegames and developers might be
able to reproduce some bugs from such savegames using patched (loading
part applied) versions even when stock 1.15.0 doesn't reproduce them.
- Caz
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c 2004-08-27 15:50:11.640625000 +0300
+++ freeciv/server/savegame.c 2004-08-28 13:48:52.375000000 +0300
@@ -1403,6 +1403,13 @@
unit_type(punit)->vision_range);
}
+ /* Even though these are not currently used, read and discard them
+ in order to avoid 'unused entry' warnings. */
+ secfile_lookup_int_default(file, -1,
+ "player%d.u%d.tile_index", plrno, i);
+ secfile_lookup_int_default(file, -1,
+ "player%d.u%d.city_index", plrno, i);
+
unit_list_insert_back(&plr->units, punit);
unit_list_insert(&map_get_tile(punit->x, punit->y)->units, punit);
@@ -2442,6 +2449,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;
Files freeciv/tamatasta.sav.gz and freeciv/tamatasta.sav.gz differ
|
|