[Freeciv-Dev] (PR#9466) check direction in mapstep
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9466 >
For hex maps MAPSTEP needs to verify that the direction is valid. This
patch calls is_valid_dir to do that.
This slows down MAPSTEP significantly since is_valid_dir is an extra
function call (it could easily be made inline/macro, but I doubt it's
worth it). But MAPSTEP isn't used very often so this shouldn't have a
measurable effect on runtime.
This is the last cleanup necessary for hex-maps.
jason
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.198
diff -u -r1.198 map.h
--- common/map.h 21 Jul 2004 14:46:59 -0000 1.198
+++ common/map.h 21 Jul 2004 14:56:03 -0000
@@ -329,9 +329,10 @@
* we bend this rule here.
*/
#define MAPSTEP(dest_x, dest_y, src_x, src_y, dir) \
-( (dest_x) = (src_x) + DIR_DX[(dir)], \
- (dest_y) = (src_y) + DIR_DY[(dir)], \
- normalize_map_pos(&(dest_x), &(dest_y)))
+ (is_valid_dir(dir) \
+ && ((dest_x) = (src_x) + DIR_DX[(dir)], \
+ (dest_y) = (src_y) + DIR_DY[(dir)], \
+ normalize_map_pos(&(dest_x), &(dest_y))))
struct player *map_get_owner(int x, int y);
void map_set_owner(int x, int y, struct player *pplayer);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9466) check direction in mapstep,
Jason Short <=
|
|