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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * 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 |
6 | * Copyright (©) 2002-2005 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * 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 |
10 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
157 | void update_ (); |
158 | void update_ (); |
158 | MTH void update () |
159 | MTH void update () |
159 | { |
160 | { |
160 | // we take advantage of the fact that 0x80 is the sign bit |
161 | // we take advantage of the fact that 0x80 is the sign bit |
161 | // to generate more efficient code on many cpus |
162 | // to generate more efficient code on many cpus |
162 | assert (sint8 (P_UPTODATE) < 0); |
163 | //assert (sint8 (P_UPTODATE) < 0); |
163 | assert (sint8 (-1 & ~P_UPTODATE) >= 0); |
164 | //assert (sint8 (-1 & ~P_UPTODATE) >= 0); |
164 | |
165 | |
165 | if (expect_false (sint8 (flags_) >= 0)) |
166 | if (ecb_expect_false (sint8 (flags_) >= 0)) |
166 | update_ (); |
167 | update_ (); |
167 | |
168 | |
168 | // must be true by now (gcc seems content with only the second test) |
169 | // must be true by now (gcc seems content with only the second test) |
169 | assume (sint8 (flags_) < 0); |
170 | ecb_assume (sint8 (flags_) < 0); |
170 | assume (flags_ & P_UPTODATE); |
171 | ecb_assume (flags_ & P_UPTODATE); |
171 | } |
172 | } |
172 | |
173 | |
173 | MTH uint8 flags () |
174 | MTH uint8 flags () |
174 | { |
175 | { |
175 | update (); |
176 | update (); |
… | |
… | |
249 | struct shopitems : zero_initialised |
250 | struct shopitems : zero_initialised |
250 | { |
251 | { |
251 | const char *name; /* name of the item in question, null if it is the default item */ |
252 | const char *name; /* name of the item in question, null if it is the default item */ |
252 | const char *name_pl; /* plural name */ |
253 | const char *name_pl; /* plural name */ |
253 | int typenum; /* itemtype number we need to match 0 if it is the default price */ |
254 | 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, |
255 | sint8 strength; /* the degree of specialisation the shop has in this item, |
255 | * as a percentage from -100 to 100 */ |
256 | * as a percentage from -100 to 100 */ |
256 | int index; /* being the size of the shopitems array. */ |
257 | int index; /* being the size of the shopitems array. */ |
257 | }; |
258 | }; |
258 | |
259 | |
259 | // map I/O, what to load/save |
260 | // map I/O, what to load/save |
… | |
… | |
261 | IO_HEADER = 0x01, // the "arch map" pseudo object |
262 | IO_HEADER = 0x01, // the "arch map" pseudo object |
262 | IO_OBJECTS = 0x02, // the non-unique objects |
263 | IO_OBJECTS = 0x02, // the non-unique objects |
263 | IO_UNIQUES = 0x04, // unique objects |
264 | IO_UNIQUES = 0x04, // unique objects |
264 | }; |
265 | }; |
265 | |
266 | |
266 | /* In general, code should always use the macros |
267 | /* In general, code should always use the macros |
267 | * above (or functions in map.c) to access many of the |
268 | * above (or functions in map.c) to access many of the |
268 | * values in the map structure. Failure to do this will |
269 | * values in the map structure. Failure to do this will |
269 | * almost certainly break various features. You may think |
270 | * almost certainly break various features. You may think |
270 | * it is safe to look at width and height values directly |
271 | * it is safe to look at width and height values directly |
271 | * (or even through the macros), but doing so will completely |
272 | * (or even through the macros), but doing so will completely |
272 | * break map tiling. |
273 | * break map tiling. |
… | |
… | |
280 | region_ptr *regionmap; /* index to region */ |
281 | region_ptr *regionmap; /* index to region */ |
281 | |
282 | |
282 | tstamp ACC (RW, last_access); /* last time this map was accessed somehow */ |
283 | tstamp ACC (RW, last_access); /* last time this map was accessed somehow */ |
283 | |
284 | |
284 | shstr ACC (RW, name); /* Name of map as given by its creator */ |
285 | 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 |
286 | 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 |
287 | * points to the struct containing all the properties of |
287 | * the region */ |
288 | * the region */ |
288 | double ACC (RW, reset_time); |
289 | double ACC (RW, reset_time); |
289 | uint32 ACC (RW, reset_timeout); /* How many seconds must elapse before this map |
290 | uint32 ACC (RW, reset_timeout); /* How many seconds must elapse before this map |
290 | * should be reset |
291 | * should be reset |
291 | */ |
292 | */ |
… | |
… | |
527 | return *this; |
528 | return *this; |
528 | } |
529 | } |
529 | |
530 | |
530 | mapxy &move (int dir) |
531 | mapxy &move (int dir) |
531 | { |
532 | { |
532 | return move (freearr_x [dir], freearr_y [dir]); |
533 | return move (DIRX (dir), DIRY (dir)); |
533 | } |
534 | } |
534 | |
535 | |
535 | operator void *() const { return (void *)m; } |
536 | operator void *() const { return (void *)m; } |
536 | mapxy &operator =(const object *op) |
537 | mapxy &operator =(const object *op) |
537 | { |
538 | { |