ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/map.h
(Generate patch)

Comparing deliantra/server/include/map.h (file contents):
Revision 1.96 by root, Mon Jul 14 16:42:49 2008 UTC vs.
Revision 1.97 by root, Mon Aug 11 23:23:41 2008 UTC

83/* These are used in the MapLook flags element. They are not used in 83/* These are used in the MapLook flags element. They are not used in
84 * in the object flags structure. 84 * in the object flags structure.
85 */ 85 */
86#define P_BLOCKSVIEW 0x01 86#define P_BLOCKSVIEW 0x01
87#define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */ 87#define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */
88#define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */ 88//#define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */
89#define P_SAFE 0x08 /* If this is set the map tile is a safe space, 89#define P_SAFE 0x08 /* If this is set the map tile is a safe space,
90 * that means, nothing harmful can be done, 90 * that means, nothing harmful can be done,
91 * such as: bombs, potion usage, alchemy, spells 91 * such as: bombs, potion usage, alchemy, spells
92 * this was introduced to make shops safer 92 * this was introduced to make shops safer
93 * but is useful in other situations */ 93 * but is useful in other situations */
110 * particular space (was map, floor, floor2, map_ob), 110 * particular space (was map, floor, floor2, map_ob),
111 * have this structure take care of that information. 111 * have this structure take care of that information.
112 * This puts it all in one place, and should also make it easier 112 * This puts it all in one place, and should also make it easier
113 * to extend information about a space. 113 * to extend information about a space.
114 */ 114 */
115INTERFACE_CLASS (mapspace)
115struct mapspace 116struct mapspace
116{ 117{
118 object *ACC (RW, bot);
117 object *bot, *top; /* lowest/highest object on this space */ 119 object *ACC (RW, top); /* lowest/highest object on this space */
118 object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ 120 object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */
119 uint8 flags_; /* flags about this space (see the P_ values above) */ 121 uint8 flags_; /* flags about this space (see the P_ values above) */
120 sint8 light; /* How much light this space provides */ 122 sint8 ACC (RW, light); /* How much light this space provides */
121 MoveType move_block; /* What movement types this space blocks */ 123 MoveType ACC (RW, move_block); /* What movement types this space blocks */
122 MoveType move_slow; /* What movement types this space slows */ 124 MoveType ACC (RW, move_slow); /* What movement types this space slows */
123 MoveType move_on; /* What movement types are activated */ 125 MoveType ACC (RW, move_on); /* What movement types are activated */
124 MoveType move_off; /* What movement types are activated */ 126 MoveType ACC (RW, move_off); /* What movement types are activated */
125 127
126 void update_ (); 128 void update_ ();
127 void update () 129 MTH void update ()
128 { 130 {
129 if (!(flags_ & P_UPTODATE)) 131 if (!(flags_ & P_UPTODATE))
130 update_ (); 132 update_ ();
131 } 133 }
132 134
133 uint8 flags () 135 MTH uint8 flags ()
134 { 136 {
135 update (); 137 update ();
136 return flags_; 138 return flags_;
137 } 139 }
138 140
139 // maybe only inline quick flags_ checking?
140 object *player () 141 MTH object *player ()
141 { 142 {
142 // search from the top, because players are usually on top 143 // this assumes that players are always on top
143 // make usually == always and this non-amortized O(1) 144 return top && top->type == PLAYER ? top : 0;
144 // could gte rid of P_PLAYER, too, then
145 if (flags () & P_PLAYER)
146 for (object *op = top; op; op = op->below)
147 if (op->type == PLAYER)
148 return op;
149
150 return 0;
151 } 145 }
152 146
153 // return the item volume on this mapspace in cm³ 147 // return the item volume on this mapspace in cm³
154 uint64 volume () const; 148 MTH uint64 volume () const;
155 149
156 bool blocks (MoveType mt) const 150 bool blocks (MoveType mt) const
157 { 151 {
158 return move_block && (mt & move_block) == mt; 152 return move_block && (mt & move_block) == mt;
159 } 153 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines