1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2005,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002-2005 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
348 | bool _load_objects (object_thawer &thawer); |
348 | bool _load_objects (object_thawer &thawer); |
349 | MTH bool _load_objects (object_thawer *thawer) { return _load_objects (*thawer); } |
349 | MTH bool _load_objects (object_thawer *thawer) { return _load_objects (*thawer); } |
350 | |
350 | |
351 | // save objects into the given file (uses IO_ flags) |
351 | // save objects into the given file (uses IO_ flags) |
352 | bool _save_objects (object_freezer &freezer, int flags); |
352 | bool _save_objects (object_freezer &freezer, int flags); |
353 | MTH bool _save_objects (const_utf8_string path, int flags); |
353 | MTH bool _save_objects (const_octet_string path, int flags); |
354 | |
354 | |
355 | // save the header pseudo object _only_ |
355 | // save the header pseudo object _only_ |
356 | bool _save_header (object_freezer &freezer); |
356 | bool _save_header (object_freezer &freezer); |
357 | MTH bool _save_header (const_utf8_string path); |
357 | MTH bool _save_header (const_octet_string path); |
358 | |
358 | |
359 | maptile (); |
359 | maptile (); |
360 | maptile (int w, int h); |
360 | maptile (int w, int h); |
361 | ~maptile (); |
361 | ~maptile (); |
362 | |
362 | |
… | |
… | |
399 | mapspace &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } |
399 | mapspace &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } |
400 | |
400 | |
401 | // return an array of maprects corresponding |
401 | // return an array of maprects corresponding |
402 | // to the given rectangular area. the last rect will have |
402 | // to the given rectangular area. the last rect will have |
403 | // a 0 map pointer. |
403 | // a 0 map pointer. |
404 | // the array will be stored in a static memory area, |
|
|
405 | // so recursion is not atm. supported |
|
|
406 | maprect *split_to_tiles (int x0, int y0, int x1, int y1); |
404 | maprect *split_to_tiles (dynbuf &buf, int x0, int y0, int x1, int y1); |
|
|
405 | |
|
|
406 | MTH bool is_in_shop (int x, int y) const; |
407 | }; |
407 | }; |
|
|
408 | |
|
|
409 | inline bool |
|
|
410 | object::is_in_shop () const |
|
|
411 | { |
|
|
412 | return is_on_map () |
|
|
413 | && map->is_in_shop (x, y); |
|
|
414 | } |
408 | |
415 | |
409 | //+GPL |
416 | //+GPL |
410 | |
417 | |
411 | /* This is used by get_rangevector to determine where the other |
418 | /* This is used by get_rangevector to determine where the other |
412 | * creature is. get_rangevector takes into account map tiling, |
419 | * creature is. get_rangevector takes into account map tiling, |
… | |
… | |
547 | |
554 | |
548 | #define ordered_mapwalk_end \ |
555 | #define ordered_mapwalk_end \ |
549 | } \ |
556 | } \ |
550 | } |
557 | } |
551 | |
558 | |
|
|
559 | extern dynbuf mapwalk_buf; // can be used in simple non-recursive situations |
|
|
560 | |
552 | // loop over every space in the given maprect, |
561 | // loop over every space in the given maprect, |
553 | // setting m, nx, ny to the map and -coordinate and dx, dy to the offset relative to dx0,dy0 |
562 | // setting m, nx, ny to the map and -coordinate and dx, dy to the offset relative to dx0,dy0 |
554 | // the iterator code must be a single statement following this macro call, similar to "if" |
563 | // the iterator code must be a single statement following this macro call, similar to "if" |
555 | // "continue" will skip to the next space |
564 | // "continue" will skip to the next space |
556 | #define rect_mapwalk(rect,dx0,dy0) \ |
565 | #define rect_mapwalk(rect,dx0,dy0) \ |
… | |
… | |
562 | |
571 | |
563 | // same as ordered_mapwalk, but the walk will not follow any particular |
572 | // same as ordered_mapwalk, but the walk will not follow any particular |
564 | // order (unorded), but is likely faster. |
573 | // order (unorded), but is likely faster. |
565 | // m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op |
574 | // m will be set to the map (never 0!), nx, ny to the map coord, dx, dy to the offset relative to op |
566 | // "continue" will skip to the next space |
575 | // "continue" will skip to the next space |
567 | #define unordered_mapwalk_at(map,ox,oy,dx0,dy0,dx1,dy1) \ |
576 | #define unordered_mapwalk_at(buf,map,ox,oy,dx0,dy0,dx1,dy1) \ |
568 | for (maprect *r_e_c_t = (map)->split_to_tiles ( \ |
577 | for (maprect *r_e_c_t = (map)->split_to_tiles (buf, \ |
569 | (ox) + (dx0) , (oy) + (dy0) , \ |
578 | (ox) + (dx0) , (oy) + (dy0) , \ |
570 | (ox) + (dx1) + 1, (oy) + (dy1) + 1); \ |
579 | (ox) + (dx1) + 1, (oy) + (dy1) + 1); \ |
571 | r_e_c_t->m; \ |
580 | r_e_c_t->m; \ |
572 | ++r_e_c_t) \ |
581 | ++r_e_c_t) \ |
573 | rect_mapwalk (r_e_c_t, (ox), (oy)) |
582 | rect_mapwalk (r_e_c_t, (ox), (oy)) |
574 | |
583 | |
575 | #define unordered_mapwalk(op,dx0,dy0,dx1,dy1) \ |
584 | #define unordered_mapwalk(buf,op,dx0,dy0,dx1,dy1) \ |
576 | unordered_mapwalk_at (op->map, op->x, op->y, dx0, dy0, dx1, dy1) |
585 | unordered_mapwalk_at (buf,op->map, op->x, op->y, dx0, dy0, dx1, dy1) |
577 | |
586 | |
578 | #endif |
587 | #endif |
579 | |
588 | |