mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class MANGOS_DLL_SPEC HostilReference : public Reference<Unit, ThreatManager>
|
|||
bool iAccessible;
|
||||
private:
|
||||
// Inform the source, that the status of that reference was changed
|
||||
void fireStatusChanged(const ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent);
|
||||
void fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent);
|
||||
|
||||
Unit* getSourceUnit();
|
||||
public:
|
||||
|
|
@ -168,12 +168,9 @@ class MANGOS_DLL_SPEC ThreatContainer
|
|||
|
||||
class MANGOS_DLL_SPEC ThreatManager
|
||||
{
|
||||
private:
|
||||
HostilReference* iCurrentVictim;
|
||||
Unit* iOwner;
|
||||
ThreatContainer iThreatContainer;
|
||||
ThreatContainer iThreatOfflineContainer;
|
||||
public:
|
||||
friend class HostilReference;
|
||||
|
||||
explicit ThreatManager(Unit *pOwner);
|
||||
|
||||
~ThreatManager() { clearReferences(); }
|
||||
|
|
@ -187,7 +184,7 @@ class MANGOS_DLL_SPEC ThreatManager
|
|||
|
||||
bool isThreatListEmpty() { return iThreatContainer.empty();}
|
||||
|
||||
bool processThreatEvent(const UnitBaseEvent* pUnitBaseEvent);
|
||||
void processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent);
|
||||
|
||||
HostilReference* getCurrentVictim() { return iCurrentVictim; }
|
||||
|
||||
|
|
@ -208,6 +205,11 @@ class MANGOS_DLL_SPEC ThreatManager
|
|||
std::list<HostilReference*>& getOfflieThreatList() { return iThreatOfflineContainer.getThreatList(); }
|
||||
ThreatContainer& getOnlineContainer() { return iThreatContainer; }
|
||||
ThreatContainer& getOfflineContainer() { return iThreatOfflineContainer; }
|
||||
private:
|
||||
HostilReference* iCurrentVictim;
|
||||
Unit* iOwner;
|
||||
ThreatContainer iThreatContainer;
|
||||
ThreatContainer iThreatOfflineContainer;
|
||||
};
|
||||
|
||||
//=================================================
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7617"
|
||||
#define REVISION_NR "7618"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue