… | |
… | |
107 | * used in the get_map_flags value - that function is used to return |
107 | * used in the get_map_flags value - that function is used to return |
108 | * the flag value, as well as other conditions - using a more general |
108 | * the flag value, as well as other conditions - using a more general |
109 | * function that does more of the work can hopefully be used to replace |
109 | * function that does more of the work can hopefully be used to replace |
110 | * lots of duplicate checks currently in the code. |
110 | * lots of duplicate checks currently in the code. |
111 | */ |
111 | */ |
112 | #define P_OUT_OF_MAP 0x10000 /* This space is outside the map */ |
112 | #define P_OUT_OF_MAP 0x10000 /* This space is outside the map */ |
113 | #define P_NEW_MAP 0x20000 |
113 | #define P_NEW_MAP 0x20000 /* Coordinates passed result in a new tiled map */ |
114 | /* Coordinates passed result in a new tiled map */ |
|
|
115 | |
114 | |
116 | /* Instead of having numerous arrays that have information on a |
115 | /* Instead of having numerous arrays that have information on a |
117 | * particular space (was map, floor, floor2, map_ob), |
116 | * particular space (was map, floor, floor2, map_ob), |
118 | * have this structure take care of that information. |
117 | * have this structure take care of that information. |
119 | * This puts it all in one place, and should also make it easier |
118 | * This puts it all in one place, and should also make it easier |
… | |
… | |
123 | struct mapspace |
122 | struct mapspace |
124 | { |
123 | { |
125 | object *ACC (RW, bot); |
124 | object *ACC (RW, bot); |
126 | object *ACC (RW, top); /* lowest/highest object on this space */ |
125 | object *ACC (RW, top); /* lowest/highest object on this space */ |
127 | object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */ |
126 | object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */ |
|
|
127 | uint32_t smell; // the last count a player was seen here, or 0 |
|
|
128 | static uint32_t smellcount; // global smell counter |
128 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
129 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
129 | sint8 ACC (RW, light); /* How much light this space provides */ |
130 | sint8 ACC (RW, light); /* How much light this space provides */ |
130 | MoveType ACC (RW, move_block); /* What movement types this space blocks */ |
131 | MoveType ACC (RW, move_block); /* What movement types this space blocks */ |
131 | MoveType ACC (RW, move_slow); /* What movement types this space slows */ |
132 | MoveType ACC (RW, move_slow); /* What movement types this space slows */ |
132 | MoveType ACC (RW, move_on); /* What movement types are activated */ |
133 | MoveType ACC (RW, move_on); /* What movement types are activated */ |
133 | MoveType ACC (RW, move_off); /* What movement types are activated */ |
134 | MoveType ACC (RW, move_off); /* What movement types are activated */ |
134 | |
135 | |
135 | void update_ (); |
136 | void update_ (); |
136 | MTH void update () |
137 | MTH void update () |
137 | { |
138 | { |
138 | if (!(flags_ & P_UPTODATE)) |
139 | if (expect_false (!(flags_ & P_UPTODATE))) |
139 | update_ (); |
140 | update_ (); |
140 | } |
141 | } |
141 | |
142 | |
142 | MTH uint8 flags () |
143 | MTH uint8 flags () |
143 | { |
144 | { |
… | |
… | |
293 | MTH void update_buttons (); |
294 | MTH void update_buttons (); |
294 | MTH int change_map_light (int change); |
295 | MTH int change_map_light (int change); |
295 | MTH int estimate_difficulty () const; |
296 | MTH int estimate_difficulty () const; |
296 | |
297 | |
297 | MTH void play_sound (faceidx sound, int x, int y) const; |
298 | MTH void play_sound (faceidx sound, int x, int y) const; |
|
|
299 | MTH void say_msg (const char *msg, int x, int y) const; |
|
|
300 | |
|
|
301 | // connected links |
|
|
302 | oblinkpt *find_link (shstr_tmp id); |
|
|
303 | MTH void trigger (shstr_tmp id, int state = 1, object *activator = 0, object *originator = 0); |
298 | |
304 | |
299 | // set the given flag on all objects in the map |
305 | // set the given flag on all objects in the map |
300 | MTH void set_object_flag (int flag, int value = 1); |
306 | MTH void set_object_flag (int flag, int value = 1); |
301 | MTH void post_load_original (); |
307 | MTH void post_load_original (); |
302 | |
308 | |
… | |
… | |
397 | // and so on. |
403 | // and so on. |
398 | int get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny); |
404 | int get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny); |
399 | int out_of_map (maptile *m, int x, int y); |
405 | int out_of_map (maptile *m, int x, int y); |
400 | maptile *get_map_from_coord (maptile *m, sint16 *x, sint16 *y); |
406 | maptile *get_map_from_coord (maptile *m, sint16 *x, sint16 *y); |
401 | void get_rangevector (object *op1, object *op2, rv_vector *retval, int flags); |
407 | void get_rangevector (object *op1, object *op2, rv_vector *retval, int flags); |
402 | void get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags); |
408 | void get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags = 0 /*unused*/); |
403 | int on_same_map (const object *op1, const object *op2); |
409 | int on_same_map (const object *op1, const object *op2); |
404 | int adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy); |
410 | int adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy); |
405 | |
411 | |
406 | // adjust map, x and y for tiled maps and return true if the position is valid at all |
412 | // adjust map, x and y for tiled maps and return true if the position is valid at all |
407 | static inline bool |
413 | static inline bool |
… | |
… | |
488 | // can be used as a single statement, but both iterate macros |
494 | // can be used as a single statement, but both iterate macros |
489 | // invocations must not be followed by a ";" |
495 | // invocations must not be followed by a ";" |
490 | // see common/los.C for usage example |
496 | // see common/los.C for usage example |
491 | // the walk will be ordered, outer loop x, inner loop y |
497 | // the walk will be ordered, outer loop x, inner loop y |
492 | // m will be set to the map (or 0), nx, ny to the map coord, dx, dy to the offset relative to op |
498 | // m will be set to the map (or 0), nx, ny to the map coord, dx, dy to the offset relative to op |
|
|
499 | // "continue" will skip to the next space |
493 | #define ordered_mapwalk_begin(op,dx0,dy0,dx1,dy1) \ |
500 | #define ordered_mapwalk_begin(op,dx0,dy0,dx1,dy1) \ |
494 | for (int dx = (dx0); dx <= (dx1); ++dx) \ |
501 | for (int dx = (dx0); dx <= (dx1); ++dx) \ |
495 | { \ |
502 | { \ |
496 | sint16 nx, ny; \ |
503 | sint16 nx, ny; \ |
497 | maptile *m = 0; \ |
504 | maptile *m = 0; \ |
… | |
… | |
502 | /* if not, do it the slow way */ \ |
509 | /* if not, do it the slow way */ \ |
503 | if (!m || ++ny >= m->height) \ |
510 | if (!m || ++ny >= m->height) \ |
504 | { \ |
511 | { \ |
505 | nx = (op)->x + dx; ny = (op)->y + dy; m = (op)->map; \ |
512 | nx = (op)->x + dx; ny = (op)->y + dy; m = (op)->map; \ |
506 | \ |
513 | \ |
507 | if (xy_normalise (m, nx, ny)) \ |
514 | if (!xy_normalise (m, nx, ny)) \ |
508 | m->touch (); \ |
|
|
509 | else \ |
|
|
510 | m = 0; \ |
515 | m = 0; \ |
511 | } |
516 | } |
512 | |
517 | |
513 | #define ordered_mapwalk_end \ |
518 | #define ordered_mapwalk_end \ |
514 | } \ |
519 | } \ |
515 | } |
520 | } |
516 | |
521 | |
517 | // loop over every space in the given maprect, |
522 | // loop over every space in the given maprect, |
518 | // setting m, nx, ny to the map and -coordinate and dx, dy to the offste relative to dx0,dy0 |
523 | // setting m, nx, ny to the map and -coordinate and dx, dy to the offste relative to dx0,dy0 |
519 | // the iterator code must be a single statement following this macro call, similar to "if" |
524 | // the iterator code must be a single statement following this macro call, similar to "if" |
|
|
525 | // "continue" will skip to the next space |
520 | #define rect_mapwalk(rect,dx0,dy0) \ |
526 | #define rect_mapwalk(rect,dx0,dy0) \ |
521 | statementvar (maptile *, m, (rect)->m) \ |
527 | statementvar (maptile *, m, (rect)->m) \ |
522 | for (int nx = (rect)->x0; nx < (rect)->x1; ++nx) \ |
528 | for (int nx = (rect)->x0; nx < (rect)->x1; ++nx) \ |
523 | for (int ny = (rect)->y0; ny < (rect)->y1; ++ny) \ |
529 | for (int ny = (rect)->y0; ny < (rect)->y1; ++ny) \ |
524 | statementvar (int, dx, nx + (rect)->dx - (dx0)) \ |
530 | statementvar (int, dx, nx + (rect)->dx - (dx0)) \ |
525 | statementvar (int, dy, ny + (rect)->dy - (dy0)) |
531 | statementvar (int, dy, ny + (rect)->dy - (dy0)) |
526 | |
532 | |
527 | // same as above, but the walk will not follow any particular |
533 | // same as above, but the walk will not follow any particular |
528 | // order (unorded), but is likely faster. |
534 | // order (unorded), but is likely faster. |
529 | // m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op |
535 | // m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op |
|
|
536 | // "continue" will skip to the next space |
530 | #define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \ |
537 | #define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \ |
531 | for (maprect *r_e_c_t = (op)->map->split_to_tiles ( \ |
538 | for (maprect *r_e_c_t = (op)->map->split_to_tiles ( \ |
532 | (op)->x + (dx0) , (op)->y + (dy0) , \ |
539 | (op)->x + (dx0) , (op)->y + (dy0) , \ |
533 | (op)->x + (dx1) + 1, (op)->y + (dy1) + 1); \ |
540 | (op)->x + (dx1) + 1, (op)->y + (dy1) + 1); \ |
534 | r_e_c_t->m; \ |
541 | r_e_c_t->m; \ |