… | |
… | |
93 | /* These are used in the MapLook flags element. They are not used in |
93 | /* These are used in the MapLook flags element. They are not used in |
94 | * in the object flags structure. |
94 | * in the object flags structure. |
95 | */ |
95 | */ |
96 | #define P_BLOCKSVIEW 0x01 |
96 | #define P_BLOCKSVIEW 0x01 |
97 | #define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */ |
97 | #define P_NO_MAGIC 0x02 /* Spells (some) can't pass this object */ |
98 | #define P_PLAYER 0x04 /* a player (or something seeing these objects) is on this mapspace */ |
98 | #define P_NO_CLERIC 0x04 /* no clerical spells cast here */ |
99 | #define P_SAFE 0x08 /* If this is set the map tile is a safe space, |
99 | #define P_SAFE 0x08 /* If this is set the map tile is a safe space, |
100 | * that means, nothing harmful can be done, |
100 | * that means, nothing harmful can be done, |
101 | * such as: bombs, potion usage, alchemy, spells |
101 | * such as: bombs, potion usage, alchemy, spells |
102 | * this was introduced to make shops safer |
102 | * this was introduced to make shops safer |
103 | * but is useful in other situations */ |
103 | * but is useful in other situations */ |
|
|
104 | |
|
|
105 | #define P_PLAYER 0x10 /* a player (or something seeing these objects) is on this mapspace */ |
104 | #define P_IS_ALIVE 0x10 /* something alive is on this space */ |
106 | #define P_IS_ALIVE 0x20 /* something alive is on this space */ |
105 | #define P_NO_CLERIC 0x20 /* no clerical spells cast here */ |
|
|
106 | |
|
|
107 | #define P_UPTODATE 0x80 /* this space is up to date */ |
107 | #define P_UPTODATE 0x80 // this space is up to date |
108 | |
108 | |
109 | /* The following two values are not stored in the MapLook flags, but instead |
109 | /* The following two values are not stored in the MapLook flags, but instead |
110 | * used in the get_map_flags value - that function is used to return |
110 | * used in the get_map_flags value - that function is used to return |
111 | * the flag value, as well as other conditions - using a more general |
111 | * the flag value, as well as other conditions - using a more general |
112 | * function that does more of the work can hopefully be used to replace |
112 | * function that does more of the work can hopefully be used to replace |
… | |
… | |
123 | */ |
123 | */ |
124 | INTERFACE_CLASS (mapspace) |
124 | INTERFACE_CLASS (mapspace) |
125 | struct mapspace |
125 | struct mapspace |
126 | { |
126 | { |
127 | object *ACC (RW, bot); |
127 | object *ACC (RW, bot); |
128 | object *ACC (RW, top); /* lowest/highest object on this space */ |
128 | object *ACC (RW, top); /* lowest/highest object on this space */ |
129 | object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */ |
129 | object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */ |
130 | uint32_t smell; // the last count a player was seen here, or 0 |
|
|
131 | static uint32_t smellcount; // global smell counter |
|
|
132 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
130 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
133 | sint8 ACC (RW, light); /* How much light this space provides */ |
131 | sint8 ACC (RW, light); /* How much light this space provides */ |
134 | MoveType ACC (RW, move_block); /* What movement types this space blocks */ |
132 | MoveType ACC (RW, move_block); /* What movement types this space blocks */ |
135 | MoveType ACC (RW, move_slow); /* What movement types this space slows */ |
133 | MoveType ACC (RW, move_slow); /* What movement types this space slows */ |
136 | MoveType ACC (RW, move_on); /* What movement types are activated */ |
134 | MoveType ACC (RW, move_on); /* What movement types are activated */ |
137 | MoveType ACC (RW, move_off); /* What movement types are activated */ |
135 | MoveType ACC (RW, move_off); /* What movement types are activated */ |
|
|
136 | uint16_t ACC (RW, nrof_); // saturates at 64k |
|
|
137 | uint32_t ACC (RW, volume_); // ~dm³ (not cm³) (factor is actually 1024) |
|
|
138 | uint32_t ACC (RW, smell); // the last count a player was seen here, or 0 |
|
|
139 | static uint32_t ACC (RW, smellcount); // global smell counter |
|
|
140 | |
|
|
141 | uint32_t pad1_, pad2_; // pad to 64 bytes on 64 bit systems |
138 | |
142 | |
139 | //-GPL |
143 | //-GPL |
140 | |
144 | |
141 | void update_ (); |
145 | void update_ (); |
142 | MTH void update () |
146 | MTH void update () |
143 | { |
147 | { |
144 | if (expect_false (!(flags_ & P_UPTODATE))) |
148 | // we take advantage of the fact that 0x80 is the sign bit |
|
|
149 | // to generate more efficient code on many cpus |
|
|
150 | assert (P_UPTODATE == 0x80); |
|
|
151 | |
|
|
152 | if (expect_false (sint8 (flags_) < 0)) |
145 | update_ (); |
153 | update_ (); |
|
|
154 | |
|
|
155 | // must be true by now |
|
|
156 | assume (sint8 (flags_) < 0); |
|
|
157 | assume (flags_ & P_UPTODATE); |
146 | } |
158 | } |
147 | |
159 | |
148 | MTH uint8 flags () |
160 | MTH uint8 flags () |
149 | { |
161 | { |
150 | update (); |
162 | update (); |
… | |
… | |
167 | op = 0; |
179 | op = 0; |
168 | |
180 | |
169 | return op; |
181 | return op; |
170 | } |
182 | } |
171 | |
183 | |
|
|
184 | MTH uint32 nrof () |
|
|
185 | { |
|
|
186 | update (); |
|
|
187 | return nrof_; |
|
|
188 | } |
|
|
189 | |
172 | // return the item volume on this mapspace in cm³ |
190 | // return the item volume on this mapspace in cm³ |
173 | MTH uint64 volume () const; |
191 | MTH uint64 volume () |
|
|
192 | { |
|
|
193 | update (); |
|
|
194 | return volume_ * 1024; |
|
|
195 | } |
174 | |
196 | |
175 | bool blocks (MoveType mt) const |
197 | bool blocks (MoveType mt) const |
176 | { |
198 | { |
177 | return move_block && (mt & move_block) == mt; |
199 | return move_block && (mt & move_block) == mt; |
178 | } |
200 | } |
… | |
… | |
277 | shstr ACC (RW, tile_path[4]); /* path to adjoining maps */ |
299 | shstr ACC (RW, tile_path[4]); /* path to adjoining maps */ |
278 | maptile *ACC (RW, tile_map[4]); /* Next map, linked list */ |
300 | maptile *ACC (RW, tile_map[4]); /* Next map, linked list */ |
279 | shstr ACC (RW, path); /* Filename of the map */ |
301 | shstr ACC (RW, path); /* Filename of the map */ |
280 | int ACC (RW, max_nrof); // maximum nrof of any single item on a mapspace |
302 | int ACC (RW, max_nrof); // maximum nrof of any single item on a mapspace |
281 | uint64 ACC (RW, max_volume); // maximum volume for all items on a mapspace |
303 | uint64 ACC (RW, max_volume); // maximum volume for all items on a mapspace |
|
|
304 | int ACC (RW, max_items); // maximum number of items on a mapspace |
282 | |
305 | |
283 | //-GPL |
306 | //-GPL |
284 | |
307 | |
285 | // the maptile:: is neccessary here for the perl interface to work |
308 | // the maptile:: is neccessary here for the perl interface to work |
286 | MTH sint8 darklevel (sint8 outside = maptile::outdoor_darkness) const |
309 | MTH sint8 darklevel (sint8 outside = maptile::outdoor_darkness) const |