MCPcopy Create free account
hub / github.com/crawl/crawl / _query_database

Function _query_database

crawl-ref/source/database.cc:738–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738static string _query_database(TextDB &db, string key, bool canonicalise_key,
739 bool run_lua, bool untranslated)
740{
741 if (canonicalise_key)
742 {
743 // We have to canonicalise the key (in case the user typed it
744 // in and got the case wrong.)
745 lowercase(key);
746 }
747
748 // Query the DB.
749 datum result;
750
751 if (db.translation && !untranslated)
752 result = _database_fetch(db.translation->get(), key);
753 if (result.dsize <= 0)
754 result = _database_fetch(db.get(), key);
755
756 if (result.dsize <= 0)
757 return "";
758
759 string str((const char *)result.dptr, result.dsize);
760
761 // <foo> is an alias to key foo
762 if (str[0] == '<' && str[str.size() - 2] == '>'
763 && str.find('<', 1) == str.npos
764 && str.find('\n') == str.size() - 1)
765 {
766 return _query_database(db, str.substr(1, str.size() - 3),
767 canonicalise_key, run_lua, untranslated);
768 }
769
770 _substitute_descriptions(db, str, canonicalise_key, run_lua, untranslated);
771
772 if (run_lua)
773 _execute_embedded_lua(str);
774
775 return str;
776}
777
778/////////////////////////////////////////////////////////////////////////////
779// Quote DB specific functions.

Callers 10

open_dbMethod · 0.85
_substitute_descriptionsFunction · 0.85
getQuoteStringFunction · 0.85
getLongDescriptionFunction · 0.85
getGameStartDescriptionFunction · 0.85
getHelpStringFunction · 0.85
getFAQ_QuestionFunction · 0.85
getFAQ_AnswerFunction · 0.85
getHintStringFunction · 0.85
getEgoStringFunction · 0.85

Calls 7

_database_fetchFunction · 0.85
_substitute_descriptionsFunction · 0.85
_execute_embedded_luaFunction · 0.85
substrMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected