aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-03 12:43:18 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-03 12:43:18 +0100
commit5f5bf3ac7a85f8cde512ec44e3d55b93fb4354ba (patch)
tree517b955e4e2ecddf185dfd13dcdc4bcf57f4588a /frontend/cmd
parented78baff64fe45479ca6c480d985ce0f9c0c9515 (diff)
remove more pointers from frontend
Diffstat (limited to 'frontend/cmd')
-rw-r--r--frontend/cmd/cheat.cpp2
-rw-r--r--frontend/cmd/go.cpp6
-rw-r--r--frontend/cmd/query.cpp2
3 files changed, 4 insertions, 6 deletions
diff --git a/frontend/cmd/cheat.cpp b/frontend/cmd/cheat.cpp
index 981bca1..59fb13c 100644
--- a/frontend/cmd/cheat.cpp
+++ b/frontend/cmd/cheat.cpp
@@ -12,7 +12,7 @@ constexpr const char * cmd_give_key = "Manifesteer";
void GameController::cmd_give(string & item_name) {
Player & player = this->dungeon->get_player();
GameData & gamedata = GameData::get_instance();
- auto object = unique_ptr<Object>(gamedata.create_object(item_name));
+ auto object = gamedata.create_object(item_name);
lprtf("Object aangemaakt: %s\n", object->get_displayname().c_str());
player.inventory.push_back(object.release());
}
diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp
index 6fb9105..0452897 100644
--- a/frontend/cmd/go.cpp
+++ b/frontend/cmd/go.cpp
@@ -22,13 +22,11 @@ void GameController::cmd_go(string & direction_str) {
Player & player = this->dungeon->get_player();
Direction direction = direction_map.at(direction_str);
- Location * next_location = player.get_location().get_exit(direction);
- if (next_location == nullptr)
- throw Exception("er is geen uitgang in deze richting");
+ Location & next_location = player.get_location().get_exit(direction);
this->dungeon->update();
if (!player.is_dead())
- player.set_location(*next_location);
+ player.set_location(next_location);
}
diff --git a/frontend/cmd/query.cpp b/frontend/cmd/query.cpp
index 6de7f56..66f1bb2 100644
--- a/frontend/cmd/query.cpp
+++ b/frontend/cmd/query.cpp
@@ -39,7 +39,7 @@ void GameController::cmd_query(string &) {
lprtf("Uitgangen: ");
bool first = true;
for (Direction direction : DIRECTIONS) {
- if (location.get_exit(direction) == nullptr) continue;
+ if (!location.has_exit(direction)) continue;
if (!first) lprtf(", ");
lprtf("%s", direction_map.at(direction).c_str());
first = false;