summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dungeon.cc24
-rw-r--r--crawl-ref/source/ng-init.cc66
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();