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 18:33:47 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Mar 04, 2002 at 12:29:13PM -0500, Jason Short wrote:
> Mike Kaufman wrote:
> > On Mon, Mar 04, 2002 at 05:25:14PM +0100, Raimar Falke wrote:
> 
> >>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.
> 
> Well, that's what this code is intended to do, and I really don't see 
> how it could fail.
> 
> The purpose of the assert is to make sure what you're certain of really 
> is true.  If we're *absolutely* certain of it, then the assert basically 
> acts as a comment to someone reading the code:
> 
>    /* this will never make the game turn drop below 0 */
> 

> (but, Raimar, shouldn't it be assert(game.turn >= 0)?  Is the first turn 
> 0 or 1?)

0.

> > speaking of asserts, has anybody attempted to run an autogame with -DNDEBUG
> > lately? I didn't think so.
> 
> I did a month or so ago.  I found a whole slew of compiler warnings (now 
> fixed, I believe), and a significant improvement in runtime [1].
> 
> [1] This is mostly from all of the assert(is_normal_map_pos(...)) calls.

To be fair you have to do a run with CHECK_MAP_POS disabled first.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Programming today is a race between software engineers striving to
  build bigger and better idiot-proof programs, and the Universe trying
  to produce bigger and better idiots. So far, the Universe is winning."
    -- Rich Cook


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