--- deliantra/server/include/map.h 2007/08/01 01:53:13 1.81 +++ deliantra/server/include/map.h 2007/09/04 05:43:21 1.87 @@ -214,7 +214,6 @@ sint16 players; /* How many players are on this map right now */ uint16 ACC (RW, difficulty); /* What level the player should be to play here */ - bool ACC (RW, active); // wether this map is active or not bool ACC (RW, per_player); bool ACC (RW, per_party); bool ACC (RW, outdoor); /* True if an outdoor map */ @@ -273,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); @@ -302,6 +301,8 @@ MTH void touch () { last_access = runtime; } + MTH bool tile_available (int dir, bool load = true); + // find the map that is at coordinate x|y relative to this map // TODO: need a better way than passing by reference // TODO: make perl interface @@ -322,7 +323,7 @@ void make_map_floor (char **layout, char *floorstyle, random_map_params *RP); bool generate_random_map (random_map_params *RP); - static maptile *find_async (const char *path, maptile *original = 0);//PERL + static maptile *find_async (const char *path, maptile *original = 0, bool load = true);//PERL static maptile *find_sync (const char *path, maptile *original = 0);//PERL static maptile *find_style_sync (const char *dir, const char *file = 0);//PERL MTH object *pick_random_object () const; @@ -376,11 +377,59 @@ return map->at (x, y); } -inline void -object::play_sound (faceidx sound) const +// not used anywhere *yet* +struct mapxy { + maptile *m; + sint16 x, y; + + mapxy (maptile *m, sint16 x, sint16 y) + : m(m), x(x), y(y) + { } + + mapxy (object *op) + : m(op->map), x(op->x), y(op->y) + { } + + mapxy &move (int dir) + { + x += freearr_x [dir]; + y += freearr_y [dir]; + + return *this; + } + + operator void *() const { return (void *)m; } + mapxy &operator =(const object *op) + { + m = op->map; + x = op->x; + y = op->y; + + return *this; + } + + 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 & +object::operator =(const mapxy &pos) { - if (map && sound) - map->play_sound (sound, x, y); + map = pos.m; + x = pos.x; + y = pos.y; + + return pos; } #endif