diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 5e0fb7fb7a3..78d1c8062ee 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -578,12 +578,11 @@ void Monster::onFollowCreatureComplete(std::shared_ptr creature) { } const auto &it = getTargetInterator(creature); - if (it != targetList.end()) { - const auto &target = (*it).lock(); - if (!target) { - return; - } + if (it == targetList.end()) { + return; + } + if (const auto &target = (*it).lock()) { targetList.erase(it); if (hasFollowPath) {