--- deliantra/server/include/map.h 2007/01/13 23:06:13 1.51 +++ deliantra/server/include/map.h 2007/01/15 00:40:49 1.52 @@ -374,6 +374,26 @@ object *part; }; +//TODO: these should be refactored into things like xy_normalise +// and so on. +int get_map_flags(maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny); +int ob_blocked(const object *ob, maptile *m, sint16 x, sint16 y); +int out_of_map(maptile *m, int x, int y); +maptile *get_map_from_coord(maptile *m, sint16 *x, sint16 *y); +void get_rangevector(object *op1, object *op2, rv_vector *retval, int flags); +void get_rangevector_from_mapcoord(const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags); +int on_same_map(const object *op1, const object *op2); + +// adjust map, x and y for tiled maps and return true if the position is valid at all +inline bool +xy_normalise (maptile *&map, sint16 &x, sint16 &y) +{ + // when in range, do a quick return, otherwise go the slow route + return + (IN_RANGE_EXC (x, 0, map->width) && IN_RANGE_EXC (y, 0, map->height)) + || !(get_map_flags (map, &map, x, y, &x, &y) & P_OUT_OF_MAP); +} + inline mapspace & object::ms () const {