--- deliantra/server/include/map.h 2007/08/27 06:29:17 1.85 +++ deliantra/server/include/map.h 2007/09/30 20:22:18 1.89 @@ -105,11 +105,6 @@ #define P_NEW_MAP 0x20000 /* Coordinates passed result in a new tiled map */ -/* P_NO_PASS is used for ob_blocked() return value. It needs - * to be here to make sure the bits don't match with anything. - */ -#define P_NO_PASS 0x80000 - /* Instead of having numerous arrays that have information on a * particular space (was map, floor, floor2, map_ob), * have this structure take care of that information. @@ -156,6 +151,11 @@ // return the item volume on this mapspace in cm³ uint64 volume () const; + + bool blocks (MoveType mt) const + { + return move_block && (mt & move_block) == mt; + } }; struct shopitems : zero_initialised @@ -272,13 +272,13 @@ MTH struct region *region (int x, int y) const; - // loas the header pseudo-object + // load the header pseudo-object bool _load_header (object_thawer &thawer); - MTH bool _load_header (const char *path); + MTH bool _load_header (object_thawer *thawer) { return _load_header (*thawer); } // load objects into the map bool _load_objects (object_thawer &thawer); - MTH bool _load_objects (const char *path, bool skip_header = true); + MTH bool _load_objects (object_thawer *thawer) { return _load_objects (*thawer); } // save objects into the given file (uses IO_ flags) bool _save_objects (object_freezer &freezer, int flags); @@ -350,10 +350,10 @@ object *part; }; +// comaptibility cruft start //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); @@ -362,7 +362,7 @@ int adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy); // adjust map, x and y for tiled maps and return true if the position is valid at all -inline bool +static inline bool xy_normalise (maptile *&map, sint16 &x, sint16 &y) { // when in range, do a quick return, otherwise go the slow route @@ -370,6 +370,7 @@ (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); } +// comaptibility cruft end inline mapspace & object::ms () const @@ -377,7 +378,6 @@ return map->at (x, y); } -// not used anywhere *yet* struct mapxy { maptile *m; sint16 x, y; @@ -390,14 +390,19 @@ : m(op->map), x(op->x), y(op->y) { } - mapxy &move (int dir) + mapxy &move (int dx, int dy) { - x += freearr_x [dir]; - y += freearr_y [dir]; + x += dx; + y += dy; return *this; } + mapxy &move (int dir) + { + return move (freearr_x [dir], freearr_y [dir]); + } + operator void *() const { return (void *)m; } mapxy &operator =(const object *op) { @@ -409,12 +414,17 @@ } mapspace *operator ->() const { return &m->at (x, y); } - mapspace *operator * () const { return &m->at (x, y); } + mapspace &operator * () const { return m->at (x, y); } bool normalise () { return xy_normalise (m, x, y); } + + object *insert (object *op, object *originator = 0, int flags = 0) const + { + m->insert (op, x, y, originator, flags); + } }; inline const mapxy &