Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: [PATCH] check_map_pos change (PR#1031)
Home

[Freeciv-Dev] Re: [PATCH] check_map_pos change (PR#1031)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] check_map_pos change (PR#1031)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 1 Nov 2001 15:00:30 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Nov 01, 2001 at 04:57:19AM -0800, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> Gaute B Strokkenes wrote:
> > 
> > On Tue, 30 Oct 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> > > On Tue, Oct 30, 2001 at 02:45:01AM +0000, Gaute B Strokkenes wrote:
> > >> On Mon, 29 Oct 2001, vze2zq63@xxxxxxxxxxx wrote:
> > >>
> > >> I propose the following:
> 
> With this one I have taken Gaute's most recent patch and made the
> following changes:
> 
> 1.  Renamed CHECK_POS as CHECK_MAP_POS.
> 
> 2.  Changed the #definition of CHECK_POS as Raimar suggested.
> 
> 3.  Moved the "#include <assert.h>" into map.h.
> 
> 4.  Changed existing assert(is_normal_map_pos(...)) to use CHECK_MAP_POS
> (or removed them, if appropriate).
> 
> 5.  Added CHECK_MAP_POS checks into all the map iterator macros (not
> city or unit ones).
> 
> 6.  Added CHECK_MAP_POS checks to is_tiles_adjacent.
> 
> My rule is this: all coordinates must be checked.  A function may only
> forego the check if it is passing the coordinates off to another
> function that it knows will do the check.  This leads to unfortunate
> dependencies, but the alternative is either checks everywhere or not
> enough checks.

We are close.

>  int is_tiles_adjacent(int x0, int y0, int x1, int y1)
>  {
> +  CHECK_MAP_POS(x1, y1);

> +  CHECK_MAP_POS(x0, y0); /* duplicated in adjc_iterate */

Replace with 
    /* (x0,y0) are checked in adjc_iterate */

> +#define CHECK_MAP_POS(x,y) \
> +  (assert(is_normal_map_pos((x),(y))), TRUE)

Why? Why not just "assert(is_normal_map_pos((x),(y)))"?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Q:  Do you know what the death rate around here is?
 A:  One per person.


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