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.92 by root, Sun May 4 14:12:37 2008 UTC vs.
Revision 1.98 by root, Sun Aug 17 22:46:26 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
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 object *op;
143 // make usually == always and this non-amortized O(1) 144
144 // could gte rid of P_PLAYER, too, then
145 if (flags () & P_PLAYER) 145 if (flags () & P_PLAYER)
146 for (object *op = top; op; op = op->below) 146 for (op = top; op->type != PLAYER; op = op->below)
147 if (op->type == PLAYER) 147 ;
148 return op; 148 else
149 op = 0;
149 150
150 return 0; 151 return op;
151 } 152 }
152 153
153 // return the item volume on this mapspace in cm³ 154 // return the item volume on this mapspace in cm³
154 uint64 volume () const; 155 MTH uint64 volume () const;
155 156
156 bool blocks (MoveType mt) const 157 bool blocks (MoveType mt) const
157 { 158 {
158 return move_block && (mt & move_block) == mt; 159 return move_block && (mt & move_block) == mt;
160 }
161
162 bool blocks (object *op) const
163 {
164 return blocks (op->move_type);
159 } 165 }
160}; 166};
161 167
162struct shopitems : zero_initialised 168struct shopitems : zero_initialised
163{ 169{
216 uint16 ACC (RW, difficulty); /* What level the player should be to play here */ 222 uint16 ACC (RW, difficulty); /* What level the player should be to play here */
217 223
218 bool ACC (RW, per_player); 224 bool ACC (RW, per_player);
219 bool ACC (RW, per_party); 225 bool ACC (RW, per_party);
220 bool ACC (RW, outdoor); /* True if an outdoor map */ 226 bool ACC (RW, outdoor); /* True if an outdoor map */
221 bool ACC (RW, nodrop); /* avoid dropping anything on this map */ 227 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 */ 228 uint8 ACC (RW, darkness); /* indicates level of darkness of map */
223 229
224 uint16 ACC (RW, enter_x); /* enter_x and enter_y are default entrance location */ 230 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 */ 231 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 */ 232 oblinkpt *buttons; /* Linked list of linked lists of buttons */
262 268
263 MTH void play_sound (faceidx sound, int x, int y) const; 269 MTH void play_sound (faceidx sound, int x, int y) const;
264 270
265 // set the given flag on all objects in the map 271 // set the given flag on all objects in the map
266 MTH void set_object_flag (int flag, int value = 1); 272 MTH void set_object_flag (int flag, int value = 1);
273 MTH void post_load_original ();
267 274
268 MTH void link_multipart_objects (); 275 MTH void link_multipart_objects ();
269 MTH void clear_unique_items (); 276 MTH void clear_unique_items ();
270 277
271 MTH void clear_header (); 278 MTH void clear_header ();
420 bool normalise () 427 bool normalise ()
421 { 428 {
422 return xy_normalise (m, x, y); 429 return xy_normalise (m, x, y);
423 } 430 }
424 431
432 mapspace &ms () const
433 {
434 return m->at (x, y);
435 }
436
425 object *insert (object *op, object *originator = 0, int flags = 0) const 437 object *insert (object *op, object *originator = 0, int flags = 0) const
426 { 438 {
427 m->insert (op, x, y, originator, flags); 439 return m->insert (op, x, y, originator, flags);
428 } 440 }
429}; 441};
430 442
431inline const mapxy & 443inline const mapxy &
432object::operator =(const mapxy &pos) 444object::operator =(const mapxy &pos)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines