diff options
Diffstat (limited to 'frontend/generate_dungeon.cpp')
-rw-r--r-- | frontend/generate_dungeon.cpp | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/frontend/generate_dungeon.cpp b/frontend/generate_dungeon.cpp index c6ddcbf..e2a7c74 100644 --- a/frontend/generate_dungeon.cpp +++ b/frontend/generate_dungeon.cpp @@ -1,54 +1,16 @@ #include <memory> -#include <functional> -#include <sqlite3.h> #include "backend/Dungeon.h" #include "generate_dungeon.h" -#include "Exception.h" +#include "GameData.h" using namespace std; -class DB { - typedef unique_ptr<sqlite3, function<void(sqlite3*)>> unique_sqlite3; - typedef unique_ptr<sqlite3_stmt, function<void(sqlite3_stmt*)>> unique_sqlite3_stmt; - -public: - DB(const string & path) { - sqlite3 * db = NULL; - int ret = sqlite3_open_v2(path.c_str(), &db, SQLITE_OPEN_READONLY, NULL); - this->db = { - db, - [] (sqlite3 * db) { - sqlite3_close_v2(db); - }, - }; - if (ret != SQLITE_OK) - throw Exception("sqlite3_open_v2"); - } - - unique_sqlite3_stmt prepare(const string & query) { - sqlite3_stmt * stmt = NULL; - int ret = sqlite3_prepare_v2(this->db.get(), query.c_str(), query.size(), &stmt, NULL); - unique_sqlite3_stmt uniq_stmt = { - stmt, - [] (sqlite3_stmt * stmt) { - sqlite3_finalize(stmt); - }, - }; - if (ret != SQLITE_OK) - throw Exception("sqlite3_prepare_v2"); - return uniq_stmt; - } - -private: - unique_sqlite3 db = NULL; -}; - unique_ptr<Dungeon> generate_dungeon() { unique_ptr<Dungeon> dungeon = make_unique<Dungeon>(); - DB db { "kerkersendraken.db" }; + GameData & gd = GameData::get_instance(); return dungeon; } |