diff options
author | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-01-05 01:31:26 +0530 |
---|---|---|
committer | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-01-05 01:34:27 +0530 |
commit | ed85466e0202b396bb8d5469d2babd2a24664afc (patch) | |
tree | dc8803ffada803a7910d1cea36d96361c916f59d /crawl-ref/source/dgn-shoals.cc | |
parent | e88370a40d2cad80bf114500d42291f11dcff5fb (diff) | |
download | crawl-ref-ed85466e0202b396bb8d5469d2babd2a24664afc.tar.gz crawl-ref-ed85466e0202b396bb8d5469d2babd2a24664afc.zip |
Fix Shoal:$ generation bugs: stairs could be surrounded by deep water, hut entrances could be blocked by rock.
shoal-hut.lua test generates 1k Shoal:$ levels and verifies that the levels pass sanity tests.
Diffstat (limited to 'crawl-ref/source/dgn-shoals.cc')
-rw-r--r-- | crawl-ref/source/dgn-shoals.cc | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc index 428a6cf90e..3a263cccf3 100644 --- a/crawl-ref/source/dgn-shoals.cc +++ b/crawl-ref/source/dgn-shoals.cc @@ -398,15 +398,36 @@ static void _shoals_furniture(int margin) unwind_var<dungeon_feature_set> vault_exc(dgn_Vault_Excavatable_Feats); dgn_Vault_Excavatable_Feats.insert(DNGN_STONE_WALL); - const coord_def c = _pick_shoals_island(); - // Put all the stairs on one island. - grd(c) = DNGN_STONE_STAIRS_UP_I; - grd(c + coord_def(1, 0)) = DNGN_STONE_STAIRS_UP_II; - grd(c - coord_def(1, 0)) = DNGN_STONE_STAIRS_UP_III; - dgn_excavate(c, dgn_random_direction()); - - const coord_def p = _pick_shoals_island_distant_from(c); - const map_def *vault = random_map_for_tag("shoal_rune"); + int stair_tries = 50; + bool did_place_stairs = false; + coord_def stair_place; + while (stair_tries-- > 0) + { + stair_place = _pick_shoals_island(); + if (grd(stair_place) == DNGN_FLOOR) + { + // Put all the stairs on one island. + grd(stair_place) = DNGN_STONE_STAIRS_UP_I; + grd(stair_place + coord_def(1, 0)) = DNGN_STONE_STAIRS_UP_II; + grd(stair_place - coord_def(1, 0)) = DNGN_STONE_STAIRS_UP_III; + did_place_stairs = true; + break; + } + else + { + _shoals_islands.push_back(stair_place); + } + } + + if (!did_place_stairs) + { + dgn_veto_level(); + return; + } + + const coord_def p = _pick_shoals_island_distant_from(stair_place); + const char *SHOAL_RUNE_HUT = "shoal_rune"; + const map_def *vault = random_map_for_tag(SHOAL_RUNE_HUT); { // Place the rune dgn_map_parameters mp("rune"); @@ -425,7 +446,15 @@ static void _shoals_furniture(int margin) vault = random_map_for_tag("shoal_rune"); while (!vault && --tries > 0); if (vault) - dgn_place_map(vault, false, true, _pick_shoals_island(), 0); + dgn_place_map(vault, false, false, _pick_shoals_island(), 0); + } + + // Fixup pass to connect vaults. + for (int i = 0, size = Level_Vaults.size(); i < size; ++i) + { + vault_placement &vp(Level_Vaults[i]); + if (vp.map.has_tag(SHOAL_RUNE_HUT)) + dgn_dig_vault_loose(vp); } } else |