[Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#10
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
>
> On Fri, Oct 12, 2001 at 05:40:13AM -0400, Jason Dorje Short wrote:
<snip...>
> > Upon further reflection, I really like the following change that unifies
> > check_coords with CHECK_MAP_POS.
> >
> > Though we may want to rename the function check_map_pos(). It could
> > also be made a macro, if desired.
<snip...>
> Rewrite it and change the name. However note that I'm still not sure
> if this is the way to go. check_map_pos has a function call overhead
> we don't want. So the first step in all cases is the introduction of
> CHECK_MAP_POS. We can then argue how CHECK_MAP_POS should be
> implemented and if it should segv or not.
Unfortunately, the following macro
#define CHECK_MAP_POS(x, y) \
do { \
if (!is_normal_map_pos(*x, *y)) { \
assert(0); \
if (!normalize_map_pos(x, y)) { \
abort(); \
} \
} \
} while(0)
Does not seem like it will work inside map_inx:
#define map_inx(x,y) \
(CHECK_MAP_POS(&x, &y), (x)+(y)*map.xsize)
There is surely some cleverness that could be done to work around this.
Perhaps, though, the solution is to finally use an inline function? I
believe it can be placed in map.h and function just like the macro:
static inline void check_map_pos(int *x, int *y)
{
if (!is_normal_map_pos(*x, *y)) {
assert(0);
if (!normalize_map_pos(x, y)) {
abort();
}
}
}
jason
- [Freeciv-Dev] Remove map_adjust_[xy] invocations from server (PR#1003), jdorje, 2001/10/11
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#1003), Raimar Falke, 2001/10/12
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#1003), Thue, 2001/10/12
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#1003), Ross W. Wetmore, 2001/10/12
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations fromserver (PR#1003), Jason Dorje Short, 2001/10/12
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations fromserver (PR#1003), Ross W. Wetmore, 2001/10/15
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocationsfromserver (PR#1003), Jason Dorje Short, 2001/10/15
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations fromserver (PR#1003), Raimar Falke, 2001/10/15
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations fromserver (PR#1003), Ross W. Wetmore, 2001/10/15
- [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations fromserver (PR#1003), Raimar Falke, 2001/10/16
|
|