[Freeciv-Dev] Re: [Patch] turn_founded
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
On Mon, Mar 04, 2002 at 04:18:12AM -0500, Jason Short wrote:
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.
Long term goal. I ask myself if the freeciv code will be really pretty
at some point?! Probably this is more a philosophical question ;)
Lol.
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.
Ack.
- 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;
This may lead to a negative value.
Is that bad? Didn't you use -2 as the default turn_founded?
But actually, I don't think it can give a negative value. If a city is
founded on the first turn and then you save/reload on the first turn,
then did_buy would have been -1 anyway.
+ 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);
Should be _bool.
Is there a secfile_insert_bool? <checks> I guess so. Yes, that makes
it "prettier". It should also be secfile_lookup_bool for did_buy up
above (only when we have the capability).
jason
- [Freeciv-Dev] [Patch] turn_founded, Raimar Falke, 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, 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
- [Freeciv-Dev] Re: [Patch] turn_founded, Raimar Falke, 2002/03/04
[Freeciv-Dev] Re: [Patch] turn_founded, Gregory Berkolaiko, 2002/03/04
|
|