Complete.Org: Mailing Lists: Archives: freeciv-dev: September 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: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Sep 2001 15:37:29 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Sep 24, 2001 at 02:46:44PM +0200, Dirk Stoecker wrote:
> Hi,
> 
> wouldn't it be time to change line 129/130 of common/city.h from
> 
> enum choice_type { CT_NONE = 0, CT_BUILDING = 0, CT_NONMIL, CT_ATTACKER,
>                    CT_DEFENDER, CT_LAST };
> 
> to
> 
> enum choice_type { CT_NONE = 0, CT_BUILDING, CT_NONMIL, CT_ATTACKER,
>                    CT_DEFENDER, CT_LAST };
> 
> and thus remove the annoying warning of duplicate enums in nearly every
> source (SAS-C compiler) and increase code quality?

Yes this one is ugly.

> I think this should be done now to fix possibly existing wrong tests long
> time before next release.

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.

These look wrong (from a 'grep -Irn "choice.*type" .|grep -v CT_'):
./ai/aicity.c:416:      else if (!bestchoice.type && 
is_wonder(bestchoice.choice) &&
./ai/aicity.c:418:      else if (bestchoice.type && 
unit_type_flag(bestchoice.choice, F_CITIES) &&
./ai/aicity.c:421:      else if (bestchoice.type && bestchoice.type < 3 && /* 
not a defender */
./ai/aicity.c:427:      else if (bestchoice.type == 3 && pcity->size == 1 &&
./ai/aicity.c:443:      } else if (bestchoice.type || 
!is_wonder(bestchoice.choice)) {
./ai/aicity.c:446:                    (bestchoice.type ? 
unit_name(bestchoice.choice)
./ai/aicity.c:449:        if (bestchoice.type && 
!unit_type_flag(bestchoice.choice, F_NONMIL)) {

It looks like domestic_advisor_choose_build,
military_advisor_choose_build and ai_advisor_choose_building will
always return a valid type.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "We've all heard that a million monkeys banging on a million typewriters
  will eventually reproduce the entire works of Shakespeare.
  Now, thanks to the Internet, we know this is not true."


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