[Freeciv-Dev] Re: [Patch] turn_founded
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
The patch fixed two problems which are unrelated on the first sight:
did_buy isn't a bool and the cities in the city dialog (next/prev
buttons) are unsorted.
did_buy hasn't been converted to bool since it is set to -1 in the
turn it is founded. This is used to give a different message which you
try to buy something. Solved by introducing a turn_founded field in
struct city.
A long time ago we discussed without result by what criteria cities
should be sorted in the city dialog. In Civ3 the criteria is the time
of the city foundation. IMHO this criteria is usefull. You may guess
it: we use the new field for the sorting.
Patch is straightforward except the savegame compatibility which may
need extra eye balls.
The savegame stuff looks correct, but I don't like the idea of keeping
the old save file format for new games. I'd much rather do things like
this [patch attached]. Eventually I imagine save file compatibility
will be broken, all of the capability checks can be removed, and then
things will be Pretty. Until then the only drawback is that if you use
an *old* server to load a *new* game, a city that was founded this turn
will be treated as one that was founded earlier but had already bought
this turn (i.e. you'll get the wrong error message if you try to buy).
That seems like a quite acceptable tradeoff to me.
jason
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.66
diff -u -r1.66 savegame.c
--- server/savegame.c 2002/02/27 11:46:21 1.66
+++ server/savegame.c 2002/03/04 09:12:37
@@ -145,7 +145,7 @@
*/
#define SAVEFILE_OPTIONS "1.7 startoptions spacerace2 rulesets" \
" diplchance_percent worklists2 map_editor known32fix turn " \
-"attributes watchtower"
+"attributes watchtower turn_founded"
static const char hex_chars[] = "0123456789abcdef";
static const char terrain_chars[] = "adfghjm prstu";
@@ -806,8 +806,24 @@
secfile_lookup_int_default(file, 0,
"player%d.c%d.caravan_shields", plrno, i);
- pcity->did_buy=secfile_lookup_int(file,
+ if (has_capability("turn_founded", savefile_options)) {
+ pcity->turn_founded = secfile_lookup_int(file,
+ "player%d.c%d.turn_founded",
+ plrno, i);
+ pcity->did_buy = secfile_lookup_int(file, "player%d.c%d.did_buy",
+ plrno, i);
+ } else {
+ int did_buy = secfile_lookup_int(file,
"player%d.c%d.did_buy", plrno,i);
+ if (did_buy >= 0) {
+ pcity->turn_founded = game.turn - 1;
+ pcity->did_buy = (did_buy != 0);
+ } else {
+ pcity->turn_founded = game.turn;
+ pcity->did_buy = TRUE;
+ }
+ }
+
pcity->did_sell =
secfile_lookup_bool_default(file, FALSE, "player%d.c%d.did_sell",
plrno,i);
@@ -1464,6 +1480,8 @@
secfile_insert_int(file, pcity->anarchy, "player%d.c%d.anarchy", plrno,i);
secfile_insert_int(file, pcity->rapture, "player%d.c%d.rapture", plrno,i);
secfile_insert_bool(file, pcity->was_happy, "player%d.c%d.was_happy",
plrno,i);
+ secfile_insert_int(file, pcity->turn_founded, "player%d.c%d.turn_founded",
+ plrno, i);
secfile_insert_int(file, pcity->did_buy, "player%d.c%d.did_buy", plrno,i);
secfile_insert_bool(file, pcity->did_sell, "player%d.c%d.did_sell",
plrno,i);
secfile_insert_bool(file, pcity->airlift, "player%d.c%d.airlift", plrno,i);
- [Freeciv-Dev] [Patch] turn_founded, Raimar Falke, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded,
Jason Short <=
- [Freeciv-Dev] Re: [Patch] turn_founded, Raimar Falke, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded, Raimar Falke, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded, Mike Kaufman, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded, Jason Short, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded, Raimar Falke, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded, Mike Kaufman, 2002/03/04
- [Freeciv-Dev] Re: [Patch] turn_founded, Raimar Falke, 2002/03/04
|
|