From c17df7d3e28e0eeb21f7a62d1c66f525b487a5fa Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 2 Nov 2024 18:46:18 +0100 Subject: implement dungeon generation --- frontend/GameData.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'frontend/GameData.cpp') 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(2), row.col(3) }, .protection = row.col(4), }); - } catch (...) { + } catch (Exception & e) { return ObjectFactory::create_object(name.c_str()); } } @@ -142,7 +142,7 @@ vector 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 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]; +} + -- cgit v1.2.3