Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Profile.
Home

[Freeciv-Dev] Re: Profile.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gaute B Strokkenes <gs234@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Profile.
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Sep 2001 10:03:46 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Sep 28, 2001 at 02:40:09AM +0200, Gaute B Strokkenes wrote:
> On Wed, 26 Sep 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> > 
> > There is hope! After the removal of the DIR_DX array I made some
> > changes to catch any un-real map positions. There were none. So I
> > changed it to catch any non-normal(ized) map accesses. They came
> > from lines such as:
> > 
> >   enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2);
> >   enum tile_terrain_type tile_t=map_get_terrain(pcity->x+x-2, pcity->y+y-2);
> > 
> > The proposed patch would get rid of these.
> 
> I think that's a good idea.
> 
> > Although I haven't checked I'm sure that there are none or only a
> > very few non-normal(ized) map accesses left. So we can in theory
> > remove a lot of the is_real_tile and normalize_map_pos calls in
> > map_get_tile and co. However for the ability to check this in the
> > long run I would like to propose the following:
> > 
> > #define CHECK_MAP_POS(x,y) do{\
> >     int dx = x, dy = y; \
> >     assert(normalize_map_pos(&dx, &dy)); \
> >     assert(x == dx && y == dy); \
> >   } while(0)
> 
> Are you aware of check_coords() ?

No but this is another function call. And it doesn't assert or abort
or exit. I don't want an error message I want a core dump. Such
problems are errors.

> > So map_get_tile would be like:
> > 
> > struct tile *map_get_tile(int x, int y)
> > {
> >   CHECK_MAP_POS(x,y);
> > 
> >   return map.tiles + map_inx(x, y);
> > }
> > 
> > CHECK_MAP_POS can now check for 
> >  - un-real map position or for
> >  - non-normal(ized) map positions or
> >  - can be a noop
> 
> This is very similar to what I've been thinking about.  However, I
> think we should embedded this in map_inx() instead.  I think that
> would be a lot less intrusive and probably more thorough.

Problem is: map_inx isn't used much.

$ grep -Ir map_inx .|wc -l
     11
$ grep -Ir y .|grep '\*'|grep map.xsize|grep -v map.ysize |wc -l
     21

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I was dead ... but I'm better now."
    -- Capitain Sheridan in Babylon 5


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