ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/map.h
(Generate patch)

Comparing deliantra/server/include/map.h (file contents):
Revision 1.110 by root, Thu Jan 8 04:35:04 2009 UTC vs.
Revision 1.115 by root, Wed Nov 4 14:45:30 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002-2005,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002-2005,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24/* 25/*
134 MoveType ACC (RW, move_off); /* What movement types are activated */ 135 MoveType ACC (RW, move_off); /* What movement types are activated */
135 136
136 void update_ (); 137 void update_ ();
137 MTH void update () 138 MTH void update ()
138 { 139 {
139 if (!(flags_ & P_UPTODATE)) 140 if (expect_false (!(flags_ & P_UPTODATE)))
140 update_ (); 141 update_ ();
141 } 142 }
142 143
143 MTH uint8 flags () 144 MTH uint8 flags ()
144 { 145 {
294 MTH void update_buttons (); 295 MTH void update_buttons ();
295 MTH int change_map_light (int change); 296 MTH int change_map_light (int change);
296 MTH int estimate_difficulty () const; 297 MTH int estimate_difficulty () const;
297 298
298 MTH void play_sound (faceidx sound, int x, int y) const; 299 MTH void play_sound (faceidx sound, int x, int y) const;
300 MTH void say_msg (const char *msg, int x, int y) const;
299 301
300 // connected links 302 // connected links
301 oblinkpt *find_link (shstr_tmp id); 303 oblinkpt *find_link (shstr_tmp id);
302 MTH void trigger (shstr_tmp id, bool state = true, object *activator = 0, object *originator = 0); 304 MTH void trigger (shstr_tmp id, int state = 1, object *activator = 0, object *originator = 0);
303 305
304 // set the given flag on all objects in the map 306 // set the given flag on all objects in the map
305 MTH void set_object_flag (int flag, int value = 1); 307 MTH void set_object_flag (int flag, int value = 1);
306 MTH void post_load_original (); 308 MTH void post_load_original ();
307 309
402// and so on. 404// and so on.
403int get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny); 405int get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny);
404int out_of_map (maptile *m, int x, int y); 406int out_of_map (maptile *m, int x, int y);
405maptile *get_map_from_coord (maptile *m, sint16 *x, sint16 *y); 407maptile *get_map_from_coord (maptile *m, sint16 *x, sint16 *y);
406void get_rangevector (object *op1, object *op2, rv_vector *retval, int flags); 408void get_rangevector (object *op1, object *op2, rv_vector *retval, int flags);
407void get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags); 409void get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags = 0 /*unused*/);
408int on_same_map (const object *op1, const object *op2); 410int on_same_map (const object *op1, const object *op2);
409int adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy); 411int adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy);
410 412
411// adjust map, x and y for tiled maps and return true if the position is valid at all 413// adjust map, x and y for tiled maps and return true if the position is valid at all
412static inline bool 414static inline bool
517#define ordered_mapwalk_end \ 519#define ordered_mapwalk_end \
518 } \ 520 } \
519 } 521 }
520 522
521// loop over every space in the given maprect, 523// loop over every space in the given maprect,
522// setting m, nx, ny to the map and -coordinate and dx, dy to the offste relative to dx0,dy0 524// setting m, nx, ny to the map and -coordinate and dx, dy to the offset relative to dx0,dy0
523// the iterator code must be a single statement following this macro call, similar to "if" 525// the iterator code must be a single statement following this macro call, similar to "if"
524// "continue" will skip to the next space 526// "continue" will skip to the next space
525#define rect_mapwalk(rect,dx0,dy0) \ 527#define rect_mapwalk(rect,dx0,dy0) \
526 statementvar (maptile *, m, (rect)->m) \ 528 statementvar (maptile *, m, (rect)->m) \
527 for (int nx = (rect)->x0; nx < (rect)->x1; ++nx) \ 529 for (int nx = (rect)->x0; nx < (rect)->x1; ++nx) \
528 for (int ny = (rect)->y0; ny < (rect)->y1; ++ny) \ 530 for (int ny = (rect)->y0; ny < (rect)->y1; ++ny) \
529 statementvar (int, dx, nx + (rect)->dx - (dx0)) \ 531 statementvar (int, dx, nx + (rect)->dx - (dx0)) \
530 statementvar (int, dy, ny + (rect)->dy - (dy0)) 532 statementvar (int, dy, ny + (rect)->dy - (dy0))
531 533
532// same as above, but the walk will not follow any particular 534// same as ordered_mapwalk, but the walk will not follow any particular
533// order (unorded), but is likely faster. 535// order (unorded), but is likely faster.
534// m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op 536// m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op
535// "continue" will skip to the next space 537// "continue" will skip to the next space
536#define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \ 538#define unordered_mapwalk_at(map,ox,oy,dx0,dy0,dx1,dy1) \
537 for (maprect *r_e_c_t = (op)->map->split_to_tiles ( \ 539 for (maprect *r_e_c_t = (map)->split_to_tiles ( \
538 (op)->x + (dx0) , (op)->y + (dy0) , \ 540 (ox) + (dx0) , (oy) + (dy0) , \
539 (op)->x + (dx1) + 1, (op)->y + (dy1) + 1); \ 541 (ox) + (dx1) + 1, (oy) + (dy1) + 1); \
540 r_e_c_t->m; \ 542 r_e_c_t->m; \
541 ++r_e_c_t) \ 543 ++r_e_c_t) \
542 rect_mapwalk (r_e_c_t, (op)->x, (op)->y) 544 rect_mapwalk (r_e_c_t, (ox), (oy))
545
546#define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \
547 unordered_mapwalk_at (op->map, op->x, op->y, dx0, dy0, dx1, dy1)
543 548
544#endif 549#endif
545 550

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines