From 6dc149ebfca674fa7870ec3773a8d544315d866f Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 16 Apr 2024 18:01:36 -0300 Subject: [PATCH 1/2] fix: check nullptr town (avoid crash if town not exist) --- src/creatures/players/player.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index 592db179071..6f975455b70 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -657,6 +657,10 @@ class Player final : public Creature, public Cylinder, public Bankable { return loginPosition; } const Position &getTemplePosition() const { + if (!town) { + return Position(); + } + return town->getTemplePosition(); } std::shared_ptr getTown() const { From 92c4d8a97a091070697d4fa3512d93f2bf1be943 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Wed, 17 Apr 2024 14:17:09 -0300 Subject: [PATCH 2/2] return static position --- src/creatures/players/player.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index 6f975455b70..855b48a782b 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -658,7 +658,8 @@ class Player final : public Creature, public Cylinder, public Bankable { } const Position &getTemplePosition() const { if (!town) { - return Position(); + static auto emptyPosition = Position(); + return emptyPosition; } return town->getTemplePosition();