summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/database.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2012-04-05 23:49:46 -0400
committerNeil Moore <neil@s-z.org>2012-04-05 23:59:53 -0400
commit22a6ff26fb0f47fe232839e15d7064220e9b60cf (patch)
tree87c13f877cc656094da0b37c29586bd4652ae2ec /crawl-ref/source/database.cc
parent97089b0ef53fee34b92ccca6a72d03349b80db13 (diff)
downloadcrawl-ref-22a6ff26fb0f47fe232839e15d7064220e9b60cf.tar.gz
crawl-ref-22a6ff26fb0f47fe232839e15d7064220e9b60cf.zip
Avoid another "monster" crash.
Silver statues use the MiscDB (via weird_glowing_colour() -> getMiscString()). Detect missing databases in _getWeightedString() instead, to catch both this and the previously-handled queries.
Diffstat (limited to 'crawl-ref/source/database.cc')
-rw-r--r--crawl-ref/source/database.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc
index c9e0181978..0d7d61635a 100644
--- a/crawl-ref/source/database.cc
+++ b/crawl-ref/source/database.cc
@@ -597,6 +597,9 @@ static std::string _getWeightedString(TextDB &db, const std::string &key,
const std::string &suffix,
int fixed_weight = -1)
{
+ if (!db.get()) // when called by Gretell's "monster"
+ return "";
+
// We have to canonicalise the key (in case the user typed it
// in and got the case wrong.)
std::string canonical_key = key + suffix;
@@ -766,8 +769,6 @@ std::string getLongDescription(const std::string &key)
// god names only
std::string getWeightedRandomisedDescription(const std::string &key)
{
- if (!DescriptionDB.get()) // when called by Gretell's "monster"
- return "";
return _query_weighted_randomised(DescriptionDB, key);
}
@@ -843,8 +844,6 @@ std::string getRandNameString(const std::string &itemtype,
{
int num_replacements = 0;
- if (!RandartDB.get()) // when called by Gretell's "monster"
- return "";
return _getRandomisedStr(RandartDB, itemtype, suffix, num_replacements);
}