From 37b6c1ad5ff86c628ba9e6c82753e70333c157a1 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Sat, 7 Nov 2009 04:12:47 -0800 Subject: 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. --- crawl-ref/source/wiz-dgn.cc | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'crawl-ref') 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)) -- cgit v1.2.3-54-g00ecf