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,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2005 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002-2005 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* |
25 | /* |
26 | * The maptile is allocated each time a new map is opened. |
26 | * The maptile is allocated each time a new map is opened. |
… | |
… | |
157 | void update_ (); |
157 | void update_ (); |
158 | MTH void update () |
158 | MTH void update () |
159 | { |
159 | { |
160 | // we take advantage of the fact that 0x80 is the sign bit |
160 | // we take advantage of the fact that 0x80 is the sign bit |
161 | // to generate more efficient code on many cpus |
161 | // to generate more efficient code on many cpus |
162 | assert (sint8 (P_UPTODATE) < 0); |
162 | //assert (sint8 (P_UPTODATE) < 0); |
163 | assert (sint8 (-1 & ~P_UPTODATE) >= 0); |
163 | //assert (sint8 (-1 & ~P_UPTODATE) >= 0); |
164 | |
164 | |
165 | if (expect_false (sint8 (flags_) >= 0)) |
165 | if (expect_false (sint8 (flags_) >= 0)) |
166 | update_ (); |
166 | update_ (); |
167 | |
167 | |
168 | // must be true by now (gcc seems content with only the second test) |
168 | // must be true by now (gcc seems content with only the second test) |
169 | assume (sint8 (flags_) < 0); |
169 | ecb_assume (sint8 (flags_) < 0); |
170 | assume (flags_ & P_UPTODATE); |
170 | ecb_assume (flags_ & P_UPTODATE); |
171 | } |
171 | } |
172 | |
172 | |
173 | MTH uint8 flags () |
173 | MTH uint8 flags () |
174 | { |
174 | { |
175 | update (); |
175 | update (); |
… | |
… | |
204 | update (); |
204 | update (); |
205 | return items_; |
205 | return items_; |
206 | } |
206 | } |
207 | |
207 | |
208 | // return the item volume on this mapspace in cm³ |
208 | // return the item volume on this mapspace in cm³ |
209 | MTH uint64 volume () |
209 | MTH volume_t volume () |
210 | { |
210 | { |
211 | update (); |
211 | update (); |
212 | return volume_ * 1024; |
212 | return volume_ * 1024; |
213 | } |
213 | } |
214 | |
214 | |
… | |
… | |
249 | struct shopitems : zero_initialised |
249 | struct shopitems : zero_initialised |
250 | { |
250 | { |
251 | const char *name; /* name of the item in question, null if it is the default item */ |
251 | const char *name; /* name of the item in question, null if it is the default item */ |
252 | const char *name_pl; /* plural name */ |
252 | const char *name_pl; /* plural name */ |
253 | int typenum; /* itemtype number we need to match 0 if it is the default price */ |
253 | int typenum; /* itemtype number we need to match 0 if it is the default price */ |
254 | sint8 strength; /* the degree of specialisation the shop has in this item, |
254 | sint8 strength; /* the degree of specialisation the shop has in this item, |
255 | * as a percentage from -100 to 100 */ |
255 | * as a percentage from -100 to 100 */ |
256 | int index; /* being the size of the shopitems array. */ |
256 | int index; /* being the size of the shopitems array. */ |
257 | }; |
257 | }; |
258 | |
258 | |
259 | // map I/O, what to load/save |
259 | // map I/O, what to load/save |
… | |
… | |
261 | IO_HEADER = 0x01, // the "arch map" pseudo object |
261 | IO_HEADER = 0x01, // the "arch map" pseudo object |
262 | IO_OBJECTS = 0x02, // the non-unique objects |
262 | IO_OBJECTS = 0x02, // the non-unique objects |
263 | IO_UNIQUES = 0x04, // unique objects |
263 | IO_UNIQUES = 0x04, // unique objects |
264 | }; |
264 | }; |
265 | |
265 | |
266 | /* In general, code should always use the macros |
266 | /* In general, code should always use the macros |
267 | * above (or functions in map.c) to access many of the |
267 | * above (or functions in map.c) to access many of the |
268 | * values in the map structure. Failure to do this will |
268 | * values in the map structure. Failure to do this will |
269 | * almost certainly break various features. You may think |
269 | * almost certainly break various features. You may think |
270 | * it is safe to look at width and height values directly |
270 | * it is safe to look at width and height values directly |
271 | * (or even through the macros), but doing so will completely |
271 | * (or even through the macros), but doing so will completely |
272 | * break map tiling. |
272 | * break map tiling. |
… | |
… | |
280 | region_ptr *regionmap; /* index to region */ |
280 | region_ptr *regionmap; /* index to region */ |
281 | |
281 | |
282 | tstamp ACC (RW, last_access); /* last time this map was accessed somehow */ |
282 | tstamp ACC (RW, last_access); /* last time this map was accessed somehow */ |
283 | |
283 | |
284 | shstr ACC (RW, name); /* Name of map as given by its creator */ |
284 | shstr ACC (RW, name); /* Name of map as given by its creator */ |
285 | region_ptr ACC (RW, default_region); /* What jurisdiction in the game world this map is ruled by |
285 | region_ptr ACC (RW, default_region); /* What jurisdiction in the game world this map is ruled by |
286 | * points to the struct containing all the properties of |
286 | * points to the struct containing all the properties of |
287 | * the region */ |
287 | * the region */ |
288 | double ACC (RW, reset_time); |
288 | double ACC (RW, reset_time); |
289 | uint32 ACC (RW, reset_timeout); /* How many seconds must elapse before this map |
289 | uint32 ACC (RW, reset_timeout); /* How many seconds must elapse before this map |
290 | * should be reset |
290 | * should be reset |
291 | */ |
291 | */ |
… | |
… | |
320 | shstr ACC (RW, msg); /* Message map creator may have left */ |
320 | shstr ACC (RW, msg); /* Message map creator may have left */ |
321 | shstr ACC (RW, maplore); /* Map lore information */ |
321 | shstr ACC (RW, maplore); /* Map lore information */ |
322 | shstr ACC (RW, tile_path[TILE_NUM]); /* path to adjoining maps */ |
322 | shstr ACC (RW, tile_path[TILE_NUM]); /* path to adjoining maps */ |
323 | maptile *ACC (RW, tile_map[TILE_NUM]); /* Next map, linked list */ |
323 | maptile *ACC (RW, tile_map[TILE_NUM]); /* Next map, linked list */ |
324 | shstr ACC (RW, path); /* Filename of the map */ |
324 | shstr ACC (RW, path); /* Filename of the map */ |
325 | uint64 ACC (RW, max_volume); // maximum volume for all items on a mapspace |
325 | volume_t ACC (RW, max_volume); // maximum volume for all items on a mapspace |
326 | int ACC (RW, max_items); // maximum number of items on a mapspace |
326 | int ACC (RW, max_items); // maximum number of items on a mapspace |
327 | |
327 | |
328 | //-GPL |
328 | //-GPL |
329 | |
329 | |
330 | physics_queue pq[PHYSICS_QUEUES]; |
330 | physics_queue pq[PHYSICS_QUEUES]; |
… | |
… | |
527 | return *this; |
527 | return *this; |
528 | } |
528 | } |
529 | |
529 | |
530 | mapxy &move (int dir) |
530 | mapxy &move (int dir) |
531 | { |
531 | { |
532 | return move (freearr_x [dir], freearr_y [dir]); |
532 | return move (DIRX (dir), DIRY (dir)); |
533 | } |
533 | } |
534 | |
534 | |
535 | operator void *() const { return (void *)m; } |
535 | operator void *() const { return (void *)m; } |
536 | mapxy &operator =(const object *op) |
536 | mapxy &operator =(const object *op) |
537 | { |
537 | { |