Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: common/city.h
Home

[Freeciv-Dev] Re: common/city.h

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Dirk Stoecker <stoecker@xxxxxxxx>
Cc: freeciv development <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: common/city.h
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Sun, 14 Oct 2001 01:01:56 +0100

On Mon, 24 Sep 2001, stoecker@xxxxxxxx wrote:
> On Mon, 24 Sep 2001, Raimar Falke wrote:
> 
>> > > You won't catch the wrong tests in the ai code. Either you
>> > > audit the code or add checks to ensure that there are no
>> > > uninitialsed type fields or other nasty things.
>> > 
>> > If I understand it correctly, this was left in for security
>> > reasons, when these enums where introduced. So "theoretically"
>> > there should be no problems. Practically there maybe some, but we
>> > never find them without removing the =0. At least there should be
>> > none, which can be found by easy code reviews.
>> 
>> This at ./ai/aicity.c:416: "else if (!bestchoice.type &&
> 
> Line 411 according to web interface.
> 
>> is_wonder(bestchoice.choice)" is one of the problems which is
>> exists in the code. At least I can't tell if "!bestchoice.type"
>> should be "bestchoice.type==CT_NONE" or
>> "bestchoice.type==CT_BUILDING". So it is not as easy as removing
>> the "=0".
> 
> Compared to line 255 I would say CT_BUILDING.
> 
> But I see, that there are far too much positions like this left. I
> thought the progress was gone farther.

What about using

#define CT_NONE 0

here?  The principal benefit of using an enum over defines is that you
can see the names in a debugger.  That falls down when there are
multiple names for the same value...

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
INSIDE, I have the same personality disorder as LUCY RICARDO!!


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