summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/database.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-26 16:39:35 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-26 16:39:35 +0000
commit3df2c03fc7434ef10dc8608617425c0969d18916 (patch)
treef2b016f808e573f0ac81d584cba9774899465d8c /crawl-ref/source/database.cc
parent9c48662001a42b910d8e098a64673bd0636ca3d7 (diff)
downloadcrawl-ref-3df2c03fc7434ef10dc8608617425c0969d18916.tar.gz
crawl-ref-3df2c03fc7434ef10dc8608617425c0969d18916.zip
Add a FAQ part to the database, which can be accessed from the help
screen. This is intended as a pointer for general questions, not for complicated information about rare, specific occurences. Feel free to change stuff, or add more. The Q:keyword/A:keyword solution is pretty rough, but I couldn't get the database not to turn the questions into all lowercase otherwise. If someone knows of a better method, I'm all ears! git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7981 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/database.cc')
-rw-r--r--crawl-ref/source/database.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc
index 80b2369699..488ece7d42 100644
--- a/crawl-ref/source/database.cc
+++ b/crawl-ref/source/database.cc
@@ -102,6 +102,10 @@ static TextDB AllDBs[] =
TextDB( "db/help", // database for outsourced help texts
"database/help.txt",
NULL),
+
+ TextDB( "db/FAQ", // database for Frequently Asked Questions
+ "database/FAQ.txt",
+ NULL),
};
static TextDB& DescriptionDB = AllDBs[0];
@@ -111,6 +115,7 @@ static TextDB& ShoutDB = AllDBs[3];
static TextDB& MiscDB = AllDBs[4];
static TextDB& QuotesDB = AllDBs[5];
static TextDB& HelpDB = AllDBs[6];
+static TextDB& FAQDB = AllDBs[7];
// ----------------------------------------------------------------------
// TextDB
@@ -700,6 +705,32 @@ std::string getHelpString(const std::string &topic)
}
/////////////////////////////////////////////////////////////////////////////
+// FAQ DB specific functions.
+std::vector<std::string> getAllFAQKeys()
+{
+ if (!FAQDB.get())
+ {
+ std::vector<std::string> empty;
+ return (empty);
+ }
+
+ return database_find_keys(FAQDB.get(), "^q.+", false);
+}
+
+std::string getFAQ_Question(const std::string &key)
+{
+// mprf("Question key: %s", key.c_str());
+ return _query_database(FAQDB.get(), key, false, true);
+}
+
+std::string getFAQ_Answer(const std::string &question)
+{
+ std::string key = "a" + question.substr(1, question.length()-1);
+// mprf("Answer key: %s", key.c_str());
+ return _query_database(FAQDB.get(), key, false, true);
+}
+
+/////////////////////////////////////////////////////////////////////////////
// Miscellaneous DB specific functions.
std::string getMiscString(const std::string &misc,