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.91 by root, Tue Apr 15 14:21:04 2008 UTC vs.
Revision 1.102 by root, Tue Dec 23 06:58:23 2008 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002-2005,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002-2005,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
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{
216 uint16 ACC (RW, difficulty); /* What level the player should be to play here */ 226 uint16 ACC (RW, difficulty); /* What level the player should be to play here */
217 227
218 bool ACC (RW, per_player); 228 bool ACC (RW, per_player);
219 bool ACC (RW, per_party); 229 bool ACC (RW, per_party);
220 bool ACC (RW, outdoor); /* True if an outdoor map */ 230 bool ACC (RW, outdoor); /* True if an outdoor map */
221 bool ACC (RW, nodrop); /* avoid dropping anything on this map */ 231 bool ACC (RW, no_drop); /* avoid auto-dropping (on death) anything on this map */
222 uint8 ACC (RW, darkness); /* indicates level of darkness of map */ 232 sint8 ACC (RW, darkness); /* indicates level of darkness of map */
233 static sint8 outdoor_darkness; /* the global darkness level outside */
223 234
224 uint16 ACC (RW, enter_x); /* enter_x and enter_y are default entrance location */ 235 uint16 ACC (RW, enter_x); /* enter_x and enter_y are default entrance location */
225 uint16 ACC (RW, enter_y); /* on the map if none are set in the exit */ 236 uint16 ACC (RW, enter_y); /* on the map if none are set in the exit */
226 oblinkpt *buttons; /* Linked list of linked lists of buttons */ 237 oblinkpt *buttons; /* Linked list of linked lists of buttons */
227 sint16 ACC (RW, temp); /* base temperature of this tile (F) */ 238 sint16 ACC (RW, temp); /* base temperature of this tile (F) */
242 maptile *ACC (RW, tile_map[4]); /* Next map, linked list */ 253 maptile *ACC (RW, tile_map[4]); /* Next map, linked list */
243 shstr ACC (RW, path); /* Filename of the map */ 254 shstr ACC (RW, path); /* Filename of the map */
244 int ACC (RW, max_nrof); // maximum nrof of any single item on a mapspace 255 int ACC (RW, max_nrof); // maximum nrof of any single item on a mapspace
245 uint64 ACC (RW, max_volume); // maximum volume for all items on a mapspace 256 uint64 ACC (RW, max_volume); // maximum volume for all items on a mapspace
246 257
258 // the maptile:: is neccessary here for the perl interface to work
259 MTH sint8 darklevel (sint8 outside = maptile::outdoor_darkness) const
260 {
261 return clamp (outdoor ? darkness + outside : darkness, 0, MAX_DARKNESS);
262 }
263
264 static void adjust_daylight ();
265
247 MTH void activate (); 266 MTH void activate ();
248 MTH void deactivate (); 267 MTH void deactivate ();
249 268
250 // allocates all (empty) mapspace 269 // allocates all (empty) mapspace
251 MTH void alloc (); 270 MTH void alloc ();
254 273
255 MTH void fix_auto_apply (); 274 MTH void fix_auto_apply ();
256 MTH void do_decay_objects (); 275 MTH void do_decay_objects ();
257 MTH void update_buttons (); 276 MTH void update_buttons ();
258 MTH int change_map_light (int change); 277 MTH int change_map_light (int change);
259 static void change_all_map_light (int change); //PERL
260 MTH void set_darkness_map ();
261 MTH int estimate_difficulty () const; 278 MTH int estimate_difficulty () const;
262 279
263 MTH void play_sound (faceidx sound, int x, int y) const; 280 MTH void play_sound (faceidx sound, int x, int y) const;
264 281
265 // set the given flag on all objects in the map 282 // set the given flag on all objects in the map
266 MTH void set_object_flag (int flag, int value = 1); 283 MTH void set_object_flag (int flag, int value = 1);
284 MTH void post_load_original ();
267 285
268 MTH void link_multipart_objects (); 286 MTH void link_multipart_objects ();
269 MTH void clear_unique_items (); 287 MTH void clear_unique_items ();
270 288
271 MTH void clear_header (); 289 MTH void clear_header ();
325 bool generate_random_map (random_map_params *RP); 343 bool generate_random_map (random_map_params *RP);
326 344
327 static maptile *find_async (const char *path, maptile *original = 0, bool load = true);//PERL 345 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 346 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 347 static maptile *find_style_sync (const char *dir, const char *file = 0);//PERL
330 MTH object *pick_random_object () const; 348 object *pick_random_object (rand_gen &gen = rndm) const;
331 349
332 mapspace const &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } 350 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}; 351};
335 352
336/* This is used by get_rangevector to determine where the other 353/* This is used by get_rangevector to determine where the other
337 * creature is. get_rangevector takes into account map tiling, 354 * creature is. get_rangevector takes into account map tiling,
338 * so you just can not look the the map coordinates and get the 355 * so you just can not look the the map coordinates and get the
420 bool normalise () 437 bool normalise ()
421 { 438 {
422 return xy_normalise (m, x, y); 439 return xy_normalise (m, x, y);
423 } 440 }
424 441
442 mapspace &ms () const
443 {
444 return m->at (x, y);
445 }
446
425 object *insert (object *op, object *originator = 0, int flags = 0) const 447 object *insert (object *op, object *originator = 0, int flags = 0) const
426 { 448 {
427 m->insert (op, x, y, originator, flags); 449 return m->insert (op, x, y, originator, flags);
428 } 450 }
429}; 451};
430 452
431inline const mapxy & 453inline const mapxy &
432object::operator =(const mapxy &pos) 454object::operator =(const mapxy &pos)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines