[Crash fix] Target IsInWorld check

This commit is contained in:
Yunfan Li
2024-06-04 09:47:40 +08:00
parent 78f35f1b50
commit 55eecba11b
4 changed files with 14 additions and 3 deletions

View File

@@ -3090,6 +3090,10 @@ bool PlayerbotAI::IsInterruptableSpellCasting(Unit* target, std::string const sp
bool PlayerbotAI::HasAuraToDispel(Unit* target, uint32 dispelType) bool PlayerbotAI::HasAuraToDispel(Unit* target, uint32 dispelType)
{ {
if (!target->IsInWorld())
{
return false;
}
bool isFriend = bot->IsFriendlyTo(target); bool isFriend = bot->IsFriendlyTo(target);
for (uint32 type = SPELL_AURA_NONE; type < TOTAL_AURAS; ++type) for (uint32 type = SPELL_AURA_NONE; type < TOTAL_AURAS; ++type)
{ {

View File

@@ -1196,8 +1196,8 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
z = 0.05f + ground; z = 0.05f + ground;
LOG_INFO("playerbots", "Random teleporting bot (level {}) {} to {} {},{},{} ({}/{} locations)", LOG_INFO("playerbots", "Random teleporting bot {} (level {}) to {} {},{},{} ({}/{} locations)",
bot->GetLevel(), bot->GetName().c_str(), zone->area_name[0], x, y, z, attemtps, tlocs.size()); bot->GetName().c_str(), bot->GetLevel(), zone->area_name[0], x, y, z, attemtps, tlocs.size());
if (hearth) if (hearth)
{ {

View File

@@ -63,6 +63,10 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
return false; return false;
} }
if (!target->IsInWorld())
{
return false;
}
std::ostringstream msg; std::ostringstream msg;
msg << target->GetName(); msg << target->GetName();

View File

@@ -29,7 +29,10 @@ uint8 AoeHealValue::Calculate()
Player* player = ObjectAccessor::FindPlayer(itr->guid); Player* player = ObjectAccessor::FindPlayer(itr->guid);
if (!player || !player->IsAlive()) if (!player || !player->IsAlive())
continue; continue;
if (player->GetDistance(bot) >= sPlayerbotAIConfig->sightDistance)
continue;
float percent = (static_cast<float> (player->GetHealth()) / player->GetMaxHealth()) * 100; float percent = (static_cast<float> (player->GetHealth()) / player->GetMaxHealth()) * 100;
if (percent <= range) if (percent <= range)
++count; ++count;