Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#100
Home

[Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#100

[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: Remove map_adjust_[xy] invocations from server (PR#1003)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Oct 2001 08:49:08 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Oct 11, 2001 at 02:06:33PM -0700, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> This is basically a resubmission of my earlier map_adjust-3 patch, which
> was seemingly rejected (I think there was some miscommunication there).
> 
> It substitutes in is_real_tile, normalize_map_pos, and is_normal_map_pos
> in place of topology-specific code that does the same thing.
> 
> 
> The only issue I believe is that I replace
> 
>   x2 = map_adjust_x(x);
>   y2 = y;
> 
> with
> 
>   x2 = x, y2=y;
>   assert(is_real_tile(x2, y2));
>   normalize_map_pos(&x2, &y2);
> 
> alternately, a MACRO can be used to make this check (which I think is
> what Raimar wants), perhaps something like
> 
> #define CHECK_MAP_POS(x, y)
> {
>   assert(is_real_tile(x, y));
>   nearest_real_pos(&x, &y);
> }
> 
> or
> 
> #define CHECK_MAP_POS(x, y)
> {
>   int is_real = normalize_map_pos(&x, &y);
>   assert(is_real);
> }
> 
> I'm happy with just about any solution here, so long as it asserts
> is_real when in debugging mode.  Running nearest_real_pos will be
> slightly safer in NDEBUG mode.  The second macro is slightly faster than
> my current code.
> 
> Note the similarity between either of these macros and check_coords. 
> The difference is that check_coords expects the parameters to be normal,
> whereas this code only expects them to be real.

I plan to propose something like this:
 - there is a CHECK_MAP_POS(x,y) == assert(is_normal_map_pos(x,y));
 - every "assert(is_real_tile(x,y));normalize_map_pos(x,y)" is
 replaced by CHECK_MAP_POS
 - there is an extra check (if(!is_normal_map_pos(x,y)){y=x/0;})
 introduced in map_inx

In the short/medium term we can disable (but not remove)
CHECK_MAP_POS. We will probably leave the check in map_inx forever. So
I dislike the nearest_real_pos call above. If there are wrong map
positions we catch them (earlier(CHECK_MAP_POS) or later(map_inx)).

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I haven't lost my mind - it's backed up on tape somewhere."


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