From aaa33d8243844771a16aebff338c7de4d7bb7a07 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 6 May 2024 21:56:02 +0800 Subject: [PATCH] Fix possible crash --- src/LootObjectStack.cpp | 4 ++-- src/strategy/values/DistanceValue.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LootObjectStack.cpp b/src/LootObjectStack.cpp index 2a4ebd7e..4a047a16 100644 --- a/src/LootObjectStack.cpp +++ b/src/LootObjectStack.cpp @@ -182,11 +182,11 @@ WorldObject* LootObject::GetWorldObject(Player* bot) return nullptr; } Creature* creature = botAI->GetCreature(guid); - if (creature && creature->getDeathState() == DeathState::Corpse) + if (creature && creature->getDeathState() == DeathState::Corpse && creature->IsInWorld()) return creature; GameObject* go = botAI->GetGameObject(guid); - if (go && go->isSpawned()) + if (go && go->isSpawned() && go->IsInWorld()) return go; return nullptr; diff --git a/src/strategy/values/DistanceValue.cpp b/src/strategy/values/DistanceValue.cpp index 3882eab0..00850ed6 100644 --- a/src/strategy/values/DistanceValue.cpp +++ b/src/strategy/values/DistanceValue.cpp @@ -19,7 +19,7 @@ float DistanceValue::Calculate() return 0.0f; WorldObject* obj = loot.GetWorldObject(bot); - if (!obj) + if (!obj || !obj->IsInWorld()) return 0.0f; return sServerFacade->GetDistance2d(botAI->GetBot(), obj);