Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [RFC] square_dxy_iterate
Home

[Freeciv-Dev] Re: [RFC] square_dxy_iterate

[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: [RFC] square_dxy_iterate
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 24 Feb 2002 02:27:32 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sat, Feb 23, 2002 at 06:57:28PM -0500, Jason Short wrote:
> Raimar Falke wrote:
> > On Sat, Feb 23, 2002 at 07:23:27AM -0500, Jason Short wrote:
> > 
> >>Raimar Falke wrote:
> >>
> >>>On Fri, Feb 22, 2002 at 06:04:45PM -0500, Jason Short wrote:
> >>>
> >>>
> >>>>Raimar Falke wrote:
> >>>>
> >>>>
> >>>>>>From the profile of an autogame (with disabled CHECK_MAP_POS):
> >>>>>Flat profile:
> 
> > Flat profile:
> 
> [...]
> 
> > enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech)
> > {
> >   if (!tech_exists(tech)) {
> >     return TECH_UNKNOWN;
> >   }
> >   return pplayer->research.inventions[tech].state;
> > }
> > 
> > should be replaced with
> > 
> > enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech)
> > {
> >   assert(tech >= 0 && tech <game.num_tech_types);
> >   return pplayer->research.inventions[tech].state;
> > }
> 
> What is the purpose of tech_exists if it is not used?

If it really isn't used anymore it can be discareded. But this won't happend.

> What if the set of techs is not a continuous set (i.e. some values
> in 0..(game.num_tech_types-1) are not valid technologies)?

No problem. We check for safe array access before and then return the
array value. Now the code have to be audited so that the array always
contains a TECH_UNKNOWN if tech_exists() return FALSE.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  One nuclear bomb can ruin your whole day.


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