… | |
… | |
83 | /* These are used in the MapLook flags element. They are not used in |
83 | /* These are used in the MapLook flags element. They are not used in |
84 | * in the object flags structure. |
84 | * in the object flags structure. |
85 | */ |
85 | */ |
86 | #define P_BLOCKSVIEW 0x01 |
86 | #define P_BLOCKSVIEW 0x01 |
87 | #define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */ |
87 | #define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */ |
88 | #define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */ |
88 | //#define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */ |
89 | #define P_SAFE 0x08 /* If this is set the map tile is a safe space, |
89 | #define P_SAFE 0x08 /* If this is set the map tile is a safe space, |
90 | * that means, nothing harmful can be done, |
90 | * that means, nothing harmful can be done, |
91 | * such as: bombs, potion usage, alchemy, spells |
91 | * such as: bombs, potion usage, alchemy, spells |
92 | * this was introduced to make shops safer |
92 | * this was introduced to make shops safer |
93 | * but is useful in other situations */ |
93 | * but is useful in other situations */ |
… | |
… | |
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 | */ |
|
|
115 | INTERFACE_CLASS (mapspace) |
115 | struct mapspace |
116 | struct 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 | // this assumes that players are always on top |
143 | // make usually == always and this non-amortized O(1) |
144 | return top && top->type == PLAYER ? top : 0; |
144 | // could gte rid of P_PLAYER, too, then |
|
|
145 | if (flags () & P_PLAYER) |
|
|
146 | for (object *op = top; op; op = op->below) |
|
|
147 | if (op->type == PLAYER) |
|
|
148 | return op; |
|
|
149 | |
|
|
150 | return 0; |
|
|
151 | } |
145 | } |
152 | |
146 | |
153 | // return the item volume on this mapspace in cm³ |
147 | // return the item volume on this mapspace in cm³ |
154 | uint64 volume () const; |
148 | MTH uint64 volume () const; |
155 | |
149 | |
156 | bool blocks (MoveType mt) const |
150 | bool blocks (MoveType mt) const |
157 | { |
151 | { |
158 | return move_block && (mt & move_block) == mt; |
152 | return move_block && (mt & move_block) == mt; |
|
|
153 | } |
|
|
154 | |
|
|
155 | bool blocks (object *op) const |
|
|
156 | { |
|
|
157 | return blocks (op->move_type); |
159 | } |
158 | } |
160 | }; |
159 | }; |
161 | |
160 | |
162 | struct shopitems : zero_initialised |
161 | struct shopitems : zero_initialised |
163 | { |
162 | { |
… | |
… | |
216 | uint16 ACC (RW, difficulty); /* What level the player should be to play here */ |
215 | uint16 ACC (RW, difficulty); /* What level the player should be to play here */ |
217 | |
216 | |
218 | bool ACC (RW, per_player); |
217 | bool ACC (RW, per_player); |
219 | bool ACC (RW, per_party); |
218 | bool ACC (RW, per_party); |
220 | bool ACC (RW, outdoor); /* True if an outdoor map */ |
219 | bool ACC (RW, outdoor); /* True if an outdoor map */ |
221 | bool ACC (RW, nodrop); /* avoid dropping anything on this map */ |
220 | 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 */ |
221 | uint8 ACC (RW, darkness); /* indicates level of darkness of map */ |
223 | |
222 | |
224 | uint16 ACC (RW, enter_x); /* enter_x and enter_y are default entrance location */ |
223 | 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 */ |
224 | 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 */ |
225 | oblinkpt *buttons; /* Linked list of linked lists of buttons */ |
… | |
… | |
262 | |
261 | |
263 | MTH void play_sound (faceidx sound, int x, int y) const; |
262 | MTH void play_sound (faceidx sound, int x, int y) const; |
264 | |
263 | |
265 | // set the given flag on all objects in the map |
264 | // set the given flag on all objects in the map |
266 | MTH void set_object_flag (int flag, int value = 1); |
265 | MTH void set_object_flag (int flag, int value = 1); |
|
|
266 | MTH void post_load_original (); |
267 | |
267 | |
268 | MTH void link_multipart_objects (); |
268 | MTH void link_multipart_objects (); |
269 | MTH void clear_unique_items (); |
269 | MTH void clear_unique_items (); |
270 | |
270 | |
271 | MTH void clear_header (); |
271 | MTH void clear_header (); |
… | |
… | |
420 | bool normalise () |
420 | bool normalise () |
421 | { |
421 | { |
422 | return xy_normalise (m, x, y); |
422 | return xy_normalise (m, x, y); |
423 | } |
423 | } |
424 | |
424 | |
|
|
425 | mapspace &ms () const |
|
|
426 | { |
|
|
427 | return m->at (x, y); |
|
|
428 | } |
|
|
429 | |
425 | object *insert (object *op, object *originator = 0, int flags = 0) const |
430 | object *insert (object *op, object *originator = 0, int flags = 0) const |
426 | { |
431 | { |
427 | m->insert (op, x, y, originator, flags); |
432 | return m->insert (op, x, y, originator, flags); |
428 | } |
433 | } |
429 | }; |
434 | }; |
430 | |
435 | |
431 | inline const mapxy & |
436 | inline const mapxy & |
432 | object::operator =(const mapxy &pos) |
437 | object::operator =(const mapxy &pos) |