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: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] turn_founded
From: Mike Kaufman <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Mar 2002 11:15:50 -0600

On Mon, Mar 04, 2002 at 05:25:14PM +0100, Raimar Falke wrote:
> On Mon, Mar 04, 2002 at 06:20:24AM -0500, Jason Short wrote:
> > Raimar Falke wrote:
> > >>-    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?
> 
> I think it is bad if a value is normally >=0 and for some cities -1.
> 
> > 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.
> 
> IMHO we should insert an assert:
> 
> +      if (did_buy >= 0) {
>   assert(game.turn>0);

no. this assert crap is starting to get silly. We should write the code so
that game turn is initialized to a non-negative number and stays 
non-negative.

speaking of asserts, has anybody attempted to run an autogame with -DNDEBUG
lately? I didn't think so.

-mike

> +        pcity->turn_founded = game.turn - 1;
> +        pcity->did_buy = (did_buy != 0);
> +      } else {
> 
> > 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).
> 
> Yes.
> 
>       Raimar
> 
> -- 
>  email: rf13@xxxxxxxxxxxxxxxxx
>  "The BeOS takes the best features from the major operating systems. 
>   It's got the power and flexibility of Unix, the interface and ease 
>   of use of the MacOS, and Minesweeper from Windows."


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