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.30 by root, Wed Dec 20 11:36:39 2006 UTC vs.
Revision 1.33 by root, Mon Dec 25 14:43:23 2006 UTC

42 * map pointers. 42 * map pointers.
43 */ 43 */
44#define MAGIC_MAP_SIZE 50 44#define MAGIC_MAP_SIZE 50
45#define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2 45#define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2
46 46
47#define MAP_LAYERS 4 47#define MAP_LAYERS 3
48 48
49/* This is when the map will reset */ 49/* This is when the map will reset */
50#define MAP_WHEN_RESET(m) ((m)->reset_time) 50#define MAP_WHEN_RESET(m) ((m)->reset_time)
51 51
52#define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout) 52#define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout)
58/* mape darkness used to enforce the MAX_DARKNESS value. 58/* mape darkness used to enforce the MAX_DARKNESS value.
59 * but IMO, if it is beyond max value, that should be fixed 59 * but IMO, if it is beyond max value, that should be fixed
60 * on the map or in the code. 60 * on the map or in the code.
61 */ 61 */
62#define MAP_DARKNESS(m) (m)->darkness 62#define MAP_DARKNESS(m) (m)->darkness
63
64#define MAP_WIDTH(m) (m)->width
65#define MAP_HEIGHT(m) (m)->height
66 63
67/* Convenient function - total number of spaces is used 64/* Convenient function - total number of spaces is used
68 * in many places. 65 * in many places.
69 */ 66 */
70#define MAP_SIZE(m) ((m)->width * (m)->height) 67#define MAP_SIZE(m) ((m)->width * (m)->height)
182 } 179 }
183 180
184 // maybe only inline quick flags_ checking? 181 // maybe only inline quick flags_ checking?
185 object *player () 182 object *player ()
186 { 183 {
184 // search from the top, because players are usually on top
185 // make usually == always and this non-amortized O(1)
186 // could gte rid of P_PLAYER, too, then
187 if (flags () & P_PLAYER) 187 if (flags () & P_PLAYER)
188 for (object *op = bottom; op; op = op->above) 188 for (object *op = top; op; op = op->below)
189 if (op->type == PLAYER) 189 if (op->type == PLAYER)
190 return op; 190 return op;
191 191
192 return 0; 192 return 0;
193 } 193 }
264 * almost certainly break various features. You may think 264 * almost certainly break various features. You may think
265 * it is safe to look at width and height values directly 265 * it is safe to look at width and height values directly
266 * (or even through the macros), but doing so will completely 266 * (or even through the macros), but doing so will completely
267 * break map tiling. 267 * break map tiling.
268 */ 268 */
269ACC_CLASS (maptile) 269INTERFACE_CLASS (maptile)
270struct maptile : zero_initialised, attachable<maptile> 270struct maptile : zero_initialised, attachable
271{ 271{
272 sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */ 272 sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */
273 struct mapspace *spaces; /* Array of spaces on this map */ 273 struct mapspace *spaces; /* Array of spaces on this map */
274 274
275 maptile *ACC (RW, next); /* Next map, linked list */ 275 maptile *ACC (RW, next); /* Next map, linked list */
318 char *tile_path[4]; /* path to adjoining maps */ 318 char *tile_path[4]; /* path to adjoining maps */
319 maptile *tile_map[4]; /* Next map, linked list */ 319 maptile *tile_map[4]; /* Next map, linked list */
320 char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */ 320 char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */
321 321
322 maptile (); 322 maptile ();
323 ~maptile ();
324 void do_destroy ();
325 void gather_callbacks (AV *&callbacks, event_type event) const;
326
323 void allocate (); 327 void allocate ();
324 328
325 mapspace const &at (uint32 x, uint32 y) const { return spaces [x + width * y]; } 329 mapspace const &at (uint32 x, uint32 y) const { return spaces [x + width * y]; }
326 mapspace &at (uint32 x, uint32 y) { return spaces [x + width * y]; } 330 mapspace &at (uint32 x, uint32 y) { return spaces [x + width * y]; }
327}; 331};
342 int distance_y; 346 int distance_y;
343 int direction; 347 int direction;
344 object *part; 348 object *part;
345}; 349};
346 350
351inline mapspace &
352object::ms () const
353{
354 return map->at (x, y);
355}
356
347#endif 357#endif
348 358

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines