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.106 by root, Sat Dec 27 04:07:44 2008 UTC vs.
Revision 1.108 by root, Sun Dec 28 08:08:24 2008 UTC

489// can be used as a single statement, but both iterate macros 489// can be used as a single statement, but both iterate macros
490// invocations must not be followed by a ";" 490// invocations must not be followed by a ";"
491// see common/los.C for usage example 491// see common/los.C for usage example
492// the walk will be ordered, outer loop x, inner loop y 492// the walk will be ordered, outer loop x, inner loop y
493// m will be set to the map (or 0), nx, ny to the map coord, dx, dy to the offset relative to op 493// m will be set to the map (or 0), nx, ny to the map coord, dx, dy to the offset relative to op
494// "continue" will skip to the next space
494#define ordered_mapwalk_begin(op,dx0,dy0,dx1,dy1) \ 495#define ordered_mapwalk_begin(op,dx0,dy0,dx1,dy1) \
495 for (int dx = (dx0); dx <= (dx1); ++dx) \ 496 for (int dx = (dx0); dx <= (dx1); ++dx) \
496 { \ 497 { \
497 sint16 nx, ny; \ 498 sint16 nx, ny; \
498 maptile *m = 0; \ 499 maptile *m = 0; \
503 /* if not, do it the slow way */ \ 504 /* if not, do it the slow way */ \
504 if (!m || ++ny >= m->height) \ 505 if (!m || ++ny >= m->height) \
505 { \ 506 { \
506 nx = (op)->x + dx; ny = (op)->y + dy; m = (op)->map; \ 507 nx = (op)->x + dx; ny = (op)->y + dy; m = (op)->map; \
507 \ 508 \
508 if (xy_normalise (m, nx, ny)) \ 509 if (!xy_normalise (m, nx, ny)) \
509 m->touch (); \
510 else \
511 m = 0; \ 510 m = 0; \
512 } 511 }
513 512
514#define ordered_mapwalk_end \ 513#define ordered_mapwalk_end \
515 } \ 514 } \
516 } 515 }
517 516
518// loop over every space in the given maprect, 517// loop over every space in the given maprect,
519// setting m, nx, ny to the map and -coordinate and dx, dy to the offste relative to dx0,dy0 518// setting m, nx, ny to the map and -coordinate and dx, dy to the offste relative to dx0,dy0
520// the iterator code must be a single statement following this macro call, similar to "if" 519// the iterator code must be a single statement following this macro call, similar to "if"
520// "continue" will skip to the next space
521#define rect_mapwalk(rect,dx0,dy0) \ 521#define rect_mapwalk(rect,dx0,dy0) \
522 statementvar (maptile *, m, (rect)->m) \ 522 statementvar (maptile *, m, (rect)->m) \
523 for (int nx = (rect)->x0; nx < (rect)->x1; ++nx) \ 523 for (int nx = (rect)->x0; nx < (rect)->x1; ++nx) \
524 for (int ny = (rect)->y0; ny < (rect)->y1; ++ny) \ 524 for (int ny = (rect)->y0; ny < (rect)->y1; ++ny) \
525 statementvar (int, dx, nx + (rect)->dx - (dx0)) \ 525 statementvar (int, dx, nx + (rect)->dx - (dx0)) \
526 statementvar (int, dy, ny + (rect)->dy - (dy0)) 526 statementvar (int, dy, ny + (rect)->dy - (dy0))
527 527
528// same as above, but the walk will not follow any particular 528// same as above, but the walk will not follow any particular
529// order (unorded), but is likely faster. 529// order (unorded), but is likely faster.
530// m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op 530// m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op
531// "continue" will skip to the next space
531#define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \ 532#define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \
532 for (maprect *r_e_c_t = (op)->map->split_to_tiles ( \ 533 for (maprect *r_e_c_t = (op)->map->split_to_tiles ( \
533 (op)->x + (dx0) , (op)->y + (dy0) , \ 534 (op)->x + (dx0) , (op)->y + (dy0) , \
534 (op)->x + (dx1) + 1, (op)->y + (dy1) + 1); \ 535 (op)->x + (dx1) + 1, (op)->y + (dy1) + 1); \
535 r_e_c_t->m; \ 536 r_e_c_t->m; \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines