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: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] turn_founded
From: Jason Short <vze2zq63@xxxxxxxxxxx>
Date: Mon, 04 Mar 2002 12:29:13 -0500
Reply-to: jdorje@xxxxxxxxxxxx

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

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.

jason



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