diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index ac43b589392..7423403bb9f 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -1523,8 +1523,8 @@ void ProtocolGame::checkCreatureAsKnown(uint32_t id, bool &known, uint32_t &remo } // We need to protect party players from removing const auto &creature = g_game().getCreatureByID(*it); - if (std::shared_ptr checkPlayer; - creature && (checkPlayer = creature->getPlayer()) != nullptr) { + const auto &checkPlayer = creature ? creature->getPlayer() : nullptr; + if (checkPlayer) { if (player->getParty() != checkPlayer->getParty() && !canSee(creature)) { removedKnown = *it; knownCreatureSet.erase(it);