Fix possible crash

This commit is contained in:
Yunfan Li
2024-05-06 21:56:02 +08:00
parent 7d27000de5
commit aaa33d8243
2 changed files with 3 additions and 3 deletions

View File

@@ -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;

View File

@@ -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);