Crossfire Server  1.75.0
map.h
Go to the documentation of this file.
1 
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  */
10 
11 #ifndef MAP_H
12 #define MAP_H
13 
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
25 #define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2
26 
32 #define MAP_LAYERS 10
33 
34 extern const char *const map_layer_name[MAP_LAYERS];
35 
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
59 #define MAP_TYPE_LEGACY 1
60 #define MAP_TYPE_DEFAULT 2
61 #define MAP_TYPE_CHOICE 3
65 #define MAP_WHEN_RESET(m) ((m)->reset_time)
66 
67 #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout)
68 #define MAP_DIFFICULTY(m) ((m)->difficulty)
69 #define MAP_TIMEOUT(m) ((m)->timeout)
70 #define MAP_OUTDOORS(m) ((m)->outdoor)
71 
73 #define MAP_DARKNESS(m) (m)->darkness
74 
76 #define MAP_WIDTH(m) (m)->width
77 
78 #define MAP_HEIGHT(m) (m)->height
79 
80 #define MAP_SIZE(m) map_size(m)
81 
83 #define MAP_ENTER_X(m) (m)->enter_x
84 
85 #define MAP_ENTER_Y(m) (m)->enter_y
86 
87 #define MAP_NOSMOOTH(m) (m)->nosmooth
88 
94 #define MAP_FLUSH 0x1
95 #define MAP_PLAYER_UNIQUE 0x2
96 #define MAP_NO_DIFFICULTY 0x4
97 #define MAP_STYLE 0x8
98 #define MAP_OVERLAY 0x10
109 #define SAVE_FLAG_SAVE_UNPAID 1
110 #define SAVE_FLAG_NO_REMOVE 2
119 #define SAVE_MODE_NORMAL 0
120 #define SAVE_MODE_INPLACE 1
121 #define SAVE_MODE_OVERLAY 2
129 #define MAP_IN_MEMORY 1
130 #define MAP_SWAPPED 2
131 #define MAP_LOADING 3
132 #define MAP_SAVING 4
142 #define SAVE_ERROR_OK 0
143 #define SAVE_ERROR_RCREATION -1
144 #define SAVE_ERROR_UCREATION -2
145 #define SAVE_ERROR_WRITE -3
146 #define SAVE_ERROR_NO_PATH -4
147 #define SAVE_ERROR_URENAME -5
148 #define SAVE_ERROR_CLOSE -6
149 /* -7 (no longer used) */
150 #define SAVE_ERROR_NOT_IN_MEMORY -10
151 #define SAVE_ERROR_PLAYER -11
154 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should
155  * really be used, as it is multi tile aware. However, there are some cases
156  * where it is known the map is not tiled or the values are known
157  * consistent (eg, op->map, op->x, op->y)
158  */
159 
160 #define GET_MAP_FLAGS(M, X, Y) (map_space(M, X, Y)->flags)
161 
162 #define SET_MAP_FLAGS(M, X, Y, C) (map_space(M, X, Y)->flags = C)
163 
165 #define GET_MAP_LIGHT(M, X, Y) (map_space(M, X, Y)->light)
166 
167 #define SET_MAP_LIGHT(M, X, Y, L) (map_space(M, X, Y)->light = L)
168 
169 #define GET_MAP_PLAYER(M, X, Y) (map_space(M, X, Y)->pl)
170 #define SET_MAP_PLAYER(M, X, Y, C) (map_space(M, X, Y)->pl = C)
171 
173 #define GET_MAP_OB(M, X, Y) (map_space(M, X, Y)->bottom)
174 
175 #define GET_MAP_TOP(M, X, Y) (map_space(M, X, Y)->top)
176 
178 #define SET_MAP_OB(M, X, Y, tmp) (map_space(M, X, Y)->bottom = (tmp))
179 
180 #define SET_MAP_TOP(M, X, Y, tmp) (map_space(M, X, Y)->top = (tmp))
181 
183 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) (map_space(M, X, Y)->faces_obj[L] = C)
184 
185 #define GET_MAP_FACE_OBJ(M, X, Y, L) (map_space(M, X, Y)->faces_obj[L])
186 
190 #define GET_MAP_FACE_OBJS(M, X, Y) (map_space(M, X, Y)->faces_obj)
191 
192 extern bool ob_move_block(object *ob1, object *ob2);
193 
195 #define GET_MAP_MOVE_BLOCK(M, X, Y) (map_space(M, X, Y)->move_block)
196 
197 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) (map_space(M, X, Y)->move_block = C)
198 
200 #define GET_MAP_MOVE_SLOW(M, X, Y) (map_space(M, X, Y)->move_slow)
201 
202 #define SET_MAP_MOVE_SLOW(M, X, Y, C) (map_space(M, X, Y)->move_slow = C)
203 
205 #define GET_MAP_MOVE_ON(M, X, Y) (map_space(M, X, Y)->move_on)
206 
207 #define SET_MAP_MOVE_ON(M, X, Y, C) (map_space(M, X, Y)->move_on = C)
208 
210 #define GET_MAP_MOVE_OFF(M, X, Y) (map_space(M, X, Y)->move_off)
211 
212 #define SET_MAP_MOVE_OFF(M, X, Y, C) (map_space(M, X, Y)->move_off = C)
213 
220 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
221 
229 #define P_BLOCKSVIEW 0x01
230 #define P_NO_MAGIC 0x02
232 /* AB_NO_PASS is used for arch_blocked() return value. It needs
233  * to be here to make sure the bits don't match with anything.
234  * Changed name to have AB_ prefix just to make sure no one
235  * is using the P_NO_PASS. AB_.. should only be used for
236  * arch_blocked and functions that examine the return value.
237  */
238 #define AB_NO_PASS 0x04
239 #define P_PLAYER 0x08
240 #define P_IS_ALIVE 0x10
241 #define P_NO_CLERIC 0x20
242 #define P_NEED_UPDATE 0x40
243 #define P_NO_ERROR 0x80
246 /* The following two values are not stored in the MapLook flags, but instead
247  * used in the get_map_flags value - that function is used to return
248  * the flag value, as well as other conditions - using a more general
249  * function that does more of the work can hopefully be used to replace
250  * lots of duplicate checks currently in the code.
251  */
252 #define P_OUT_OF_MAP 0x100
253 #define P_NEW_MAP 0x200
259 struct MapSpace {
260  object *bottom;
261  object *top;
262  object *faces_obj[MAP_LAYERS];
263  uint8_t flags;
264  int8_t light;
265  MoveType move_block;
266  MoveType move_slow;
267  MoveType move_on;
268  MoveType move_off;
269  object *pl;
270 };
277 struct region {
278  char *name;
284  char *longname;
286  char *msg;
287  uint32_t counter;
288  int8_t fallback;
290  char *jailmap;
291  int16_t jailx, jaily;
292 };
298 struct shopitems {
299  const char *name;
300  const char *name_pl;
301  int typenum;
302  int8_t strength;
304  int index;
305 };
318 struct mapstruct {
319  mapstruct *next;
320  char *tmpname;
321  char *name;
322  struct region *region;
325  uint32_t reset_time;
326  uint32_t reset_timeout;
328  uint32_t fixed_resettime:1;
330  sstring reset_group;
331  uint32_t unique:1;
332  uint32_t is_template:1;
333  uint32_t nosmooth:1;
334  uint32_t outdoor:1;
335  int32_t timeout;
336  uint16_t difficulty;
337  int16_t players;
338  uint32_t in_memory;
339  uint8_t darkness;
340  uint16_t width, height;
341  int16_t enter_x, enter_y;
347  oblinkpt *buttons;
348  MapSpace *spaces;
350  char *shoprace;
351  double shopgreed;
352  uint64_t shopmin;
353  uint64_t shopmax;
354  char *msg;
355  char *maplore;
356  char *tile_path[4];
357  mapstruct *tile_map[4];
358  char path[HUGE_BUF];
359  long last_reset_time;
360  char *background_music;
361 };
373 struct rv_vector {
374  unsigned int distance;
375  int distance_x;
376  int distance_y;
377  int direction;
378  object *part;
379 };
381 uint32_t map_size(mapstruct *m);
382 
383 extern bool map_path_unique(const char *name);
384 
385 extern MapSpace *map_space(const mapstruct *m, int x, int y);
386 
387 extern void map_reset_swap(mapstruct *m);
388 
389 extern int map_light_on(mapstruct *m, int x, int y);
390 
391 extern bool coords_in_shop(mapstruct *map, int x, int y);
392 
396 extern bool shop_contains(object *ob);
397 
398 #endif /* MAP_H */
This is used by get_rangevector to determine where the other creature is.
Definition: map.h:375
bool coords_in_shop(mapstruct *map, int x, int y)
Check if the given map coordinates are in a shop.
Definition: map.cpp:2756
std::vector< archetype * > players
Definition: player.cpp:501
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
int16_t jailx
Definition: map.h:293
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:424
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:286
Used to link together several object links.
Definition: object.h:469
uint32_t counter
A generic counter for holding temporary data.
Definition: map.h:289
bool shop_contains(object *ob)
Check if an object is in a shop.
Definition: map.cpp:2763
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:290
char * name
Shortend name of the region as maps refer to it.
Definition: map.h:280
#define MAP_LAYERS
This correspondes to the map layers in the map2 protocol.
Definition: map.h:32
This is a game-map.
Definition: map.h:320
MapSpace * map_space(const mapstruct *m, int x, int y)
Definition: map.cpp:2717
region * parent
Pointer to the region that is a parent of the current region, if a value isn&#39;t defined in the current...
Definition: map.h:281
bool ob_move_block(object *ob1, object *ob2)
Basic macro to see if ob2 blocks ob1 from moving onto this space.
Definition: map.cpp:327
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
Definition: map.cpp:808
static const flag_definition flags[]
Flag mapping.
char * jailmap
Where a player that is arrested in this region should be imprisoned.
Definition: map.h:292
int map_light_on(mapstruct *m, int x, int y)
Return the light level at position (X, Y) on map M.
Definition: map.cpp:2729
static event_registration m
Definition: citylife.cpp:424
This structure contains all information related to one map square.
Definition: map.h:261
int16_t jaily
The coodinates in jailmap to which the player should be sent.
Definition: map.h:293
char * msg
The description of the region.
Definition: map.h:288
Shop-related information for a map.
Definition: map.h:300
bool map_path_unique(const char *name)
Return true if the given map path leads to a unique map.
Definition: map.cpp:2713
void map_reset_swap(mapstruct *m)
Call this when an in-memory map is used or referenced.
Definition: map.cpp:1759
const char * sstring
Definition: sstring.h:2
This is a game region.
Definition: map.h:279
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.cpp:46