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.94 by root, Wed May 7 11:02:50 2008 UTC vs.
Revision 1.100 by root, Tue Dec 23 00:39:48 2008 UTC

63 * where it is known the map is not tiled or the values are known 63 * where it is known the map is not tiled or the values are known
64 * consistent (eg, op->map, op->x, op->y) 64 * consistent (eg, op->map, op->x, op->y)
65 */ 65 */
66// all those macros are herewith declared legacy 66// all those macros are herewith declared legacy
67#define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags () 67#define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags ()
68#define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light
69#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bot 68#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bot
70#define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top 69#define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top
71#define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] 70#define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L]
72#define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block 71#define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block
73#define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow 72#define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow
110 * particular space (was map, floor, floor2, map_ob), 109 * particular space (was map, floor, floor2, map_ob),
111 * have this structure take care of that information. 110 * have this structure take care of that information.
112 * This puts it all in one place, and should also make it easier 111 * This puts it all in one place, and should also make it easier
113 * to extend information about a space. 112 * to extend information about a space.
114 */ 113 */
114INTERFACE_CLASS (mapspace)
115struct mapspace 115struct mapspace
116{ 116{
117 object *ACC (RW, bot);
117 object *bot, *top; /* lowest/highest object on this space */ 118 object *ACC (RW, top); /* lowest/highest object on this space */
118 object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ 119 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) */ 120 uint8 flags_; /* flags about this space (see the P_ values above) */
120 sint8 light; /* How much light this space provides */ 121 sint8 ACC (RW, light); /* How much light this space provides */
121 MoveType move_block; /* What movement types this space blocks */ 122 MoveType ACC (RW, move_block); /* What movement types this space blocks */
122 MoveType move_slow; /* What movement types this space slows */ 123 MoveType ACC (RW, move_slow); /* What movement types this space slows */
123 MoveType move_on; /* What movement types are activated */ 124 MoveType ACC (RW, move_on); /* What movement types are activated */
124 MoveType move_off; /* What movement types are activated */ 125 MoveType ACC (RW, move_off); /* What movement types are activated */
125 126
126 void update_ (); 127 void update_ ();
127 void update () 128 MTH void update ()
128 { 129 {
129 if (!(flags_ & P_UPTODATE)) 130 if (!(flags_ & P_UPTODATE))
130 update_ (); 131 update_ ();
131 } 132 }
132 133
133 uint8 flags () 134 MTH uint8 flags ()
134 { 135 {
135 update (); 136 update ();
136 return flags_; 137 return flags_;
137 } 138 }
139
140 MTH void invalidate ()
141 {
142 flags_ = 0;
143 }
138 144
139 // maybe only inline quick flags_ checking?
140 object *player () 145 MTH object *player ()
141 { 146 {
142 // search from the top, because players are usually on top 147 object *op;
143 // make usually == always and this non-amortized O(1) 148
144 // could gte rid of P_PLAYER, too, then
145 if (flags () & P_PLAYER) 149 if (flags () & P_PLAYER)
146 for (object *op = top; op; op = op->below) 150 for (op = top; op->type != PLAYER; op = op->below)
147 if (op->type == PLAYER) 151 ;
148 return op; 152 else
153 op = 0;
149 154
150 return 0; 155 return op;
151 } 156 }
152 157
153 // return the item volume on this mapspace in cm³ 158 // return the item volume on this mapspace in cm³
154 uint64 volume () const; 159 MTH uint64 volume () const;
155 160
156 bool blocks (MoveType mt) const 161 bool blocks (MoveType mt) const
157 { 162 {
158 return move_block && (mt & move_block) == mt; 163 return move_block && (mt & move_block) == mt;
164 }
165
166 bool blocks (object *op) const
167 {
168 return blocks (op->move_type);
159 } 169 }
160}; 170};
161 171
162struct shopitems : zero_initialised 172struct shopitems : zero_initialised
163{ 173{
262 272
263 MTH void play_sound (faceidx sound, int x, int y) const; 273 MTH void play_sound (faceidx sound, int x, int y) const;
264 274
265 // set the given flag on all objects in the map 275 // set the given flag on all objects in the map
266 MTH void set_object_flag (int flag, int value = 1); 276 MTH void set_object_flag (int flag, int value = 1);
277 MTH void post_load_original ();
267 278
268 MTH void link_multipart_objects (); 279 MTH void link_multipart_objects ();
269 MTH void clear_unique_items (); 280 MTH void clear_unique_items ();
270 281
271 MTH void clear_header (); 282 MTH void clear_header ();
327 static maptile *find_async (const char *path, maptile *original = 0, bool load = true);//PERL 338 static maptile *find_async (const char *path, maptile *original = 0, bool load = true);//PERL
328 static maptile *find_sync (const char *path, maptile *original = 0);//PERL 339 static maptile *find_sync (const char *path, maptile *original = 0);//PERL
329 static maptile *find_style_sync (const char *dir, const char *file = 0);//PERL 340 static maptile *find_style_sync (const char *dir, const char *file = 0);//PERL
330 object *pick_random_object (rand_gen &gen = rndm) const; 341 object *pick_random_object (rand_gen &gen = rndm) const;
331 342
332 mapspace const &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } 343 mapspace &at (uint32 x, uint32 y) const { return spaces [x * height + y]; }
333 mapspace &at (uint32 x, uint32 y) { return spaces [x * height + y]; }
334}; 344};
335 345
336/* This is used by get_rangevector to determine where the other 346/* This is used by get_rangevector to determine where the other
337 * creature is. get_rangevector takes into account map tiling, 347 * creature is. get_rangevector takes into account map tiling,
338 * so you just can not look the the map coordinates and get the 348 * so you just can not look the the map coordinates and get the
420 bool normalise () 430 bool normalise ()
421 { 431 {
422 return xy_normalise (m, x, y); 432 return xy_normalise (m, x, y);
423 } 433 }
424 434
435 mapspace &ms () const
436 {
437 return m->at (x, y);
438 }
439
425 object *insert (object *op, object *originator = 0, int flags = 0) const 440 object *insert (object *op, object *originator = 0, int flags = 0) const
426 { 441 {
427 m->insert (op, x, y, originator, flags); 442 return m->insert (op, x, y, originator, flags);
428 } 443 }
429}; 444};
430 445
431inline const mapxy & 446inline const mapxy &
432object::operator =(const mapxy &pos) 447object::operator =(const mapxy &pos)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines