… | |
… | |
30 | #define MAP_H |
30 | #define MAP_H |
31 | |
31 | |
32 | #include "cfperl.h" |
32 | #include "cfperl.h" |
33 | |
33 | |
34 | /* We set this size - this is to make magic map work properly on |
34 | /* We set this size - this is to make magic map work properly on |
35 | * tiled maps. There is no requirement that this matches the |
35 | * tiled maps. There is no requirement that this matches the |
36 | * tiled maps size - it just seemed like a reasonable value. |
36 | * tiled maps size - it just seemed like a reasonable value. |
37 | * Magic map code now always starts out putting the player in the |
37 | * Magic map code now always starts out putting the player in the |
38 | * center of the map - this makes the most sense when dealing |
38 | * center of the map - this makes the most sense when dealing |
39 | * with tiled maps. |
39 | * with tiled maps. |
40 | * We also figure out the magicmap color to use as we process the |
40 | * We also figure out the magicmap color to use as we process the |
… | |
… | |
44 | #define MAGIC_MAP_SIZE 50 |
44 | #define MAGIC_MAP_SIZE 50 |
45 | #define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2 |
45 | #define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2 |
46 | |
46 | |
47 | #define MAP_LAYERS 3 |
47 | #define MAP_LAYERS 3 |
48 | |
48 | |
49 | /* This is when the map will reset */ |
|
|
50 | #define MAP_WHEN_RESET(m) ((m)->reset_time) |
|
|
51 | |
|
|
52 | #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout) |
|
|
53 | #define MAP_DIFFICULTY(m) ((m)->difficulty) |
|
|
54 | #define MAP_TIMEOUT(m) ((m)->timeout) |
|
|
55 | #define MAP_SWAP_TIME(m) ((m)->swap_time) |
|
|
56 | #define MAP_OUTDOORS(m) ((m)->outdoor) |
|
|
57 | |
|
|
58 | /* mape darkness used to enforce the MAX_DARKNESS value. |
|
|
59 | * but IMO, if it is beyond max value, that should be fixed |
|
|
60 | * on the map or in the code. |
|
|
61 | */ |
|
|
62 | #define MAP_DARKNESS(m) (m)->darkness |
|
|
63 | |
|
|
64 | #define MAP_WIDTH(m) (m)->width |
|
|
65 | #define MAP_HEIGHT(m) (m)->height |
|
|
66 | |
|
|
67 | /* Convenient function - total number of spaces is used |
|
|
68 | * in many places. |
|
|
69 | */ |
|
|
70 | #define MAP_SIZE(m) ((m)->width * (m)->height) |
|
|
71 | |
|
|
72 | #define MAP_ENTER_X(m) (m)->enter_x |
|
|
73 | #define MAP_ENTER_Y(m) (m)->enter_y |
|
|
74 | |
|
|
75 | #define MAP_TEMP(m) (m)->temp |
|
|
76 | #define MAP_PRESSURE(m) (m)->pressure |
|
|
77 | #define MAP_HUMID(m) (m)->humid |
|
|
78 | #define MAP_WINDSPEED(m) (m)->windspeed |
|
|
79 | #define MAP_WINDDIRECTION(m) (m)->winddir |
|
|
80 | #define MAP_SKYCOND(m) (m)->sky |
|
|
81 | #define MAP_WORLDPARTX(m) (m)->wpartx |
|
|
82 | #define MAP_WORLDPARTY(m) (m)->wparty |
|
|
83 | #define MAP_NOSMOOTH(m) (m)->nosmooth |
|
|
84 | |
|
|
85 | /* options passed to ready_map_name and load_original_map */ |
49 | /* options passed to ready_map_name and load_original_map */ |
86 | #define MAP_FLUSH 0x1 |
50 | #define MAP_FLUSH 0x01 |
87 | #define MAP_PLAYER_UNIQUE 0x2 |
51 | #define MAP_PLAYER_UNIQUE 0x02 |
88 | #define MAP_BLOCK 0x4 |
52 | #define MAP_BLOCK 0x04 |
89 | #define MAP_STYLE 0x8 |
53 | #define MAP_STYLE 0x08 |
90 | #define MAP_OVERLAY 0x10 |
54 | #define MAP_OVERLAY 0x10 |
91 | |
55 | |
92 | /* Values for in_memory below. Should probably be an enumerations */ |
56 | /* Values for in_memory below. Should probably be an enumerations */ |
93 | #define MAP_IN_MEMORY 1 |
57 | #define MAP_IN_MEMORY 1 |
94 | #define MAP_SWAPPED 2 |
58 | #define MAP_SWAPPED 2 |
… | |
… | |
101 | * consistent (eg, op->map, op->x, op->y) |
65 | * consistent (eg, op->map, op->x, op->y) |
102 | */ |
66 | */ |
103 | // all those macros are herewith declared legacy |
67 | // all those macros are herewith declared legacy |
104 | #define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags () |
68 | #define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags () |
105 | #define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light |
69 | #define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light |
106 | #define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bottom |
70 | #define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bot |
107 | #define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top |
71 | #define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top |
108 | #define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L] |
72 | #define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L] |
109 | #define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] |
73 | #define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] |
110 | #define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block |
74 | #define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block |
111 | #define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow |
75 | #define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow |
… | |
… | |
155 | * This puts it all in one place, and should also make it easier |
119 | * This puts it all in one place, and should also make it easier |
156 | * to extend information about a space. |
120 | * to extend information about a space. |
157 | */ |
121 | */ |
158 | struct mapspace |
122 | struct mapspace |
159 | { |
123 | { |
160 | object *bottom; /* lowest object on this space */ |
124 | object *bot, *top; /* lowest/highest object on this space */ |
161 | object *top; /* Highest object on this space */ |
|
|
162 | New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ |
125 | New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ |
163 | object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ |
126 | object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ |
164 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
127 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
165 | sint8 light; /* How much light this space provides */ |
128 | sint8 light; /* How much light this space provides */ |
166 | MoveType move_block; /* What movement types this space blocks */ |
129 | MoveType move_block; /* What movement types this space blocks */ |
… | |
… | |
267 | * almost certainly break various features. You may think |
230 | * almost certainly break various features. You may think |
268 | * it is safe to look at width and height values directly |
231 | * it is safe to look at width and height values directly |
269 | * (or even through the macros), but doing so will completely |
232 | * (or even through the macros), but doing so will completely |
270 | * break map tiling. |
233 | * break map tiling. |
271 | */ |
234 | */ |
272 | ACC_CLASS (maptile) |
235 | INTERFACE_CLASS (maptile) |
273 | struct maptile : zero_initialised, attachable<maptile> |
236 | struct maptile : zero_initialised, attachable |
274 | { |
237 | { |
275 | sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */ |
238 | sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */ |
276 | struct mapspace *spaces; /* Array of spaces on this map */ |
239 | struct mapspace *spaces; /* Array of spaces on this map */ |
277 | |
240 | |
278 | maptile *ACC (RW, next); /* Next map, linked list */ |
241 | maptile *ACC (RW, next); /* Next map, linked list */ |
… | |
… | |
308 | sint16 ACC (RW, pressure); /* barometric pressure (mb) */ |
271 | sint16 ACC (RW, pressure); /* barometric pressure (mb) */ |
309 | sint8 ACC (RW, humid); /* humitidy of this tile */ |
272 | sint8 ACC (RW, humid); /* humitidy of this tile */ |
310 | sint8 ACC (RW, windspeed); /* windspeed of this tile */ |
273 | sint8 ACC (RW, windspeed); /* windspeed of this tile */ |
311 | sint8 ACC (RW, winddir); /* direction of wind */ |
274 | sint8 ACC (RW, winddir); /* direction of wind */ |
312 | sint8 ACC (RW, sky); /* sky conditions */ |
275 | sint8 ACC (RW, sky); /* sky conditions */ |
313 | int ACC (RW, wpartx), ACC (RW, wparty); /*Highly fasten conversion between worldmap and weathermap */ |
276 | int ACC (RW, worldpartx), ACC (RW, worldparty); /*Highly fasten conversion between worldmap and weathermap */ |
314 | struct shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ |
277 | struct shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ |
315 | char *ACC (RO, shoprace); /* the preffered race of the local shopkeeper */ |
278 | char *ACC (RO, shoprace); /* the preffered race of the local shopkeeper */ |
316 | double ACC (RW, shopgreed); /* how much our shopkeeper overcharges */ |
279 | double ACC (RW, shopgreed); /* how much our shopkeeper overcharges */ |
317 | sint64 ACC (RW, shopmin); /* minimum price a shop will trade for */ |
280 | sint64 ACC (RW, shopmin); /* minimum price a shop will trade for */ |
318 | sint64 ACC (RW, shopmax); /* maximum price a shop will offer */ |
281 | sint64 ACC (RW, shopmax); /* maximum price a shop will offer */ |
… | |
… | |
321 | char *tile_path[4]; /* path to adjoining maps */ |
284 | char *tile_path[4]; /* path to adjoining maps */ |
322 | maptile *tile_map[4]; /* Next map, linked list */ |
285 | maptile *tile_map[4]; /* Next map, linked list */ |
323 | char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */ |
286 | char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */ |
324 | |
287 | |
325 | maptile (); |
288 | maptile (); |
|
|
289 | ~maptile (); |
|
|
290 | void do_destroy (); |
|
|
291 | void gather_callbacks (AV *&callbacks, event_type event) const; |
|
|
292 | |
326 | void allocate (); |
293 | MTH void allocate (); |
|
|
294 | MTH int size () const { return width * height; } |
327 | |
295 | |
|
|
296 | MTH object *insert (object *op, int x, int y, object *originator = 0, int flags = 0); |
|
|
297 | |
328 | mapspace const &at (uint32 x, uint32 y) const { return spaces [x + width * y]; } |
298 | mapspace const &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } |
329 | mapspace &at (uint32 x, uint32 y) { return spaces [x + width * y]; } |
299 | mapspace &at (uint32 x, uint32 y) { return spaces [x * height + y]; } |
330 | }; |
300 | }; |
331 | |
301 | |
332 | /* This is used by get_rangevector to determine where the other |
302 | /* This is used by get_rangevector to determine where the other |
333 | * creature is. get_rangevector takes into account map tiling, |
303 | * creature is. get_rangevector takes into account map tiling, |
334 | * so you just can not look the the map coordinates and get the |
304 | * so you just can not look the the map coordinates and get the |