[XTarget] Disallow Corpses in XTarget Auto Slots (#1881)

* [XTarget] Disallow Corpses in XTarget Auto Slots

Why:
There exists an odd state where corpses will fill up your XTarget window.
This is reproducable using a combination of a pet to kill a mob
and timely feign death to wipe the owner's aggro.

What:
Added an IsCorpse check to IsXTarget.
Added a block to mark corpse XTargets as dirty to ProcessXTargetAutoHaters

* fixup! [XTarget] Disallow Corpses in XTarget Auto Slots

* fixup! [XTarget] Disallow Corpses in XTarget Auto Slots

* [XTarget] Disallow Corpses Code Cleanup

Added some safety, performance, and code readability changes per PR request.
This commit is contained in:
mmcgarvey
2022-01-02 22:07:57 -05:00
committed by GitHub
parent 645251992d
commit 220d8497dd
4 changed files with 24 additions and 3 deletions
+13 -3
View File
@@ -7172,7 +7172,7 @@ void Client::OpenLFGuildWindow()
bool Client::IsXTarget(const Mob *m) const
{
if(!XTargettingAvailable() || !m || (m->GetID() == 0))
if(!XTargettingAvailable() || !m || !m->IsValidXTarget())
return false;
for(int i = 0; i < GetMaxXTargets(); ++i)
@@ -7215,10 +7215,10 @@ void Client::UpdateClientXTarget(Client *c)
// IT IS NOT SAFE TO CALL THIS IF IT'S NOT INITIAL AGGRO
void Client::AddAutoXTarget(Mob *m, bool send)
{
m_activeautohatermgr->increment_count(m);
if (!XTargettingAvailable() || !XTargetAutoAddHaters || IsXTarget(m))
return;
m_activeautohatermgr->increment_count(m);
for(int i = 0; i < GetMaxXTargets(); ++i)
{
@@ -7428,8 +7428,17 @@ void Client::ProcessXTargetAutoHaters()
if (XTargets[i].Type != Auto)
continue;
auto *mob = entity_list.GetMob(XTargets[i].ID);
if (XTargets[i].ID != 0 && !GetXTargetAutoMgr()->contains_mob(XTargets[i].ID)) {
XTargets[i].ID = 0;
XTargets[i].Name[0] = 0;
XTargets[i].dirty = true;
}
if (XTargets[i].ID != 0 && mob && !mob->IsValidXTarget()) {
XTargets[i].ID = 0;
XTargets[i].Name[0] = 0;
XTargets[i].dirty = true;
}
@@ -7465,6 +7474,7 @@ void Client::ProcessXTargetAutoHaters()
break;
}
}
m_dirtyautohaters = false;
SendXTargetUpdates();
}