Skip to content

Commit

Permalink
fix: increasing reference counter
Browse files Browse the repository at this point in the history
  • Loading branch information
murilo09 committed Jan 8, 2025
1 parent 3697df6 commit 81a02c1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ bool Monster::isOpponent(const std::shared_ptr<Creature> &creature) const {
return creature != master;
}

if (creature->getPlayer() && creature->getPlayer()->hasFlag(PlayerFlags_t::IgnoredByMonsters)) {
const auto &player = creature ? creature->getPlayer() : nullptr;
if (player && player->hasFlag(PlayerFlags_t::IgnoredByMonsters)) {
return false;
}

Expand All @@ -679,7 +680,7 @@ bool Monster::isOpponent(const std::shared_ptr<Creature> &creature) const {

const auto &creatureMaster = creature->getMaster();
const auto &creaturePlayer = creatureMaster ? creatureMaster->getPlayer() : nullptr;
if (creature->getPlayer() || creaturePlayer) {
if (player || creaturePlayer) {
return true;
}

Expand Down Expand Up @@ -913,7 +914,8 @@ bool Monster::isTarget(const std::shared_ptr<Creature> &creature) {
}

if (!isSummon()) {
if (creature->getPlayer() && creature->getPlayer()->isDisconnected()) {
const auto &player = creature ? creature->getPlayer() : nullptr;
if (player && player->isDisconnected()) {
return false;
}

Expand All @@ -934,7 +936,8 @@ bool Monster::selectTarget(const std::shared_ptr<Creature> &creature) {
return false;
}

if (creature && creature->getPlayer()->isLoginProtected()) {
const auto &player = creature ? creature->getPlayer() : nullptr;
if (player && player->isLoginProtected()) {
return false;
}

Expand Down

0 comments on commit 81a02c1

Please sign in to comment.