[Freeciv-Dev] Re: [RFC] square_dxy_iterate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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.
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, (continued)
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Petr Baudis, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Petr Baudis, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Jason Short, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Jason Short, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate,
Raimar Falke <=
|
|