[7770] Prevent access to possible deleted aura's spell proto in Aura::HandleModStealth.
[AHbot.git] / src / game / UnitEvents.h
blob3f42afd9f77ade41720cf4ac3404e6dfc291b79e
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _UNITEVENTS
20 #define _UNITEVENTS
22 #include "Common.h"
24 class ThreatContainer;
25 class ThreatManager;
26 class HostilReference;
28 //==============================================================
29 //==============================================================
31 enum UNIT_EVENT_TYPE
33 // Player/Pet changed on/offline status
34 UEV_THREAT_REF_ONLINE_STATUS = 1<<0,
36 // Threat for Player/Pet changed
37 UEV_THREAT_REF_THREAT_CHANGE = 1<<1,
39 // Player/Pet will be removed from list (dead) [for internal use]
40 UEV_THREAT_REF_REMOVE_FROM_LIST = 1<<2,
42 // Player/Pet entered/left water or some other place where it is/was not accessible for the creature
43 UEV_THREAT_REF_ASSECCIBLE_STATUS = 1<<3,
45 // Threat list is going to be sorted (if dirty flag is set)
46 UEV_THREAT_SORT_LIST = 1<<4,
48 // New target should be fetched, could tbe the current target as well
49 UEV_THREAT_SET_NEXT_TARGET = 1<<5,
51 // A new victim (target) was set. Could be NULL
52 UEV_THREAT_VICTIM_CHANGED = 1<<6,
54 // Future use
55 //UEV_UNIT_KILLED = 1<<7,
57 //Future use
58 //UEV_UNIT_HEALTH_CHANGE = 1<<8,
61 #define UEV_THREAT_REF_EVENT_MASK ( UEV_THREAT_REF_ONLINE_STATUS | UEV_THREAT_REF_THREAT_CHANGE | UEV_THREAT_REF_REMOVE_FROM_LIST | UEV_THREAT_REF_ASSECCIBLE_STATUS)
62 #define UEV_THREAT_MANAGER_EVENT_MASK (UEV_THREAT_SORT_LIST | UEV_THREAT_SET_NEXT_TARGET | UEV_THREAT_VICTIM_CHANGED)
63 #define UEV_ALL_EVENT_MASK (0xffffffff)
65 // Future use
66 //#define UEV_UNIT_EVENT_MASK (UEV_UNIT_KILLED | UEV_UNIT_HEALTH_CHANGE)
68 //==============================================================
70 class MANGOS_DLL_SPEC UnitBaseEvent
72 private:
73 uint32 iType;
74 public:
75 UnitBaseEvent(uint32 pType) { iType = pType; }
76 uint32 getType() const { return iType; }
77 bool matchesTypeMask(uint32 pMask) const { return iType & pMask; }
79 void setType(uint32 pType) { iType = pType; }
83 //==============================================================
85 class MANGOS_DLL_SPEC ThreatRefStatusChangeEvent : public UnitBaseEvent
87 private:
88 HostilReference* iHostilReference;
89 union
91 float iFValue;
92 int32 iIValue;
93 bool iBValue;
95 ThreatManager* iThreatManager;
96 public:
97 ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType) { iHostilReference = NULL; }
99 ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; }
101 ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference, float pValue) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; iFValue = pValue; }
103 ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference, bool pValue) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; iBValue = pValue; }
105 int32 getIValue() const { return iIValue; }
107 float getFValue() const { return iFValue; }
109 bool getBValue() const { return iBValue; }
111 void setBValue(bool pValue) { iBValue = pValue; }
113 HostilReference* getReference() const { return iHostilReference; }
115 void setThreatManager(ThreatManager* pThreatManager) { iThreatManager = pThreatManager; }
117 ThreatManager* getThreatManager() const { return iThreatManager; }
120 //==============================================================
122 class MANGOS_DLL_SPEC ThreatManagerEvent : public ThreatRefStatusChangeEvent
124 private:
125 ThreatContainer* iThreatContainer;
126 public:
127 ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType) {}
128 ThreatManagerEvent(uint32 pType, HostilReference* pHostilReference) : ThreatRefStatusChangeEvent(pType, pHostilReference) {}
130 void setThreatContainer(ThreatContainer* pThreatContainer) { iThreatContainer = pThreatContainer; }
132 ThreatContainer* getThreatContainer() const { return iThreatContainer; }
135 //==============================================================
136 #endif