From 0742680347f065b0d1b67834737ccf6af0f05516 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 7 Jul 2007 16:14:16 +0000 Subject: Fixed bugs in floating vault exit connections, added an entry vault as a testcase. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1785 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dungeon.cc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/dungeon.cc') diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 74763e5064..cabab1adcb 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -2789,6 +2789,22 @@ static coord_def dig_away_dir(const vault_placement &place, bool y_edge = pos.y == place.y || pos.y == place.y + place.height - 1; + // Handle exits in non-rectangular areas. + if (!x_edge && !y_edge) + { + const coord_def rel = pos - coord_def(place.x, place.y); + for (int yi = -1; yi <= 1; ++yi) + for (int xi = -1; xi <= 1; ++xi) + { + if (!xi == !yi) + continue; + + const coord_def mv(rel.x + xi, rel.y + yi); + if (!place.map.in_map(mv)) + return (mv - rel); + } + } + if (x_edge && y_edge) { if (coinflip()) @@ -2887,7 +2903,7 @@ static bool map_grid_is_on_edge(const vault_placement &place, { for (int xi = c.x - 1; xi <= c.x + 1; ++xi) for (int yi = c.y - 1; yi <= c.y + 1; ++yi) - if (!place.map.in_map(coord_def(xi, yi))) + if (!place.map.in_map(coord_def(xi - place.x, yi - place.y))) return (true); return (false); } @@ -2929,8 +2945,11 @@ static void pick_float_exits(vault_placement &place, if (possible_exits.empty()) return; - - int nexits = possible_exits.size() / 10 + 1; + + const int npoints = possible_exits.size(); + int nexits = npoints < 6? npoints : npoints / 8 + 1; + if (nexits > 10) + nexits = 10; while (nexits-- > 0) { int which_exit = random2( possible_exits.size() ); @@ -3658,8 +3677,9 @@ static bool join_the_dots( if (early_exit && at != from && grd(at) == DNGN_FLOOR) return (true); - - grd(at) = DNGN_FLOOR; + + if (unforbidden(at, MMT_VAULT)) + grd(at) = DNGN_FLOOR; if (join_count > 10000) // just insurance return (false); -- cgit v1.2.3-54-g00ecf