diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-02 18:46:18 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-02 18:46:18 +0100 |
commit | c17df7d3e28e0eeb21f7a62d1c66f525b487a5fa (patch) | |
tree | 897cc608add9682c0ae36d3b3552147706234602 /frontend/GameData.cpp | |
parent | 5e4dd0c0197f6273c61491a5b9a030c93f796a12 (diff) |
implement dungeon generation
Diffstat (limited to 'frontend/GameData.cpp')
-rw-r--r-- | frontend/GameData.cpp | 16 |
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]; +} + |