diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-12 02:08:24 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-12 02:12:51 -0800 |
commit | 087b6279a027eba362d0d3227b6cc5abdac78443 (patch) | |
tree | 080ed1b507d145685c10edbd18460f06b9737d62 /crawl-ref/source | |
parent | 7a9b9a3ade714675e04052339a36308588368311 (diff) | |
download | crawl-ref-087b6279a027eba362d0d3227b6cc5abdac78443.tar.gz crawl-ref-087b6279a027eba362d0d3227b6cc5abdac78443.zip |
Choose main temple at new-game time
Randomly choose the main temple map at new game time, and count the
altars in it to determine how many altars have to go into overflow
temples.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/dungeon.cc | 24 | ||||
-rw-r--r-- | crawl-ref/source/ng-init.cc | 66 |
2 files changed, 79 insertions, 11 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 8e6b7367b6..7623cd77b3 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -2610,24 +2610,28 @@ static bool _place_portal_vault(int stair, const std::string &tag, int dlevel) static const map_def *_dgn_random_map_for_place(bool minivault) { - const map_def *vault = NULL; - if (!minivault && player_in_branch(BRANCH_ECUMENICAL_TEMPLE)) { - // Try to place a main Temple vault with the exact number - // of altars needed. - std::string tag - = make_stringf("temple_main_%lu", - _temple_altar_list.size()); - vault = random_map_for_tag(tag); + // Temple vault determined at new game tiem. + std::string name = you.props[TEMPLE_MAP_KEY]; + + // Tolerate this for a little while, for old games. + if (!name.empty()) + { + const map_def *vault = find_map_by_name(name); - if (vault != NULL) + if (vault == NULL) + { + end(1, false, "Unable to place Temple vault '%s'", + name.c_str()); + } return (vault); + } } const level_id lid = level_id::current(); - vault = random_map_for_place(lid, minivault); + const map_def *vault = random_map_for_place(lid, minivault); // Disallow entry vaults for tutorial (only complicates things). if (!vault diff --git a/crawl-ref/source/ng-init.cc b/crawl-ref/source/ng-init.cc index c77ee15ba6..9f1d1596b4 100644 --- a/crawl-ref/source/ng-init.cc +++ b/crawl-ref/source/ng-init.cc @@ -12,6 +12,7 @@ #include "describe.h" #include "dungeon.h" #include "itemname.h" +#include "maps.h" #include "player.h" #include "random.h" #include "religion.h" @@ -73,13 +74,76 @@ void initialise_branch_depths() // overflow temples, and on what level the overflow temples are. void initialise_temples() { + ////////////////////////////////////////// + // First determine main temple map to use. + level_id ecumenical(BRANCH_ECUMENICAL_TEMPLE, 1); + + map_def *main_temple = NULL; + for (int i = 0; i < 10; i++) + { + main_temple + = const_cast<map_def*>(random_map_for_place(ecumenical, false)); + + if (main_temple == NULL) + end (1, false, "No temples?!"); + + // Without all this find_glyph() returns 0. + std::string err; + main_temple->load(); + main_temple->reinit(); + err = main_temple->run_lua(true); + + if (!err.empty()) + { + mprf(MSGCH_ERROR, "Temple %s: %s", main_temple->name.c_str(), + err.c_str()); + main_temple = NULL; + continue; + } + + main_temple->fixup(); + err = main_temple->resolve(); + + if (!err.empty()) + { + mprf(MSGCH_ERROR, "Temple %s: %s", main_temple->name.c_str(), + err.c_str()); + main_temple = NULL; + continue; + } + break; + } + + if (main_temple == NULL) + end(1, false, "No valid temples."); + + you.props[TEMPLE_MAP_KEY] = main_temple->name; + + const std::vector<coord_def> altar_coords + = main_temple->find_glyph('B'); + const unsigned int main_temple_size = altar_coords.size(); + + if (main_temple_size == 0) + { + end(1, false, "Main temple '%s' has no altars", + main_temple->name.c_str()); + } + +#ifdef DEBUG_DIAGNOSITCS + mprf(MSGCH_DIAGNOSTICS, "Chose main temple %s, size %lu", + main_temple->name.c_str(), main_temple_size); +#endif + + /////////////////////////////////// + // Now set up the overflow temples. + std::vector<god_type> god_list = temple_god_list(); std::random_shuffle(god_list.begin(), god_list.end()); std::vector<god_type> overflow_gods; - while (god_list.size() > 12) + while (god_list.size() > main_temple_size) { overflow_gods.push_back(god_list.back()); god_list.pop_back(); |