diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-07 04:12:47 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-07 04:12:47 -0800 |
commit | 37b6c1ad5ff86c628ba9e6c82753e70333c157a1 (patch) | |
tree | 8739f8b76ae0e4161678035eab9ca6c1c45281a7 /crawl-ref/source/wiz-dgn.cc | |
parent | cbcaadf4ed24d890378126c97b1a7ae7da907b72 (diff) | |
download | crawl-ref-37b6c1ad5ff86c628ba9e6c82753e70333c157a1.tar.gz crawl-ref-37b6c1ad5ff86c628ba9e6c82753e70333c157a1.zip |
wiz-dgn.cc: Check for out-of-bounds maps
If you try to place a map right on top of you (&L *vault_name) then
check to make sure than this wouldn't place any of the map
out-of-bounds.
Diffstat (limited to 'crawl-ref/source/wiz-dgn.cc')
-rw-r--r-- | crawl-ref/source/wiz-dgn.cc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/crawl-ref/source/wiz-dgn.cc b/crawl-ref/source/wiz-dgn.cc index 3e8149b84f..4a691c7725 100644 --- a/crawl-ref/source/wiz-dgn.cc +++ b/crawl-ref/source/wiz-dgn.cc @@ -555,10 +555,32 @@ static void debug_load_map_by_name(std::string name) } coord_def where(-1, -1); - if ((toplace->orient == MAP_FLOAT || toplace->orient == MAP_NONE) - && place_on_us) + if (place_on_us) { - where = you.pos(); + if (toplace->orient == MAP_FLOAT || toplace->orient == MAP_NONE) + { + coord_def size = toplace->map.size(); + coord_def tl = you.pos() - (size / 2) - coord_def(-1, -1); + coord_def br = you.pos() + (size / 2) + coord_def(-1, -1); + + for (rectangle_iterator ri(tl, br); ri; ++ri) + { + if (!in_bounds(*ri)) + { + mprf("Placing %s on top of you would put part of the " + "map outside of the level, cancelling.", + toplace->name.c_str()); + return; + } + } + // We're okay. + where = you.pos(); + } + else + { + mprf("%s decides where it goes, can't place where you are.", + toplace->name.c_str()); + } } if (dgn_place_map(toplace, true, false, where)) |