diff --git a/Source/controls/accessibility_keys.cpp b/Source/controls/accessibility_keys.cpp index a619e4c77..ea8b1d802 100644 --- a/Source/controls/accessibility_keys.cpp +++ b/Source/controls/accessibility_keys.cpp @@ -263,6 +263,8 @@ void SpellBookKeyPressed() void CycleSpellHotkeys(bool next) { + if (MyPlayer == nullptr) + return; StaticVector validHotKeyIndexes; std::optional currentIndex; for (size_t slot = 0; slot < NumHotkeys; slot++) { @@ -290,6 +292,8 @@ void CycleSpellHotkeys(bool next) bool IsPlayerDead() { + if (MyPlayer == nullptr) + return true; return MyPlayer->_pmode == PM_DEATH || MyPlayerIsDead; } diff --git a/Source/controls/town_npc_nav.cpp b/Source/controls/town_npc_nav.cpp index 97b2bc717..df0f6f77c 100644 --- a/Source/controls/town_npc_nav.cpp +++ b/Source/controls/town_npc_nav.cpp @@ -50,6 +50,8 @@ void RefreshTownNpcOrder(bool selectFirst = false) TownNpcOrder.clear(); if (leveltype != DTYPE_TOWN) return; + if (MyPlayer == nullptr) + return; const Point playerPosition = MyPlayer->position.future; @@ -147,6 +149,8 @@ void SpeakSelectedTownNpc() SpeakText(_("No NPC selected."), true); return; } + if (MyPlayer == nullptr) + return; const Towner &towner = Towners[SelectedTownNpc]; const Point playerPosition = MyPlayer->position.future; @@ -277,6 +281,8 @@ void ListTownNpcsKeyPressed() townNpcs.reserve(Towners.size()); cows.reserve(Towners.size()); + if (MyPlayer == nullptr) + return; const Point playerPosition = MyPlayer->position.future; diff --git a/Source/controls/tracker.cpp b/Source/controls/tracker.cpp index 33f22bb05..39e568090 100644 --- a/Source/controls/tracker.cpp +++ b/Source/controls/tracker.cpp @@ -1470,6 +1470,7 @@ void AutoWalkToTrackerTargetKeyPressed() return; } if (MyPlayer == nullptr) { + AutoWalkTrackerTargetId = -1; SpeakText(_("Cannot walk right now."), true); return; } @@ -1592,6 +1593,7 @@ void UpdateAutoWalkTracker() return; if (MyPlayer == nullptr) { + AutoWalkTrackerTargetId = -1; SpeakText(_("Cannot walk right now."), true); return; }