Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [Patch] turn_founded
Home

[Freeciv-Dev] Re: [Patch] turn_founded

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] turn_founded
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Mar 2002 12:01:33 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

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 ;)

> 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.

> +        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.

>      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);

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Using only the operating-system that came with your computer is just
  like only playing the demo-disc that came with your CD-player."


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