Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2002:
[Freeciv-Dev] Re: normalize_map_pos and invalid map positions
Home

[Freeciv-Dev] Re: normalize_map_pos and invalid map positions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: normalize_map_pos and invalid map positions
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Sat, 10 Aug 2002 02:16:24 +0200

On Fri, Aug 09, 2002 at 11:02:44PM +0000, Per I. Mathisen wrote:

I will leave the other "uninteresting"/easy questions to Jason ;)

> > The problem comes in when we consider worst-case scenarios.Suppose a
> > particular piece of code does not correctly normalize the coordinates
> > before passing them in.Usually we could just normalize them and be
> > done with it, but in this case that's dangerous.If (-1,-1) is passed
> > in we cannot tell if we should normalize or treat it as a special case.

> Just make a strict policy and interface, then enforce it? For each data
> structure, designate whether it will contain normalized or raw
> coordinates. The latter I would think should only be generated in a very
> few places in the code. Or am I wrong?

Yes. Unreal map positions are removed/skipped immediately. The
remaining ones are normalized. So almost all of the code only works on
normal positions. There are no guards except at the bottom:
CHECK_MAP_POS at map_get_tile and co.

> > And what if (-2,-2) is passed in?
> 
> If we encounter that in a piece of data where coords should be normalized,
> then obviously we should assert and die (or freelog and return). No?

Or ignore the packet. See also CHECK_MAP_POS (which got disabled some
weeks ago in non-debug mode (you should enable it if you make the
goto_dest_ changes)).

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Using only the operating-system that came with your computer is just
  like only playing the demo-disc that came with your CD-player."


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