1 | /* |
1 | /* |
2 | * static char *rcsid_define_h = |
2 | * static char *rcsid_define_h = |
3 | * "$Id: map.h,v 1.2 2006/02/21 11:00:07 root Exp $"; |
3 | * "$Id: map.h,v 1.10 2006/08/27 16:15:12 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
31 | * It contains pointers (very indirectly) to all objects on the map. |
31 | * It contains pointers (very indirectly) to all objects on the map. |
32 | */ |
32 | */ |
33 | |
33 | |
34 | #ifndef MAP_H |
34 | #ifndef MAP_H |
35 | #define MAP_H |
35 | #define MAP_H |
|
|
36 | |
|
|
37 | #include "cfperl.h" |
36 | |
38 | |
37 | /* We set this size - this is to make magic map work properly on |
39 | /* We set this size - this is to make magic map work properly on |
38 | * tiled maps. There is no requirement that this matches the |
40 | * tiled maps. There is no requirement that this matches the |
39 | * tiled maps size - it just seemed like a reasonable value. |
41 | * tiled maps size - it just seemed like a reasonable value. |
40 | * Magic map code now always starts out putting the player in the |
42 | * Magic map code now always starts out putting the player in the |
… | |
… | |
155 | * arch_blocked and functions that examine the return value. |
157 | * arch_blocked and functions that examine the return value. |
156 | */ |
158 | */ |
157 | |
159 | |
158 | #define AB_NO_PASS 0x04 |
160 | #define AB_NO_PASS 0x04 |
159 | /*#define P_PASS_THRU 0x08 *//* */ |
161 | /*#define P_PASS_THRU 0x08 *//* */ |
|
|
162 | #define P_SAFE 0x08 /* If this is set the map is a safe map, |
|
|
163 | * that means, nothing harmful there will be done, |
|
|
164 | * like: bombs, potion usage, alchemy, spells |
|
|
165 | * this was introduced to make shops more safe |
|
|
166 | * and propably other maps */ |
160 | #define P_IS_ALIVE 0x10 /* something alive is on this space */ |
167 | #define P_IS_ALIVE 0x10 /* something alive is on this space */ |
161 | #define P_NO_CLERIC 0x20 /* no clerical spells cast here */ |
168 | #define P_NO_CLERIC 0x20 /* no clerical spells cast here */ |
162 | #define P_NEED_UPDATE 0x40 /* this space is out of date */ |
169 | #define P_NEED_UPDATE 0x40 /* this space is out of date */ |
163 | #define P_NO_ERROR 0x80 /* Purely temporary - if set, update_position |
170 | #define P_NO_ERROR 0x80 /* Purely temporary - if set, update_position |
164 | * does not complain if the flags are different. |
171 | * does not complain if the flags are different. |
… | |
… | |
186 | * have this structure take care of that information. |
193 | * have this structure take care of that information. |
187 | * This puts it all in one place, and should also make it easier |
194 | * This puts it all in one place, and should also make it easier |
188 | * to extend information about a space. |
195 | * to extend information about a space. |
189 | */ |
196 | */ |
190 | |
197 | |
191 | typedef struct MapSpace { |
198 | struct MapSpace { |
192 | object *bottom; /* lowest object on this space */ |
199 | object *bottom; /* lowest object on this space */ |
193 | object *top; /* Highest object on this space */ |
200 | object *top; /* Highest object on this space */ |
194 | New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ |
201 | New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ |
195 | object *faces_obj[MAP_LAYERS]; /* face objects for the 3 layers */ |
202 | object *faces_obj[MAP_LAYERS]; /* face objects for the 3 layers */ |
196 | uint8 flags; /* flags about this space (see the P_ values above) */ |
203 | uint8 flags; /* flags about this space (see the P_ values above) */ |
197 | sint8 light; /* How much light this space provides */ |
204 | sint8 light; /* How much light this space provides */ |
198 | MoveType move_block; /* What movement types this space blocks */ |
205 | MoveType move_block; /* What movement types this space blocks */ |
199 | MoveType move_slow; /* What movement types this space slows */ |
206 | MoveType move_slow; /* What movement types this space slows */ |
200 | MoveType move_on; /* What movement types are activated */ |
207 | MoveType move_on; /* What movement types are activated */ |
201 | MoveType move_off; /* What movement types are activated */ |
208 | MoveType move_off; /* What movement types are activated */ |
202 | } MapSpace; |
209 | }; |
203 | |
210 | |
204 | /* |
211 | /* |
205 | * this is an overlay structure of the whole world. It exists as a simple |
212 | * this is an overlay structure of the whole world. It exists as a simple |
206 | * high level map, which doesn't contain the full data of the underlying map. |
213 | * high level map, which doesn't contain the full data of the underlying map. |
207 | * in this map, only things such as weather are recorded. By doing so, we |
214 | * in this map, only things such as weather are recorded. By doing so, we |
208 | * can keep the entire world parameters in memory, and act as a whole on |
215 | * can keep the entire world parameters in memory, and act as a whole on |
209 | * them at once. We can then, in a separate loop, update the actual world |
216 | * them at once. We can then, in a separate loop, update the actual world |
210 | * with the new values we have assigned. |
217 | * with the new values we have assigned. |
211 | */ |
218 | */ |
212 | |
219 | |
213 | typedef struct wmapdef { |
220 | struct weathermap_t { |
214 | sint16 temp; /* base temperature of this tile (F) */ |
221 | sint16 temp; /* base temperature of this tile (F) */ |
215 | sint16 pressure; /* barometric pressure (mb) */ |
222 | sint16 pressure; /* barometric pressure (mb) */ |
216 | sint8 humid; /* humitidy of this tile */ |
223 | sint8 humid; /* humitidy of this tile */ |
217 | sint8 windspeed; /* windspeed of this tile */ |
224 | sint8 windspeed; /* windspeed of this tile */ |
218 | sint8 winddir; /* direction of wind */ |
225 | sint8 winddir; /* direction of wind */ |
… | |
… | |
221 | uint32 rainfall; /* cumulative rainfall */ |
228 | uint32 rainfall; /* cumulative rainfall */ |
222 | uint8 darkness; /* indicates level of darkness of map */ |
229 | uint8 darkness; /* indicates level of darkness of map */ |
223 | uint8 water; /* 0-100 percentage of water tiles */ |
230 | uint8 water; /* 0-100 percentage of water tiles */ |
224 | /*Dynamic parts*/ |
231 | /*Dynamic parts*/ |
225 | sint16 realtemp; /* temperature at a given calculation step for this tile*/ |
232 | sint16 realtemp; /* temperature at a given calculation step for this tile*/ |
226 | } weathermap_t; |
233 | }; |
227 | |
234 | |
228 | /* |
235 | /* |
229 | * Each map is in a given region of the game world and links to a region definiton, so |
236 | * Each map is in a given region of the game world and links to a region definiton, so |
230 | * they have to appear here in the headers, before the mapdef |
237 | * they have to appear here in the headers, before the mapdef |
231 | */ |
238 | */ |
232 | typedef struct regiondef { |
239 | struct region { |
233 | struct regiondef *next; /* pointer to next region, NULL for the last one */ |
240 | struct region *next; /* pointer to next region, NULL for the last one */ |
234 | const char *name; /* Shortend name of the region as maps refer to it */ |
241 | const char *name; /* Shortend name of the region as maps refer to it */ |
235 | const char *parent_name; /* |
242 | const char *parent_name; /* |
236 | * So that parent and child regions can be defined in |
243 | * So that parent and child regions can be defined in |
237 | * any order, we keep hold of the parent_name during |
244 | * any order, we keep hold of the parent_name during |
238 | * initialisation, and the children get assigned to their |
245 | * initialisation, and the children get assigned to their |
239 | * parents later. (before runtime on the server though) |
246 | * parents later. (before runtime on the server though) |
240 | * nothing outside the init code should ever use this value. |
247 | * nothing outside the init code should ever use this value. |
241 | */ |
248 | */ |
242 | struct regiondef *parent;/* |
249 | struct region *parent; /* |
243 | * Pointer to the region that is a parent of the current |
250 | * Pointer to the region that is a parent of the current |
244 | * region, if a value isn't defined in the current region |
251 | * region, if a value isn't defined in the current region |
245 | * we traverse this series of pointers until it is. |
252 | * we traverse this series of pointers until it is. |
246 | */ |
253 | */ |
247 | const char *longname; /* Official title of the region, this might be defined |
254 | const char *longname; /* Official title of the region, this might be defined |
248 | * to be the same as name*/ |
255 | * to be the same as name*/ |
249 | const char *msg; /* the description of the region */ |
256 | const char *msg; /* the description of the region */ |
250 | uint32 counter; /* A generic counter for holding temporary data. */ |
257 | uint32 counter; /* A generic counter for holding temporary data. */ |
251 | sint8 fallback; /* whether, in the event of a region not existing, |
258 | sint8 fallback; /* whether, in the event of a region not existing, |
252 | * this should be the one we fall back on as the default */ |
259 | * this should be the one we fall back on as the default */ |
253 | } region; |
260 | char *jailmap; /*where a player that is arrested in this region should be imprisoned.*/ |
|
|
261 | sint16 jailx, jaily; /* The coodinates in jailmap to which the player should be sent. */ |
|
|
262 | }; |
254 | |
263 | |
255 | |
264 | |
256 | typedef struct shopitem { |
265 | struct shopitems { |
257 | const char *name; /* name of the item in question, null if it is the default item */ |
266 | const char *name; /* name of the item in question, null if it is the default item */ |
258 | const char *name_pl; /* plural name */ |
267 | const char *name_pl; /* plural name */ |
259 | int typenum; /* itemtype number we need to match 0 if it is the default price*/ |
268 | int typenum; /* itemtype number we need to match 0 if it is the default price*/ |
260 | sint8 strength; /* the degree of specialisation the shop has in this item, |
269 | sint8 strength; /* the degree of specialisation the shop has in this item, |
261 | * as a percentage from -100 to 100 */ |
270 | * as a percentage from -100 to 100 */ |
262 | int index; /* being the size of the shopitems array.*/ |
271 | int index; /* being the size of the shopitems array.*/ |
263 | } shopitems; |
272 | }; |
264 | |
273 | |
265 | /* In general, code should always use the macros |
274 | /* In general, code should always use the macros |
266 | * above (or functions in map.c) to access many of the |
275 | * above (or functions in map.c) to access many of the |
267 | * values in the map structure. Failure to do this will |
276 | * values in the map structure. Failure to do this will |
268 | * almost certainly break various features. You may think |
277 | * almost certainly break various features. You may think |
269 | * it is safe to look at width and height values directly |
278 | * it is safe to look at width and height values directly |
270 | * (or even through the macros), but doing so will completely |
279 | * (or even through the macros), but doing so will completely |
271 | * break map tiling. |
280 | * break map tiling. |
272 | */ |
281 | */ |
273 | typedef struct mapdef { |
282 | struct mapstruct : extendable<mapstruct> { |
|
|
283 | static data_type get_dt () { return DT_MAP; } |
|
|
284 | |
274 | struct mapdef *next; /* Next map, linked list */ |
285 | struct mapstruct *next; /* Next map, linked list */ |
275 | char *tmpname; /* Name of temporary file */ |
286 | char *tmpname; /* Name of temporary file */ |
276 | char *name; /* Name of map as given by its creator */ |
287 | char *name; /* Name of map as given by its creator */ |
277 | region *region; /* What jurisdiction in the game world this map is ruled by |
288 | struct region *region; /* What jurisdiction in the game world this map is ruled by |
278 | * points to the struct containing all the properties of |
289 | * points to the struct containing all the properties of |
279 | * the region */ |
290 | * the region */ |
280 | uint32 reset_time; /* when this map should reset */ |
291 | uint32 reset_time; /* when this map should reset */ |
281 | uint32 reset_timeout; /* How many seconds must elapse before this map |
292 | uint32 reset_timeout; /* How many seconds must elapse before this map |
282 | * should be reset |
293 | * should be reset |
283 | */ |
294 | */ |
284 | uint32 fixed_resettime:1; /* if true, reset time is not affected by |
295 | uint32 fixed_resettime:1; /* if true, reset time is not affected by |
285 | * players entering/exiting map |
296 | * players entering/exiting map |
286 | */ |
297 | */ |
287 | uint32 unique:1; /* if set, this is a per player unique map */ |
298 | uint32 unique:1; /* if set, this is a per player unique map */ |
|
|
299 | uint32 safe_map:1; /* if set, this map doesn't allow using magic or harmful stuff in any way */ |
288 | uint32 template:1; /* if set, this is a template map */ |
300 | uint32 templatemap:1; /* if set, this is a template map */ |
289 | uint32 nosmooth:1; /* if set the content of this map has smoothlevel=0 forced*/ |
301 | uint32 nosmooth:1; /* if set the content of this map has smoothlevel=0 forced*/ |
290 | sint32 timeout; /* swapout is set to this */ |
302 | sint32 timeout; /* swapout is set to this */ |
291 | sint32 swap_time; /* When it reaches 0, the map will be swapped out */ |
303 | sint32 swap_time; /* When it reaches 0, the map will be swapped out */ |
292 | sint16 players; /* How many plares are on this level right now */ |
304 | sint16 players; /* How many plares are on this level right now */ |
293 | uint32 in_memory; /* If not true, the map has been freed and must |
305 | uint32 in_memory; /* If not true, the map has been freed and must |
… | |
… | |
300 | uint16 width,height; /* Width and height of map. */ |
312 | uint16 width,height; /* Width and height of map. */ |
301 | uint16 enter_x; /* enter_x and enter_y are default entrance location */ |
313 | uint16 enter_x; /* enter_x and enter_y are default entrance location */ |
302 | uint16 enter_y; /* on the map if none are set in the exit */ |
314 | uint16 enter_y; /* on the map if none are set in the exit */ |
303 | uint32 outdoor:1; /* True if an outdoor map */ |
315 | uint32 outdoor:1; /* True if an outdoor map */ |
304 | oblinkpt *buttons; /* Linked list of linked lists of buttons */ |
316 | oblinkpt *buttons; /* Linked list of linked lists of buttons */ |
305 | MapSpace *spaces; /* Array of spaces on this map */ |
317 | struct MapSpace *spaces; /* Array of spaces on this map */ |
306 | sint16 temp; /* base temperature of this tile (F) */ |
318 | sint16 temp; /* base temperature of this tile (F) */ |
307 | sint16 pressure; /* barometric pressure (mb) */ |
319 | sint16 pressure; /* barometric pressure (mb) */ |
308 | sint8 humid; /* humitidy of this tile */ |
320 | sint8 humid; /* humitidy of this tile */ |
309 | sint8 windspeed; /* windspeed of this tile */ |
321 | sint8 windspeed; /* windspeed of this tile */ |
310 | sint8 winddir; /* direction of wind */ |
322 | sint8 winddir; /* direction of wind */ |
311 | sint8 sky; /* sky conditions */ |
323 | sint8 sky; /* sky conditions */ |
312 | int wpartx,wparty; /*Highly fasten conversion between worldmap and weathermap*/ |
324 | int wpartx,wparty; /*Highly fasten conversion between worldmap and weathermap*/ |
313 | shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ |
325 | struct shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ |
314 | char *shoprace; /* the preffered race of the local shopkeeper */ |
326 | char *shoprace; /* the preffered race of the local shopkeeper */ |
315 | double shopgreed; /* how much our shopkeeper overcharges */ |
327 | double shopgreed; /* how much our shopkeeper overcharges */ |
316 | uint64 shopmin; /* minimum price a shop will trade for */ |
328 | uint64 shopmin; /* minimum price a shop will trade for */ |
317 | uint64 shopmax; /* maximum price a shop will offer */ |
329 | uint64 shopmax; /* maximum price a shop will offer */ |
318 | char *msg; /* Message map creator may have left */ |
330 | char *msg; /* Message map creator may have left */ |
|
|
331 | char *maplore; /* Map lore information */ |
319 | char *tile_path[4]; /* path to adjoining maps */ |
332 | char *tile_path[4]; /* path to adjoining maps */ |
320 | struct mapdef *tile_map[4]; /* Next map, linked list */ |
333 | struct mapstruct *tile_map[4]; /* Next map, linked list */ |
321 | char path[HUGE_BUF]; /* Filename of the map */ |
334 | char path[HUGE_BUF]; /* Filename of the map */ |
322 | } mapstruct; |
335 | }; |
323 | |
336 | |
324 | /* This is used by get_rangevector to determine where the other |
337 | /* This is used by get_rangevector to determine where the other |
325 | * creature is. get_rangevector takes into account map tiling, |
338 | * creature is. get_rangevector takes into account map tiling, |
326 | * so you just can not look the the map coordinates and get the |
339 | * so you just can not look the the map coordinates and get the |
327 | * righte value. distance_x/y are distance away, which |
340 | * righte value. distance_x/y are distance away, which |
328 | * can be negativbe. direction is the crossfire direction scheme |
341 | * can be negativbe. direction is the crossfire direction scheme |
329 | * that the creature should head. part is the part of the |
342 | * that the creature should head. part is the part of the |
330 | * monster that is closest. |
343 | * monster that is closest. |
331 | * Note: distance should be always >=0. I changed it to UINT. MT |
344 | * Note: distance should be always >=0. I changed it to UINT. MT |
332 | */ |
345 | */ |
333 | typedef struct rv_vector { |
346 | struct rv_vector { |
334 | unsigned int distance; |
347 | unsigned int distance; |
335 | int distance_x; |
348 | int distance_x; |
336 | int distance_y; |
349 | int distance_y; |
337 | int direction; |
350 | int direction; |
338 | object *part; |
351 | object *part; |
339 | } rv_vector; |
352 | }; |
340 | |
353 | |
341 | #endif |
354 | #endif |