Crossfire Server, Trunk  R20608
Go to the documentation of this file.
6 /*
7  * The mapstruct is allocated each time a new map is opened.
8  * It contains pointers (very indirectly) to all objects on the map.
9  */
11 #ifndef MAP_H
12 #define MAP_H
14 /* We set this size - this is to make magic map work properly on
15  * tiled maps. There is no requirement that this matches the
16  * tiled maps size - it just seemed like a reasonable value.
17  * Magic map code now always starts out putting the player in the
18  * center of the map - this makes the most sense when dealing
19  * with tiled maps.
20  * We also figure out the magicmap color to use as we process the
21  * spaces - this is more efficient as we already have up to date
22  * map pointers.
23  */
24 #define MAGIC_MAP_SIZE 50
27 /* This correspondes to the map layers in the map2 protocol.
28  * The MAP_LAYER_... correspond to what goes on what layer -
29  * this removes the need for hardcoding, and also makes sure
30  * we don't overstep the number of layers.
31  */
32 #define MAP_LAYERS 10
34 extern const char *const map_layer_name[MAP_LAYERS];
40 #define MAP_LAYER_FLOOR 0
41 #define MAP_LAYER_NO_PICK1 1
42 #define MAP_LAYER_NO_PICK2 2
43 #define MAP_LAYER_ITEM1 3
44 #define MAP_LAYER_ITEM2 4
45 #define MAP_LAYER_ITEM3 5
46 #define MAP_LAYER_LIVING1 6
47 #define MAP_LAYER_LIVING2 7
48 #define MAP_LAYER_FLY1 8
49 #define MAP_LAYER_FLY2 9
57 #define MAP_TYPE_LEGACY 1
58 #define MAP_TYPE_DEFAULT 2
59 #define MAP_TYPE_CHOICE 3
62 #define MAP_WHEN_RESET(m) ((m)->reset_time)
64 #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout)
65 #define MAP_DIFFICULTY(m) ((m)->difficulty)
66 #define MAP_TIMEOUT(m) ((m)->timeout)
67 #define MAP_SWAP_TIME(m) ((m)->swap_time)
68 #define MAP_OUTDOORS(m) ((m)->outdoor)
75 #define MAP_DARKNESS(m) (m)->darkness
78 #define MAP_WIDTH(m) (m)->width
80 #define MAP_HEIGHT(m) (m)->height
82 #define MAP_SIZE(m) map_size(m)
85 #define MAP_ENTER_X(m) (m)->enter_x
87 #define MAP_ENTER_Y(m) (m)->enter_y
89 #define MAP_NOSMOOTH(m) (m)->nosmooth
96 #define MAP_FLUSH 0x1
97 #define MAP_PLAYER_UNIQUE 0x2
98 #define MAP_STYLE 0x8
99 #define MAP_OVERLAY 0x10
111 #define SAVE_FLAG_NO_REMOVE 2
120 #define SAVE_MODE_NORMAL 0
121 #define SAVE_MODE_INPLACE 1
122 #define SAVE_MODE_OVERLAY 2
130 #define MAP_IN_MEMORY 1
131 #define MAP_SWAPPED 2
132 #define MAP_LOADING 3
133 #define MAP_SAVING 4
143 #define SAVE_ERROR_OK 0
146 #define SAVE_ERROR_WRITE -3
147 #define SAVE_ERROR_NO_PATH -4
148 #define SAVE_ERROR_URENAME -5
149 #define SAVE_ERROR_CLOSE -6
150 #define SAVE_ERROR_RRENAME -7
151 #define SAVE_ERROR_NOT_IN_MEMORY -10
152 #define SAVE_ERROR_PLAYER -11
155 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should
156  * really be used, as it is multi tile aware. However, there are some cases
157  * where it is known the map is not tiled or the values are known
158  * consistent (eg, op->map, op->x, op->y)
159  */
161 #define GET_MAP_FLAGS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].flags)
163 #define SET_MAP_FLAGS(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
165 #define GET_MAP_LIGHT(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].light)
167 #define SET_MAP_LIGHT(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].light = L)
168 #define GET_MAP_PLAYER(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].pl)
169 #define SET_MAP_PLAYER(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].pl = C)
172 #define GET_MAP_OB(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].bottom)
174 #define GET_MAP_TOP(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].top)
177 #define SET_MAP_OB(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
179 #define SET_MAP_TOP(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))
182 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
184 #define GET_MAP_FACE_OBJ(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
189 #define GET_MAP_FACE_OBJS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
192 #define GET_MAP_MOVE_BLOCK(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_block)
194 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
197 #define GET_MAP_MOVE_SLOW(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
199 #define SET_MAP_MOVE_SLOW(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
202 #define GET_MAP_MOVE_ON(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_on)
204 #define SET_MAP_MOVE_ON(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
207 #define GET_MAP_MOVE_OFF(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_off)
209 #define SET_MAP_MOVE_OFF(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
217 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
226 #define P_BLOCKSVIEW 0x01
227 #define P_NO_MAGIC 0x02
229 /* AB_NO_PASS is used for arch_blocked() return value. It needs
230  * to be here to make sure the bits don't match with anything.
231  * Changed name to have AB_ prefix just to make sure no one
232  * is using the P_NO_PASS. AB_.. should only be used for
233  * arch_blocked and functions that examine the return value.
234  */
235 #define AB_NO_PASS 0x04
236 #define P_PLAYER 0x08
237 #define P_IS_ALIVE 0x10
238 #define P_NO_CLERIC 0x20
239 #define P_NEED_UPDATE 0x40
240 #define P_NO_ERROR 0x80
243 /* The following two values are not stored in the MapLook flags, but instead
244  * used in the get_map_flags value - that function is used to return
245  * the flag value, as well as other conditions - using a more general
246  * function that does more of the work can hopefully be used to replace
247  * lots of duplicate checks currently in the code.
248  */
249 #define P_OUT_OF_MAP 0x100
250 #define P_NEW_MAP 0x200
256 typedef struct MapSpace {
257  object *bottom;
258  object *top;
266  object *pl;
274 typedef struct regiondef {
275  struct regiondef *next;
276  char *name;
277  char *parent_name;
284  struct regiondef *parent;
289  char *longname;
291  char *msg;
292  uint32_t counter;
295  char *jailmap;
296  int16_t jailx, jaily;
303 typedef struct shopitem {
304  const char *name;
305  const char *name_pl;
306  int typenum;
309  int index;
310 } shopitems;
323 typedef struct mapdef {
324  struct mapdef *next;
325  char *tmpname;
326  char *name;
327  struct regiondef *region;
352  oblinkpt *buttons;
353  MapSpace *spaces;
354  struct shopitem *shopitems;
355  char *shoprace;
356  double shopgreed;
359  char *msg;
360  char *maplore;
361  char *tile_path[4];
362  struct mapdef *tile_map[4];
363  char path[HUGE_BUF];
378 typedef struct rv_vector {
379  unsigned int distance;
382  int direction;
383  object *part;
388 #endif /* MAP_H */
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
double shopgreed
How much our shopkeeper overcharges.
Definition: map.h:358
MapSpace * spaces
Array of spaces on this map.
Definition: map.h:355
object * bottom
Lowest object on this space.
Definition: map.h:259
struct mapdef mapstruct
This is a game-map.
int16_t jaily
The coodinates in jailmap to which the player should be sent.
Definition: map.h:298
This is used by get_rangevector to determine where the other creature is.
Definition: map.h:380
int32_t swap_time
When it reaches 0, the map will be swapped out.
Definition: map.h:342
unsigned char uint8_t
Definition: win32.h:161
object * part
Part we found.
Definition: map.h:385
uint32_t nosmooth
If set the content of this map has smoothlevel=0 forced.
Definition: map.h:339
int16_t players
How many players are on this level right now.
Definition: map.h:344
struct mapdef * tile_map[4]
Adjoining maps.
Definition: map.h:364
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
Definition: map.h:345
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:432
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
uint32_t is_template
If set, this is a template map.
Definition: map.h:338
int8_t fallback
Whether, in the event of a region not existing, this should be the one we fall back on as the default...
Definition: map.h:295
uint32_t reset_time
When this map should reset.
Definition: map.h:332
MoveType move_on
What movement types are activated.
Definition: map.h:266
const char * name
Name of the item in question, null if it is the default item.
Definition: map.h:306
char * maplore
Map lore information.
Definition: map.h:362
int distance_y
Y delta.
Definition: map.h:383
Used to link together several object links.
Definition: object.h:451
int typenum
Itemtype number we need to match, -1 if it is the default price.
Definition: map.h:308
uint16_t height
Width and height of map.
Definition: map.h:347
char * name
Name of map as given by its creator.
Definition: map.h:328
char * name
Shortend name of the region as maps refer to it.
Definition: map.h:278
int index
Being the size of the shopitems array.
Definition: map.h:311
object * faces_obj[MAP_LAYERS]
Face objects for the layers.
Definition: map.h:261
signed short int16_t
Definition: win32.h:160
int16_t enter_x
Definition: map.h:348
uint32_t unique
If set, this is a per player unique map.
Definition: map.h:337
int8_t strength
The degree of specialisation the shop has in this item, as a percentage from -100 to 100...
Definition: map.h:309
struct regiondef * next
Pointer to next region, NULL for the last one.
Definition: map.h:277
This is a game region.
Definition: map.h:276
uint64_t shopmin
Minimum price a shop will trade for.
Definition: map.h:359
MoveType move_block
What movement types this space blocks.
Definition: map.h:264
char * msg
Message map creator may have left.
Definition: map.h:361
#define MAP_LAYERS
Definition: map.h:32
int distance_x
X delta.
Definition: map.h:382
char * parent_name
So that parent and child regions can be defined in any order, we keep hold of the parent_name during ...
Definition: map.h:279
int8_t light
How much light this space provides.
Definition: map.h:263
char * tile_path[4]
Path to adjoining maps.
Definition: map.h:363
uint32_t counter
A generic counter for holding temporary data.
Definition: map.h:294
MoveType move_slow
What movement types this space slows.
Definition: map.h:265
uint32_t fixed_resettime
If true, reset time is not affected by players entering/exiting map.
Definition: map.h:335
uint8_t darkness
Indicates level of darkness of map.
Definition: map.h:346
object * pl
Player who is on this space, may be NULL.
Definition: map.h:268
long last_reset_time
A timestamp of the last original map loading.
Definition: map.h:366
struct shopitem shopitems
Shop-related information for a map.
struct MapSpace MapSpace
This structure contains all information related to one map square.
unsigned __int64 uint64_t
Definition: win32.h:167
struct regiondef * parent
Pointer to the region that is a parent of the current region, if a value isn't defined in the current...
Definition: map.h:286
struct rv_vector rv_vector
This is used by get_rangevector to determine where the other creature is.
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
Definition: map.c:830
oblinkpt * buttons
Linked list of linked lists of buttons.
Definition: map.h:354
int16_t jailx
Definition: map.h:298
int16_t enter_y
Enter_x and enter_y are default entrance coordinates to use for a map such that when an exit specifie...
Definition: map.h:348
unsigned short uint16_t
Definition: win32.h:163
uint16_t difficulty
What level the player should be to play here.
Definition: map.h:343
char * tmpname
Name of temporary file.
Definition: map.h:327
int32_t timeout
Swapout is set to this.
Definition: map.h:341
unsigned int uint32_t
Definition: win32.h:162
uint32_t outdoor
True if an outdoor map.
Definition: map.h:340
This structure contains all information related to one map square.
Definition: map.h:258
signed char int8_t
Type definitions for fixed-size integer types.
Definition: win32.h:158
const char * name_pl
Plural name.
Definition: map.h:307
char * jailmap
Where a player that is arrested in this region should be imprisoned.
Definition: map.h:297
uint32_t reset_timeout
How many seconds must elapse before this map should be reset.
Definition: map.h:333
uint64_t shopmax
MMaximum price a shop will offer.
Definition: map.h:360
uint16_t width
Definition: map.h:347
unsigned int distance
Distance, in squares.
Definition: map.h:381
int direction
General direction to the targer.
Definition: map.h:384
Shop-related information for a map.
Definition: map.h:305
signed int int32_t
Definition: win32.h:159
char * msg
The description of the region.
Definition: map.h:293
uint8_t flags
Flags about this space (see the P_ values above).
Definition: map.h:262
MoveType move_off
What movement types are activated.
Definition: map.h:267
struct shopitem * shopitems
List of item-types the map's shop will trade in.
Definition: map.h:356
struct mapdef * next
Next map, linked list.
Definition: map.h:326
char * shoprace
The preffered race of the local shopkeeper.
Definition: map.h:357
This is a game-map.
Definition: map.h:325
char * background_music
Background music to use for this map.
Definition: map.h:367
const char *const map_layer_name[MAP_LAYERS]
These correspond to the layer names in map.h - since some of the types can be on multiple layers...
Definition: map.c:46
struct regiondef * region
What jurisdiction in the game world this map is ruled by points to the struct containing all the prop...
Definition: map.h:329
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:291
struct regiondef region
This is a game region.
object * top
Highest object on this space.
Definition: map.h:260