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: Mike Kaufman <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Cc: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] turn_founded
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Mar 2002 18:26:13 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Mar 04, 2002 at 11:15:50AM -0600, Mike Kaufman wrote:
> 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.

Note the difference between >=0 (this is guarantied for game.turn) and
>0 (the same as != 0 in this case).

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

Inlining will bring more IMHO.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  This customer comes into the computer store. "I'm looking for a mystery
  Adventure Game with lots of graphics. You know, something realy
  challenging". "Well," replied the clerk, "have you tried Windows 98 ?"


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