mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
[7618] Fixed: Prevent adding threat to dead creature and for dead target.
Also remove horriable typecast in ThreatManager code and some other cleanups.
This commit is contained in:
parent
764c6b5248
commit
a787741a5a
3 changed files with 22 additions and 20 deletions
|
|
@ -81,7 +81,7 @@ void HostilReference::sourceObjectDestroyLink()
|
|||
//============================================================
|
||||
// Inform the source, that the status of the reference changed
|
||||
|
||||
void HostilReference::fireStatusChanged(const ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent)
|
||||
void HostilReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent)
|
||||
{
|
||||
if(getSource())
|
||||
getSource()->processThreatEvent(&pThreatRefStatusChangeEvent);
|
||||
|
|
@ -355,12 +355,18 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, SpellSchoolMask scho
|
|||
//players and pets have only InHateListOf
|
||||
//HateOfflineList is used co contain unattackable victims (in-flight, in-water, GM etc.)
|
||||
|
||||
if (pVictim == getOwner()) // only for same creatures :)
|
||||
// not to self
|
||||
if (pVictim == getOwner())
|
||||
return;
|
||||
|
||||
// not to GM
|
||||
if(!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) )
|
||||
return;
|
||||
|
||||
// not to dead and not for dead
|
||||
if(!pVictim->isAlive() || !getOwner()->isAlive() )
|
||||
return;
|
||||
|
||||
assert(getOwner()->GetTypeId()== TYPEID_UNIT);
|
||||
|
||||
float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, schoolMask, pThreatSpell);
|
||||
|
|
@ -444,18 +450,13 @@ void ThreatManager::setCurrentVictim(HostilReference* pHostilReference)
|
|||
// The hated unit is gone, dead or deleted
|
||||
// return true, if the event is consumed
|
||||
|
||||
bool ThreatManager::processThreatEvent(const UnitBaseEvent* pUnitBaseEvent)
|
||||
void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent)
|
||||
{
|
||||
bool consumed = false;
|
||||
|
||||
ThreatRefStatusChangeEvent* threatRefStatusChangeEvent;
|
||||
HostilReference* hostilReference;
|
||||
|
||||
threatRefStatusChangeEvent = (ThreatRefStatusChangeEvent*) pUnitBaseEvent;
|
||||
threatRefStatusChangeEvent->setThreatManager(this); // now we can set the threat manager
|
||||
hostilReference = threatRefStatusChangeEvent->getReference();
|
||||
|
||||
switch(pUnitBaseEvent->getType())
|
||||
HostilReference* hostilReference = threatRefStatusChangeEvent->getReference();
|
||||
|
||||
switch(threatRefStatusChangeEvent->getType())
|
||||
{
|
||||
case UEV_THREAT_REF_THREAT_CHANGE:
|
||||
if((getCurrentVictim() == hostilReference && threatRefStatusChangeEvent->getFValue()<0.0f) ||
|
||||
|
|
@ -493,5 +494,4 @@ bool ThreatManager::processThreatEvent(const UnitBaseEvent* pUnitBaseEvent)
|
|||
iThreatOfflineContainer.remove(hostilReference);
|
||||
break;
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue