aboutsummaryrefslogtreecommitdiff
path: root/frontend/GameData.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/GameData.cpp')
-rw-r--r--frontend/GameData.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/frontend/GameData.cpp b/frontend/GameData.cpp
index 6d22f8e..70a8058 100644
--- a/frontend/GameData.cpp
+++ b/frontend/GameData.cpp
@@ -79,7 +79,7 @@ Object * GameData::create_object(const string & name) const {
.value = { row.col<int>(2), row.col<int>(3) },
.protection = row.col<int>(4),
});
- } catch (...) {
+ } catch (Exception & e) {
return ObjectFactory::create_object(name.c_str());
}
}
@@ -142,7 +142,7 @@ vector<string> GameData::random_names(const string & table, unsigned count) cons
// (i.e. the table name in this case), which makes this function vulnerable
// to SQL injection if the table argument contains user-controllable data.
String query_str = String::fmt("select naam from %s order by random() limit ?", table.c_str());
- static DBStatement query = this->db.prepare(query_str.c_str());
+ DBStatement query = this->db.prepare(query_str.c_str());
query.reset()
.bind(count)
;
@@ -169,3 +169,15 @@ vector<string> GameData::random_enemies(unsigned count) const {
return this->random_names("Vijanden", count);
}
+string GameData::random_location() const {
+ return this->random_locations(1)[0];
+}
+
+string GameData::random_object() const {
+ return this->random_objects(1)[0];
+}
+
+string GameData::random_enemy() const {
+ return this->random_enemies(1)[0];
+}
+