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.29 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.32 by root, Mon Dec 25 11:25:49 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)
99 * really be used, as it is multi tile aware. However, there are some cases 99 * really be used, as it is multi tile aware. However, there are some cases
100 * where it is known the map is not tiled or the values are known 100 * where it is known the map is not tiled or the values are known
101 * consistent (eg, op->map, op->x, op->y) 101 * consistent (eg, op->map, op->x, op->y)
102 */ 102 */
103// all those macros are herewith declared legacy 103// all those macros are herewith declared legacy
104#define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags 104#define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags ()
105#define SET_MAP_FLAGS(M,X,Y,C) (M)->at((X),(Y)).flags = (C)
106#define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light 105#define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light
107#define SET_MAP_LIGHT(M,X,Y,L) (M)->at((X),(Y)).light = (L)
108#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bottom 106#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bottom
109#define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top 107#define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top
110#define SET_MAP_OB(M,X,Y,tmp) (M)->at((X),(Y)).bottom = (tmp)
111#define SET_MAP_TOP(M,X,Y,tmp) (M)->at((X),(Y)).top = (tmp)
112#define SET_MAP_FACE(M,X,Y,C,L) (M)->at((X),(Y)).faces[L] = (C)
113#define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L] 108#define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L]
114#define SET_MAP_FACE_OBJ(M,X,Y,C,L) (M)->at((X),(Y)).faces_obj[L] = (C)
115#define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] 109#define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L]
116#define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block 110#define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block
117#define SET_MAP_MOVE_BLOCK(M,X,Y,C) (M)->at((X),(Y)).move_block = (C)
118#define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow 111#define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow
119#define SET_MAP_MOVE_SLOW(M,X,Y,C) (M)->at((X),(Y)).move_slow = (C)
120#define GET_MAP_MOVE_ON(M,X,Y) (M)->at((X),(Y)).move_on 112#define GET_MAP_MOVE_ON(M,X,Y) (M)->at((X),(Y)).move_on
121#define SET_MAP_MOVE_ON(M,X,Y,C) (M)->at((X),(Y)).move_on = (C)
122#define GET_MAP_MOVE_OFF(M,X,Y) (M)->at((X),(Y)).move_off 113#define GET_MAP_MOVE_OFF(M,X,Y) (M)->at((X),(Y)).move_off
123#define SET_MAP_MOVE_OFF(M,X,Y,C) (M)->at((X),(Y)).move_off = (C)
124 114
125/* You should really know what you are doing before using this - you 115/* You should really know what you are doing before using this - you
126 * should almost always be using out_of_map instead, which takes into account 116 * should almost always be using out_of_map instead, which takes into account
127 * map tiling. 117 * map tiling.
128 */ 118 */
139 * such as: bombs, potion usage, alchemy, spells 129 * such as: bombs, potion usage, alchemy, spells
140 * this was introduced to make shops safer 130 * this was introduced to make shops safer
141 * but is useful in other situations */ 131 * but is useful in other situations */
142#define P_IS_ALIVE 0x10 /* something alive is on this space */ 132#define P_IS_ALIVE 0x10 /* something alive is on this space */
143#define P_NO_CLERIC 0x20 /* no clerical spells cast here */ 133#define P_NO_CLERIC 0x20 /* no clerical spells cast here */
134
144#define P_NEED_UPDATE 0x40 /* this space is out of date */ 135#define P_NEED_UPDATE 0x80 /* this space is out of date */
145#define P_NO_ERROR 0x80 /* Purely temporary - if set, update_position
146 * does not complain if the flags are different.
147 */
148 136
149/* The following two values are not stored in the MapLook flags, but instead 137/* The following two values are not stored in the MapLook flags, but instead
150 * used in the get_map_flags value - that function is used to return 138 * used in the get_map_flags value - that function is used to return
151 * the flag value, as well as other conditions - using a more general 139 * the flag value, as well as other conditions - using a more general
152 * function that does more of the work can hopefully be used to replace 140 * function that does more of the work can hopefully be used to replace
170struct mapspace 158struct mapspace
171{ 159{
172 object *bottom; /* lowest object on this space */ 160 object *bottom; /* lowest object on this space */
173 object *top; /* Highest object on this space */ 161 object *top; /* Highest object on this space */
174 New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ 162 New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */
175 object *faces_obj[MAP_LAYERS]; /* face objects for the 3 layers */ 163 object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */
176 uint8 flags; /* flags about this space (see the P_ values above) */ 164 uint8 flags_; /* flags about this space (see the P_ values above) */
177 sint8 light; /* How much light this space provides */ 165 sint8 light; /* How much light this space provides */
178 uint8 move_block; /* What movement types this space blocks */ 166 MoveType move_block; /* What movement types this space blocks */
179 uint8 move_slow; /* What movement types this space slows */ 167 MoveType move_slow; /* What movement types this space slows */
180 uint8 move_on; /* What movement types are activated */ 168 MoveType move_on; /* What movement types are activated */
181 uint8 move_off; /* What movement types are activated */ 169 MoveType move_off; /* What movement types are activated */
170
171 void update_ ();
172 void update ()
173 {
174 if (flags_ & P_NEED_UPDATE)
175 update_ ();
176 }
177
178 uint8 flags ()
179 {
180 update ();
181 return flags_;
182 }
183
184 // maybe only inline quick flags_ checking?
185 object *player ()
186 {
187 // search from the top, because players are usually on top
188 // make usually == always and this non-amortized O(1)
189 // could gte rid of P_PLAYER, too, then
190 if (flags () & P_PLAYER)
191 for (object *op = top; op; op = op->below)
192 if (op->type == PLAYER)
193 return op;
194
195 return 0;
196 }
182}; 197};
183 198
184/* 199/*
185 * this is an overlay structure of the whole world. It exists as a simple 200 * this is an overlay structure of the whole world. It exists as a simple
186 * high level map, which doesn't contain the full data of the underlying map. 201 * high level map, which doesn't contain the full data of the underlying map.
252 * almost certainly break various features. You may think 267 * almost certainly break various features. You may think
253 * it is safe to look at width and height values directly 268 * it is safe to look at width and height values directly
254 * (or even through the macros), but doing so will completely 269 * (or even through the macros), but doing so will completely
255 * break map tiling. 270 * break map tiling.
256 */ 271 */
257ACC_CLASS (maptile) 272INTERFACE_CLASS (maptile)
258struct maptile : zero_initialised, attachable<maptile> 273struct maptile : zero_initialised, attachable
259{ 274{
260 sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */ 275 sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */
261 struct mapspace *spaces; /* Array of spaces on this map */ 276 struct mapspace *spaces; /* Array of spaces on this map */
262 277
263 maptile *ACC (RW, next); /* Next map, linked list */ 278 maptile *ACC (RW, next); /* Next map, linked list */
306 char *tile_path[4]; /* path to adjoining maps */ 321 char *tile_path[4]; /* path to adjoining maps */
307 maptile *tile_map[4]; /* Next map, linked list */ 322 maptile *tile_map[4]; /* Next map, linked list */
308 char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */ 323 char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */
309 324
310 maptile (); 325 maptile ();
326 ~maptile ();
327 void do_destroy ();
328 void gather_callbacks (AV *&callbacks, event_type event) const;
329
311 void allocate (); 330 void allocate ();
312 331
313 mapspace const &at (uint32 x, uint32 y) const { return spaces [x + width * y]; } 332 mapspace const &at (uint32 x, uint32 y) const { return spaces [x + width * y]; }
314 mapspace &at (uint32 x, uint32 y) { return spaces [x + width * y]; } 333 mapspace &at (uint32 x, uint32 y) { return spaces [x + width * y]; }
315}; 334};
330 int distance_y; 349 int distance_y;
331 int direction; 350 int direction;
332 object *part; 351 object *part;
333}; 352};
334 353
354inline mapspace &
355object::ms () const
356{
357 return map->at (x, y);
358}
359
335#endif 360#endif
336 361

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines