summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/database.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2012-03-18 01:58:42 +0100
committerAdam Borowski <kilobyte@angband.pl>2012-03-19 12:06:09 +0100
commitcf12a034b1be9a95e0df4932a152aa54a0c4f90c (patch)
tree574bb87aa2364b38313b7d21530b0bf705dae092 /crawl-ref/source/database.cc
parent12ebb0ee182eaa795543b2dc2532ab4ec06ec169 (diff)
downloadcrawl-ref-cf12a034b1be9a95e0df4932a152aa54a0c4f90c.tar.gz
crawl-ref-cf12a034b1be9a95e0df4932a152aa54a0c4f90c.zip
Let description search work on translated (only) text.
Preferably, we'd look for English text if an item lacks its translation, but it's non-trivial with DBM. Not sure if it makes sense to even bother with it (sqlite could be mandatory), but for now, this may be good enough.
Diffstat (limited to 'crawl-ref/source/database.cc')
-rw-r--r--crawl-ref/source/database.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc
index 16dbce1b8a..bed981a90b 100644
--- a/crawl-ref/source/database.cc
+++ b/crawl-ref/source/database.cc
@@ -775,6 +775,8 @@ std::vector<std::string> getLongDescKeysByRegex(const std::string &regex,
return (empty);
}
+ // FIXME: need to match regex against translated keys, which can't
+ // be done by db only.
return _database_find_keys(DescriptionDB.get(), regex, true, filter);
}
@@ -787,7 +789,13 @@ std::vector<std::string> getLongDescBodiesByRegex(const std::string &regex,
return (empty);
}
- return _database_find_bodies(DescriptionDB.get(), regex, true, filter);
+ // On partial translations, this will match only translated descriptions.
+ // Not good, but otherwise we'd have to check hundreds of keys, with
+ // two queries for each.
+ // SQL can do this in one go, DBM can't.
+ DBM *database = DescriptionDB.translation ?
+ DescriptionDB.translation->get() : DescriptionDB.get();
+ return _database_find_bodies(database, regex, true, filter);
}
/////////////////////////////////////////////////////////////////////////////