--- deliantra/server/include/map.h 2008/05/06 16:55:26 1.93 +++ deliantra/server/include/map.h 2008/08/11 23:23:41 1.97 @@ -85,7 +85,7 @@ */ #define P_BLOCKSVIEW 0x01 #define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */ -#define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */ +//#define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */ #define P_SAFE 0x08 /* If this is set the map tile is a safe space, * that means, nothing harmful can be done, * such as: bombs, potion usage, alchemy, spells @@ -112,51 +112,50 @@ * This puts it all in one place, and should also make it easier * to extend information about a space. */ +INTERFACE_CLASS (mapspace) struct mapspace { - object *bot, *top; /* lowest/highest object on this space */ - object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ + object *ACC (RW, bot); + object *ACC (RW, top); /* lowest/highest object on this space */ + object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */ uint8 flags_; /* flags about this space (see the P_ values above) */ - sint8 light; /* How much light this space provides */ - MoveType move_block; /* What movement types this space blocks */ - MoveType move_slow; /* What movement types this space slows */ - MoveType move_on; /* What movement types are activated */ - MoveType move_off; /* What movement types are activated */ + sint8 ACC (RW, light); /* How much light this space provides */ + MoveType ACC (RW, move_block); /* What movement types this space blocks */ + MoveType ACC (RW, move_slow); /* What movement types this space slows */ + MoveType ACC (RW, move_on); /* What movement types are activated */ + MoveType ACC (RW, move_off); /* What movement types are activated */ void update_ (); - void update () + MTH void update () { if (!(flags_ & P_UPTODATE)) update_ (); } - uint8 flags () + MTH uint8 flags () { update (); return flags_; } - // maybe only inline quick flags_ checking? - object *player () + MTH object *player () { - // search from the top, because players are usually on top - // make usually == always and this non-amortized O(1) - // could gte rid of P_PLAYER, too, then - if (flags () & P_PLAYER) - for (object *op = top; op; op = op->below) - if (op->type == PLAYER) - return op; - - return 0; + // this assumes that players are always on top + return top && top->type == PLAYER ? top : 0; } // return the item volume on this mapspace in cm³ - uint64 volume () const; + MTH uint64 volume () const; bool blocks (MoveType mt) const { return move_block && (mt & move_block) == mt; } + + bool blocks (object *op) const + { + return blocks (op->move_type); + } }; struct shopitems : zero_initialised @@ -218,7 +217,7 @@ bool ACC (RW, per_player); bool ACC (RW, per_party); bool ACC (RW, outdoor); /* True if an outdoor map */ - bool ACC (RW, nodrop); /* avoid dropping anything on this map */ + bool ACC (RW, no_drop); /* avoid auto-dropping (on death) anything on this map */ uint8 ACC (RW, darkness); /* indicates level of darkness of map */ uint16 ACC (RW, enter_x); /* enter_x and enter_y are default entrance location */ @@ -264,6 +263,7 @@ // set the given flag on all objects in the map MTH void set_object_flag (int flag, int value = 1); + MTH void post_load_original (); MTH void link_multipart_objects (); MTH void clear_unique_items (); @@ -422,9 +422,14 @@ return xy_normalise (m, x, y); } + mapspace &ms () const + { + return m->at (x, y); + } + object *insert (object *op, object *originator = 0, int flags = 0) const { - m->insert (op, x, y, originator, flags); + return m->insert (op, x, y, originator, flags); } };