From ed78baff64fe45479ca6c480d985ce0f9c0c9515 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 2 Nov 2024 23:11:42 +0100 Subject: more bug fixes --- frontend/DB.cpp | 9 +++++++++ frontend/GameData.cpp | 2 +- frontend/cmd/go.cpp | 5 ++--- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'frontend') diff --git a/frontend/DB.cpp b/frontend/DB.cpp index 0f52433..1c8ab41 100644 --- a/frontend/DB.cpp +++ b/frontend/DB.cpp @@ -98,6 +98,15 @@ int DBQueryRow::col(int index) const { return this->col(index, 0); } +template <> +unsigned int DBQueryRow::col(int index, const unsigned int & default_value) const { + return this->col(index, default_value); +} +template <> +unsigned int DBQueryRow::col(int index) const { + return this->col(index, 0); +} + DBQueryRowRange DBStatement::rows() { return { *this }; } diff --git a/frontend/GameData.cpp b/frontend/GameData.cpp index 70a8058..635073a 100644 --- a/frontend/GameData.cpp +++ b/frontend/GameData.cpp @@ -77,7 +77,7 @@ Object * GameData::create_object(const string & name) const { .description = row.col(0, nullptr), .type = row.col(1, nullptr), .value = { row.col(2), row.col(3) }, - .protection = row.col(4), + .protection = row.col(4), }); } catch (Exception & e) { return ObjectFactory::create_object(name.c_str()); diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp index b8bb7e2..6fb9105 100644 --- a/frontend/cmd/go.cpp +++ b/frontend/cmd/go.cpp @@ -14,11 +14,10 @@ static const unordered_map direction_map = { { "west", Direction::WEST }, }; -void GameController::cmd_go(string & argv) { - string direction_str = str_consume_arg(argv); +void GameController::cmd_go(string & direction_str) { if (direction_str.size() == 0) throw Exception("dit commando heeft nog een argument met een richting nodig"); - if (!direction_map.contains(direction_str)) + if (!direction_map.contains(str_lower(direction_str))) throw Exception("onbekende richting \"%s\", probeer noord|zuid|oost|west", direction_str.c_str()); Player & player = this->dungeon->get_player(); -- cgit v1.2.3