mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-25 22:46:25 +00:00
Added some additional defense checks around isHostile and unit/target (#2056)
Needs second pair of eyes, they appear in crash logs here and there. Its merely a patch on a open wound. ---- As in aslong there multithreads in mapupdate, which we need for decent performance and core calls are not done correctly due various reasons. These type of issues remain. Although i am planning to experiment a little with threadsafe execution of our strategies vs performance. The most effective thing we could do is check every single action and check its stateless and where it does effect the state or read the state of a core object its done in the safest way. flags, worldthread where possible and/ot simply taking into account the state might be invalid.
This commit is contained in:
@@ -59,26 +59,22 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount)
|
||||
for (ObjectGuid const guid : targets)
|
||||
{
|
||||
Unit* unit = botAI->GetUnit(guid);
|
||||
|
||||
if (!unit)
|
||||
continue;
|
||||
|
||||
if (!unit->IsInWorld() || unit->IsDuringRemoveFromWorld())
|
||||
continue;
|
||||
|
||||
auto& rep = bot->ToPlayer()->GetReputationMgr();
|
||||
if (unit->ToCreature() && !unit->ToCreature()->GetCreatureTemplate()->lootid &&
|
||||
bot->GetReactionTo(unit) >= REP_NEUTRAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!bot->IsHostileTo(unit) && unit->GetNpcFlags() != UNIT_NPC_FLAG_NONE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!bot->isHonorOrXPTarget(unit))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (abs(bot->GetPositionZ() - unit->GetPositionZ()) > INTERACTION_DISTANCE)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user