1 | /* |
1 | /* |
2 | * static char *rcsid_define_h = |
2 | * static char *rcsid_define_h = |
3 | * "$Id: map.h,v 1.5 2006/03/07 13:44:43 root Exp $"; |
3 | * "$Id: map.h,v 1.6 2006/08/13 17:16:02 elmex 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 | |
… | |
… | |
186 | * have this structure take care of that information. |
186 | * have this structure take care of that information. |
187 | * This puts it all in one place, and should also make it easier |
187 | * This puts it all in one place, and should also make it easier |
188 | * to extend information about a space. |
188 | * to extend information about a space. |
189 | */ |
189 | */ |
190 | |
190 | |
191 | typedef struct MapSpace { |
191 | struct MapSpace { |
192 | object *bottom; /* lowest object on this space */ |
192 | object *bottom; /* lowest object on this space */ |
193 | object *top; /* Highest object on this space */ |
193 | object *top; /* Highest object on this space */ |
194 | New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ |
194 | New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ |
195 | object *faces_obj[MAP_LAYERS]; /* face objects for the 3 layers */ |
195 | object *faces_obj[MAP_LAYERS]; /* face objects for the 3 layers */ |
196 | uint8 flags; /* flags about this space (see the P_ values above) */ |
196 | uint8 flags; /* flags about this space (see the P_ values above) */ |
197 | sint8 light; /* How much light this space provides */ |
197 | sint8 light; /* How much light this space provides */ |
198 | MoveType move_block; /* What movement types this space blocks */ |
198 | MoveType move_block; /* What movement types this space blocks */ |
199 | MoveType move_slow; /* What movement types this space slows */ |
199 | MoveType move_slow; /* What movement types this space slows */ |
200 | MoveType move_on; /* What movement types are activated */ |
200 | MoveType move_on; /* What movement types are activated */ |
201 | MoveType move_off; /* What movement types are activated */ |
201 | MoveType move_off; /* What movement types are activated */ |
202 | } MapSpace; |
202 | }; |
203 | |
203 | |
204 | /* |
204 | /* |
205 | * this is an overlay structure of the whole world. It exists as a simple |
205 | * 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. |
206 | * 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 |
207 | * 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 |
208 | * 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 |
209 | * them at once. We can then, in a separate loop, update the actual world |
210 | * with the new values we have assigned. |
210 | * with the new values we have assigned. |
211 | */ |
211 | */ |
212 | |
212 | |
213 | typedef struct wmapdef { |
213 | struct weathermap_t { |
214 | sint16 temp; /* base temperature of this tile (F) */ |
214 | sint16 temp; /* base temperature of this tile (F) */ |
215 | sint16 pressure; /* barometric pressure (mb) */ |
215 | sint16 pressure; /* barometric pressure (mb) */ |
216 | sint8 humid; /* humitidy of this tile */ |
216 | sint8 humid; /* humitidy of this tile */ |
217 | sint8 windspeed; /* windspeed of this tile */ |
217 | sint8 windspeed; /* windspeed of this tile */ |
218 | sint8 winddir; /* direction of wind */ |
218 | sint8 winddir; /* direction of wind */ |
… | |
… | |
221 | uint32 rainfall; /* cumulative rainfall */ |
221 | uint32 rainfall; /* cumulative rainfall */ |
222 | uint8 darkness; /* indicates level of darkness of map */ |
222 | uint8 darkness; /* indicates level of darkness of map */ |
223 | uint8 water; /* 0-100 percentage of water tiles */ |
223 | uint8 water; /* 0-100 percentage of water tiles */ |
224 | /*Dynamic parts*/ |
224 | /*Dynamic parts*/ |
225 | sint16 realtemp; /* temperature at a given calculation step for this tile*/ |
225 | sint16 realtemp; /* temperature at a given calculation step for this tile*/ |
226 | } weathermap_t; |
226 | }; |
227 | |
227 | |
228 | /* |
228 | /* |
229 | * Each map is in a given region of the game world and links to a region definiton, so |
229 | * 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 |
230 | * they have to appear here in the headers, before the mapdef |
231 | */ |
231 | */ |
232 | typedef struct regiondef { |
232 | struct region { |
233 | struct regiondef *next; /* pointer to next region, NULL for the last one */ |
233 | 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 */ |
234 | const char *name; /* Shortend name of the region as maps refer to it */ |
235 | const char *parent_name; /* |
235 | const char *parent_name; /* |
236 | * So that parent and child regions can be defined in |
236 | * So that parent and child regions can be defined in |
237 | * any order, we keep hold of the parent_name during |
237 | * any order, we keep hold of the parent_name during |
238 | * initialisation, and the children get assigned to their |
238 | * initialisation, and the children get assigned to their |
239 | * parents later. (before runtime on the server though) |
239 | * parents later. (before runtime on the server though) |
240 | * nothing outside the init code should ever use this value. |
240 | * nothing outside the init code should ever use this value. |
241 | */ |
241 | */ |
242 | struct regiondef *parent;/* |
242 | struct region *parent; /* |
243 | * Pointer to the region that is a parent of the current |
243 | * Pointer to the region that is a parent of the current |
244 | * region, if a value isn't defined in the current region |
244 | * region, if a value isn't defined in the current region |
245 | * we traverse this series of pointers until it is. |
245 | * we traverse this series of pointers until it is. |
246 | */ |
246 | */ |
247 | const char *longname; /* Official title of the region, this might be defined |
247 | const char *longname; /* Official title of the region, this might be defined |
… | |
… | |
250 | uint32 counter; /* A generic counter for holding temporary data. */ |
250 | uint32 counter; /* A generic counter for holding temporary data. */ |
251 | sint8 fallback; /* whether, in the event of a region not existing, |
251 | sint8 fallback; /* whether, in the event of a region not existing, |
252 | * this should be the one we fall back on as the default */ |
252 | * this should be the one we fall back on as the default */ |
253 | char *jailmap; /*where a player that is arrested in this region should be imprisoned.*/ |
253 | char *jailmap; /*where a player that is arrested in this region should be imprisoned.*/ |
254 | sint16 jailx, jaily; /* The coodinates in jailmap to which the player should be sent. */ |
254 | sint16 jailx, jaily; /* The coodinates in jailmap to which the player should be sent. */ |
255 | } region; |
255 | }; |
256 | |
256 | |
257 | |
257 | |
258 | typedef struct shopitem { |
258 | struct shopitems { |
259 | const char *name; /* name of the item in question, null if it is the default item */ |
259 | const char *name; /* name of the item in question, null if it is the default item */ |
260 | const char *name_pl; /* plural name */ |
260 | const char *name_pl; /* plural name */ |
261 | int typenum; /* itemtype number we need to match 0 if it is the default price*/ |
261 | int typenum; /* itemtype number we need to match 0 if it is the default price*/ |
262 | sint8 strength; /* the degree of specialisation the shop has in this item, |
262 | sint8 strength; /* the degree of specialisation the shop has in this item, |
263 | * as a percentage from -100 to 100 */ |
263 | * as a percentage from -100 to 100 */ |
264 | int index; /* being the size of the shopitems array.*/ |
264 | int index; /* being the size of the shopitems array.*/ |
265 | } shopitems; |
265 | }; |
266 | |
266 | |
267 | /* In general, code should always use the macros |
267 | /* In general, code should always use the macros |
268 | * above (or functions in map.c) to access many of the |
268 | * above (or functions in map.c) to access many of the |
269 | * values in the map structure. Failure to do this will |
269 | * values in the map structure. Failure to do this will |
270 | * almost certainly break various features. You may think |
270 | * almost certainly break various features. You may think |
271 | * it is safe to look at width and height values directly |
271 | * it is safe to look at width and height values directly |
272 | * (or even through the macros), but doing so will completely |
272 | * (or even through the macros), but doing so will completely |
273 | * break map tiling. |
273 | * break map tiling. |
274 | */ |
274 | */ |
275 | typedef struct mapdef { |
275 | struct mapstruct { |
276 | struct mapdef *next; /* Next map, linked list */ |
276 | struct mapstruct *next; /* Next map, linked list */ |
277 | char *tmpname; /* Name of temporary file */ |
277 | char *tmpname; /* Name of temporary file */ |
278 | char *name; /* Name of map as given by its creator */ |
278 | char *name; /* Name of map as given by its creator */ |
279 | region *region; /* What jurisdiction in the game world this map is ruled by |
279 | struct region *region; /* What jurisdiction in the game world this map is ruled by |
280 | * points to the struct containing all the properties of |
280 | * points to the struct containing all the properties of |
281 | * the region */ |
281 | * the region */ |
282 | uint32 reset_time; /* when this map should reset */ |
282 | uint32 reset_time; /* when this map should reset */ |
283 | uint32 reset_timeout; /* How many seconds must elapse before this map |
283 | uint32 reset_timeout; /* How many seconds must elapse before this map |
284 | * should be reset |
284 | * should be reset |
285 | */ |
285 | */ |
286 | uint32 fixed_resettime:1; /* if true, reset time is not affected by |
286 | uint32 fixed_resettime:1; /* if true, reset time is not affected by |
287 | * players entering/exiting map |
287 | * players entering/exiting map |
288 | */ |
288 | */ |
289 | uint32 unique:1; /* if set, this is a per player unique map */ |
289 | uint32 unique:1; /* if set, this is a per player unique map */ |
290 | uint32 template:1; /* if set, this is a template map */ |
290 | uint32 templatemap:1; /* if set, this is a template map */ |
291 | uint32 nosmooth:1; /* if set the content of this map has smoothlevel=0 forced*/ |
291 | uint32 nosmooth:1; /* if set the content of this map has smoothlevel=0 forced*/ |
292 | sint32 timeout; /* swapout is set to this */ |
292 | sint32 timeout; /* swapout is set to this */ |
293 | sint32 swap_time; /* When it reaches 0, the map will be swapped out */ |
293 | sint32 swap_time; /* When it reaches 0, the map will be swapped out */ |
294 | sint16 players; /* How many plares are on this level right now */ |
294 | sint16 players; /* How many plares are on this level right now */ |
295 | uint32 in_memory; /* If not true, the map has been freed and must |
295 | uint32 in_memory; /* If not true, the map has been freed and must |
… | |
… | |
302 | uint16 width,height; /* Width and height of map. */ |
302 | uint16 width,height; /* Width and height of map. */ |
303 | uint16 enter_x; /* enter_x and enter_y are default entrance location */ |
303 | uint16 enter_x; /* enter_x and enter_y are default entrance location */ |
304 | uint16 enter_y; /* on the map if none are set in the exit */ |
304 | uint16 enter_y; /* on the map if none are set in the exit */ |
305 | uint32 outdoor:1; /* True if an outdoor map */ |
305 | uint32 outdoor:1; /* True if an outdoor map */ |
306 | oblinkpt *buttons; /* Linked list of linked lists of buttons */ |
306 | oblinkpt *buttons; /* Linked list of linked lists of buttons */ |
307 | MapSpace *spaces; /* Array of spaces on this map */ |
307 | struct MapSpace *spaces; /* Array of spaces on this map */ |
308 | sint16 temp; /* base temperature of this tile (F) */ |
308 | sint16 temp; /* base temperature of this tile (F) */ |
309 | sint16 pressure; /* barometric pressure (mb) */ |
309 | sint16 pressure; /* barometric pressure (mb) */ |
310 | sint8 humid; /* humitidy of this tile */ |
310 | sint8 humid; /* humitidy of this tile */ |
311 | sint8 windspeed; /* windspeed of this tile */ |
311 | sint8 windspeed; /* windspeed of this tile */ |
312 | sint8 winddir; /* direction of wind */ |
312 | sint8 winddir; /* direction of wind */ |
313 | sint8 sky; /* sky conditions */ |
313 | sint8 sky; /* sky conditions */ |
314 | int wpartx,wparty; /*Highly fasten conversion between worldmap and weathermap*/ |
314 | int wpartx,wparty; /*Highly fasten conversion between worldmap and weathermap*/ |
315 | shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ |
315 | struct shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ |
316 | char *shoprace; /* the preffered race of the local shopkeeper */ |
316 | char *shoprace; /* the preffered race of the local shopkeeper */ |
317 | double shopgreed; /* how much our shopkeeper overcharges */ |
317 | double shopgreed; /* how much our shopkeeper overcharges */ |
318 | uint64 shopmin; /* minimum price a shop will trade for */ |
318 | uint64 shopmin; /* minimum price a shop will trade for */ |
319 | uint64 shopmax; /* maximum price a shop will offer */ |
319 | uint64 shopmax; /* maximum price a shop will offer */ |
320 | char *msg; /* Message map creator may have left */ |
320 | char *msg; /* Message map creator may have left */ |
321 | char *maplore; /* Map lore information */ |
321 | char *maplore; /* Map lore information */ |
322 | char *tile_path[4]; /* path to adjoining maps */ |
322 | char *tile_path[4]; /* path to adjoining maps */ |
323 | struct mapdef *tile_map[4]; /* Next map, linked list */ |
323 | struct mapstruct *tile_map[4]; /* Next map, linked list */ |
324 | char path[HUGE_BUF]; /* Filename of the map */ |
324 | char path[HUGE_BUF]; /* Filename of the map */ |
325 | } mapstruct; |
325 | }; |
326 | |
326 | |
327 | /* This is used by get_rangevector to determine where the other |
327 | /* This is used by get_rangevector to determine where the other |
328 | * creature is. get_rangevector takes into account map tiling, |
328 | * creature is. get_rangevector takes into account map tiling, |
329 | * so you just can not look the the map coordinates and get the |
329 | * so you just can not look the the map coordinates and get the |
330 | * righte value. distance_x/y are distance away, which |
330 | * righte value. distance_x/y are distance away, which |
331 | * can be negativbe. direction is the crossfire direction scheme |
331 | * can be negativbe. direction is the crossfire direction scheme |
332 | * that the creature should head. part is the part of the |
332 | * that the creature should head. part is the part of the |
333 | * monster that is closest. |
333 | * monster that is closest. |
334 | * Note: distance should be always >=0. I changed it to UINT. MT |
334 | * Note: distance should be always >=0. I changed it to UINT. MT |
335 | */ |
335 | */ |
336 | typedef struct rv_vector { |
336 | struct rv_vector { |
337 | unsigned int distance; |
337 | unsigned int distance; |
338 | int distance_x; |
338 | int distance_x; |
339 | int distance_y; |
339 | int distance_y; |
340 | int direction; |
340 | int direction; |
341 | object *part; |
341 | object *part; |
342 | } rv_vector; |
342 | }; |
343 | |
343 | |
344 | extern void (*load_original_map_callback)(mapstruct *map); |
344 | extern void (*load_original_map_callback)(mapstruct *map); |
345 | extern void (*load_temporary_map_callback)(mapstruct *map); |
345 | extern void (*load_temporary_map_callback)(mapstruct *map); |
346 | extern void (*clean_temporary_map_callback)(mapstruct *map); |
346 | extern void (*clean_temporary_map_callback)(mapstruct *map); |
347 | |
347 | |