Guest User

Untitled

a guest
Jan 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.37 KB | None | 0 0
  1. diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
  2. index f8e8e8f..cd79f20 100644
  3. --- a/src/game/GridNotifiersImpl.h
  4. +++ b/src/game/GridNotifiersImpl.h
  5. @@ -166,8 +166,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
  6. {
  7. if (!holder->GetAuraByEffectIndex(eff_index))
  8. {
  9. - PersistentAreaAura* Aur = new PersistentAreaAura(spellInfo, eff_index, NULL, holder, target, i_dynobject.GetCaster());
  10. - holder->AddAura(Aur, eff_index);
  11. + PersistentAreaAura* Aur = holder->CreatePersistentAreaAura(spellInfo, eff_index, NULL, target, i_dynobject.GetCaster());
  12. target->AddAuraToModList(Aur);
  13. holder->SetInUse(true);
  14. Aur->ApplyModifier(true,true);
  15. @@ -182,8 +181,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
  16. else
  17. {
  18. holder = CreateSpellAuraHolder(spellInfo, target, i_dynobject.GetCaster());
  19. - PersistentAreaAura* Aur = new PersistentAreaAura(spellInfo, eff_index, NULL, holder, target, i_dynobject.GetCaster());
  20. - holder->AddAura(Aur, eff_index);
  21. + holder->CreatePersistentAreaAura(spellInfo, eff_index, NULL, target, i_dynobject.GetCaster());
  22. target->AddSpellAuraHolder(holder);
  23. }
  24.  
  25. diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
  26. index 3e83a72..27e708e 100644
  27. --- a/src/game/Level3.cpp
  28. +++ b/src/game/Level3.cpp
  29. @@ -4018,8 +4018,7 @@ bool ChatHandler::HandleAuraCommand(char* args)
  30. eff == SPELL_EFFECT_APPLY_AURA ||
  31. eff == SPELL_EFFECT_PERSISTENT_AREA_AURA)
  32. {
  33. - Aura *aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, target);
  34. - holder->AddAura(aur, SpellEffectIndex(i));
  35. + holder->CreateAura(spellInfo, SpellEffectIndex(i), NULL, target, NULL, NULL);
  36. }
  37. }
  38. target->AddSpellAuraHolder(holder);
  39. diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
  40. index 233cf25..4112b60 100644
  41. --- a/src/game/Pet.cpp
  42. +++ b/src/game/Pet.cpp
  43. @@ -1401,12 +1401,11 @@ void Pet::_LoadAuras(uint32 timediff)
  44. if ((effIndexMask & (1 << i)) == 0)
  45. continue;
  46.  
  47. - Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this);
  48. + Aura* aura = holder->CreateAura(spellproto, SpellEffectIndex(i), NULL, (Unit*)this, NULL, NULL);
  49. if (!damage[i])
  50. damage[i] = aura->GetModifier()->m_amount;
  51.  
  52. aura->SetLoadedState(damage[i], periodicTime[i]);
  53. - holder->AddAura(aura, SpellEffectIndex(i));
  54. }
  55.  
  56. if (!holder->IsEmptyHolder())
  57. @@ -1439,14 +1438,18 @@ void Pet::_SaveAuras()
  58. "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) "
  59. "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  60.  
  61. - for(SpellAuraHolderMap::const_iterator itr = auraHolders.begin(); itr != auraHolders.end(); ++itr)
  62. + for (SpellAuraHolderMap::const_iterator itr = auraHolders.begin(); itr != auraHolders.end(); ++itr)
  63. {
  64. SpellAuraHolder *holder = itr->second;
  65.  
  66. + if (!holder || holder->IsDeleted())
  67. + continue;
  68. +
  69. + SpellEntry const* spellInfo = holder->GetSpellProto();
  70. +
  71. bool save = true;
  72. for (int32 j = 0; j < MAX_EFFECT_INDEX; ++j)
  73. {
  74. - SpellEntry const* spellInfo = holder->GetSpellProto();
  75. if (spellInfo->EffectApplyAuraName[j] == SPELL_AURA_MOD_STEALTH ||
  76. spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER ||
  77. spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AREA_AURA_PET )
  78. @@ -3082,8 +3085,7 @@ bool Pet::ReapplyScalingAura(SpellAuraHolder* holder, SpellEntry const *spellpro
  79. RemoveAura(oldaura, AURA_REMOVE_BY_STACK);
  80. }
  81.  
  82. - Aura* aura = CreateAura(spellproto, index, &basePoints, holder, this, this, NULL);
  83. - holder->AddAura(aura, index);
  84. + Aura* aura = holder->CreateAura(spellproto, index, &basePoints, this, this, NULL);
  85. holder->SetAuraDuration(aura->GetAuraMaxDuration());
  86. AddAuraToModList(aura);
  87. aura->ApplyModifier(true,true);
  88. diff --git a/src/game/Player.cpp b/src/game/Player.cpp
  89. index 04846e7..4cfed79 100644
  90. --- a/src/game/Player.cpp
  91. +++ b/src/game/Player.cpp
  92. @@ -16792,12 +16792,12 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
  93. if ((effIndexMask & (1 << i)) == 0)
  94. continue;
  95.  
  96. - Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this);
  97. + Aura* aura = holder->CreateAura(spellproto, SpellEffectIndex(i), NULL, this, NULL, NULL);
  98. +
  99. if (!damage[i])
  100. damage[i] = aura->GetModifier()->m_amount;
  101.  
  102. aura->SetLoadedState(damage[i], periodicTime[i]);
  103. - holder->AddAura(aura, SpellEffectIndex(i));
  104. }
  105.  
  106. if (!holder->IsEmptyHolder())
  107. diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
  108. index 9d42d94..eca078e 100644
  109. --- a/src/game/SpellAuras.cpp
  110. +++ b/src/game/SpellAuras.cpp
  111. @@ -534,19 +534,44 @@ Unit* SingleEnemyTargetAura::GetTriggerTarget() const
  112. return ObjectAccessor::GetUnit(*(m_spellAuraHolder->GetTarget()), m_castersTargetGuid);
  113. }
  114.  
  115. -Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem)
  116. +Aura* SpellAuraHolder::CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit *target, Unit *caster, Item* castItem)
  117. {
  118. - if (IsAreaAuraEffect(spellproto->Effect[eff]))
  119. - return new AreaAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem);
  120. -
  121. uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff];
  122. -
  123. - if (SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
  124. + if (IsAreaAuraEffect(spellproto->Effect[eff]))
  125. + {
  126. + AddAura((Aura)AreaAura(spellproto, eff, currentBasePoints, this, target, caster, castItem), eff);
  127. + return GetAuraByEffectIndex(eff);
  128. + }
  129. + else if (SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
  130. + {
  131. for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
  132. + {
  133. if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY)
  134. - return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem);
  135. + {
  136. + AddAura((Aura)SingleEnemyTargetAura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff);
  137. + return GetAuraByEffectIndex(eff);
  138. + }
  139. + }
  140. + }
  141. + // else - normal aura
  142.  
  143. - return new Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem);
  144. + AddAura(Aura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff);
  145. +
  146. + return GetAuraByEffectIndex(eff);
  147. +}
  148. +
  149. +PersistentAreaAura* SpellAuraHolder::CreatePersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit* target, Unit* caster, Item* castItem)
  150. +{
  151. + AddAura((Aura)PersistentAreaAura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff);
  152. +
  153. + return ((PersistentAreaAura*)GetAuraByEffectIndex(eff));
  154. +}
  155. +
  156. +AreaAura* SpellAuraHolder::CreateAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit* target, Unit* caster, Item* castItem)
  157. +{
  158. + AddAura((Aura)AreaAura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff);
  159. +
  160. + return ((AreaAura*)GetAuraByEffectIndex(eff));
  161. }
  162.  
  163. SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem)
  164. @@ -782,8 +807,7 @@ void AreaAura::Update(uint32 diff)
  165.  
  166. holder->SetAuraDuration(GetAuraDuration());
  167.  
  168. - AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, holder, (*tIter), caster, NULL);
  169. - holder->AddAura(aur, m_effIndex);
  170. + AreaAura* aur = holder->CreateAreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL);
  171.  
  172. if (addedToExisting)
  173. {
  174. @@ -9787,7 +9811,7 @@ void Aura::HandleAuraStopNaturalManaRegen(bool apply, bool Real)
  175. bool Aura::IsLastAuraOnHolder()
  176. {
  177. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  178. - if (i != GetEffIndex() && GetHolder()->m_auras[i])
  179. + if (i != GetEffIndex() && GetHolder()->GetAuraByEffectIndex(SpellEffectIndex(i)))
  180. return false;
  181. return true;
  182. }
  183. @@ -9806,6 +9830,7 @@ m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0)
  184. {
  185. MANGOS_ASSERT(target);
  186. MANGOS_ASSERT(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
  187. + m_aurasStorage.clear();
  188.  
  189. if (!caster)
  190. m_casterGuid = target->GetObjectGuid();
  191. @@ -9864,24 +9889,60 @@ m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0)
  192. RemoveAura(SpellEffectIndex(i));
  193. }
  194.  
  195. -void SpellAuraHolder::AddAura(Aura *aura, SpellEffectIndex index)
  196. +void SpellAuraHolder::AddAura(Aura aura, SpellEffectIndex index)
  197. {
  198. - m_auras[index] = aura;
  199. + if (Aura* _aura = GetAuraByEffectIndex(index))
  200. + {
  201. + if (!_aura->IsDeleted())
  202. + {
  203. + DEBUG_LOG("SpellAuraHolder::AddAura attempt to add aura (effect %u) to holder of spell %u, but holder already have active aura!", index, GetId());
  204. + return;
  205. + }
  206. + else
  207. + RemoveAura(index);
  208. + }
  209. + m_aurasStorage.insert(std::make_pair(index,aura));
  210. m_auraFlags |= (1 << index);
  211. }
  212.  
  213. void SpellAuraHolder::RemoveAura(SpellEffectIndex index)
  214. {
  215. - m_auras[index] = (Aura*)NULL;
  216. - m_auraFlags &= ~(1 << index);
  217. +
  218. + if (m_auraFlags & (1 << index))
  219. + {
  220. + m_auraFlags &= ~(1 << index);
  221. +
  222. + if (m_aurasStorage.empty())
  223. + return;
  224. +
  225. + AuraStorage::iterator itr = m_aurasStorage.find(index);
  226. + if (itr != m_aurasStorage.end())
  227. + m_aurasStorage.erase(itr);
  228. + }
  229. + else
  230. + {
  231. + m_auraFlags &= ~(1 << index);
  232. + }
  233. +}
  234. +
  235. +Aura* SpellAuraHolder::GetAuraByEffectIndex(SpellEffectIndex index)
  236. +{
  237. + if (m_auraFlags & (1 << index))
  238. + {
  239. + AuraStorage::iterator itr = m_aurasStorage.find(index);
  240. + if (itr != m_aurasStorage.end())
  241. + return &itr->second;
  242. + }
  243. + return (Aura*)NULL;
  244. }
  245.  
  246. -Aura* SpellAuraHolder::GetAuraByEffectIndex(SpellEffectIndex index) const
  247. +Aura const* SpellAuraHolder::GetAura(SpellEffectIndex index) const
  248. {
  249. if (m_auraFlags & (1 << index))
  250. {
  251. - if (m_auras[index] && !m_auras[index]->IsDeleted())
  252. - return m_auras[index];
  253. + AuraStorage::const_iterator itr = m_aurasStorage.find(index);
  254. + if (itr != m_aurasStorage.end())
  255. + return &itr->second;
  256. }
  257. return (Aura*)NULL;
  258. }
  259. @@ -9936,7 +9997,7 @@ void SpellAuraHolder::_AddSpellAuraHolder()
  260. uint8 flags = 0;
  261. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  262. {
  263. - if (m_auras[i])
  264. + if (GetAuraByEffectIndex(SpellEffectIndex(i)))
  265. flags |= (1 << i);
  266. }
  267. flags |= ((GetCasterGuid() == GetTarget()->GetObjectGuid()) ? AFLAG_NOT_CASTER : AFLAG_NONE) | ((GetSpellMaxDuration(m_spellProto) > 0 && !(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_NO_DURATION)) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE);
  268. @@ -10209,7 +10270,7 @@ void SpellAuraHolder::SetStackAmount(uint32 stackAmount)
  269.  
  270. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  271. {
  272. - if (Aura *aur = m_auras[i])
  273. + if (Aura* aur = GetAuraByEffectIndex(SpellEffectIndex(i)))
  274. {
  275. int32 bp = aur->GetBasePoints();
  276. int32 amount = m_stackAmount * caster->CalculateSpellDamage(target, m_spellProto, SpellEffectIndex(i), &bp);
  277. @@ -11333,10 +11394,6 @@ void SpellAuraHolder::HandleSpellSpecificBoostsForward(bool apply)
  278.  
  279. SpellAuraHolder::~SpellAuraHolder()
  280. {
  281. - // note: auras in delete list won't be affected since they clear themselves from holder when adding to deletedAuraslist
  282. - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  283. - if (Aura *aur = m_auras[i])
  284. - delete aur;
  285. }
  286.  
  287. void SpellAuraHolder::Update(uint32 diff)
  288. @@ -11375,7 +11432,7 @@ void SpellAuraHolder::Update(uint32 diff)
  289. }
  290.  
  291. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  292. - if (Aura *aura = m_auras[i])
  293. + if (Aura *aura = GetAuraByEffectIndex(SpellEffectIndex(i)))
  294. aura->UpdateAura(diff);
  295.  
  296. // Channeled aura required check distance from caster
  297. @@ -11435,7 +11492,7 @@ bool SpellAuraHolder::HasMechanic(uint32 mechanic) const
  298. return true;
  299.  
  300. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  301. - if (m_auras[i] && m_spellProto->EffectMechanic[i] == mechanic)
  302. + if (GetAura(SpellEffectIndex(i)) && m_spellProto->EffectMechanic[i] == mechanic)
  303. return true;
  304. return false;
  305. }
  306. @@ -11446,7 +11503,7 @@ bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const
  307. return true;
  308.  
  309. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  310. - if (m_auras[i] && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] -1)) & mechanicMask))
  311. + if (GetAura(SpellEffectIndex(i)) && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] -1)) & mechanicMask))
  312. return true;
  313. return false;
  314. }
  315. @@ -11454,7 +11511,7 @@ bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const
  316. bool SpellAuraHolder::IsPersistent() const
  317. {
  318. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  319. - if (Aura *aur = m_auras[i])
  320. + if (Aura const* aur = GetAura(SpellEffectIndex(i)))
  321. if (aur->IsPersistent())
  322. return true;
  323. return false;
  324. @@ -11463,7 +11520,7 @@ bool SpellAuraHolder::IsPersistent() const
  325. bool SpellAuraHolder::IsAreaAura() const
  326. {
  327. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  328. - if (Aura *aur = m_auras[i])
  329. + if (Aura const* aur = GetAura(SpellEffectIndex(i)))
  330. if (aur->IsAreaAura())
  331. return true;
  332. return false;
  333. @@ -11472,7 +11529,7 @@ bool SpellAuraHolder::IsAreaAura() const
  334. bool SpellAuraHolder::IsPositive() const
  335. {
  336. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  337. - if (Aura *aur = m_auras[i])
  338. + if (Aura const* aur = GetAura(SpellEffectIndex(i)))
  339. if (!aur->IsPositive())
  340. return false;
  341. return true;
  342. @@ -11481,7 +11538,7 @@ bool SpellAuraHolder::IsPositive() const
  343. bool SpellAuraHolder::IsEmptyHolder() const
  344. {
  345. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  346. - if (m_auras[i])
  347. + if (GetAura(SpellEffectIndex(i)))
  348. return false;
  349. return true;
  350. }
  351. diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h
  352. index 9f9d27a..0171cc8 100644
  353. --- a/src/game/SpellAuras.h
  354. +++ b/src/game/SpellAuras.h
  355. @@ -37,6 +37,10 @@ struct ProcTriggerSpell;
  356.  
  357. // forward decl
  358. class Aura;
  359. +class AreaAura;
  360. +class PersistentAreaAura;
  361. +
  362. +typedef std::map<SpellEffectIndex,Aura> AuraStorage;
  363.  
  364. // internal helper
  365. struct ReapplyAffectedPassiveAurasHelper;
  366. @@ -45,9 +49,11 @@ class MANGOS_DLL_SPEC SpellAuraHolder
  367. {
  368. public:
  369. SpellAuraHolder (SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem);
  370. - Aura* m_auras[MAX_EFFECT_INDEX];
  371.  
  372. - void AddAura(Aura *aura, SpellEffectIndex index);
  373. + Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit *target, Unit *caster, Item* castItem);
  374. + PersistentAreaAura* CreatePersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
  375. + AreaAura* CreateAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
  376. +
  377. void RemoveAura(SpellEffectIndex index);
  378. void ApplyAuraModifiers(bool apply, bool real = false);
  379. void _AddSpellAuraHolder();
  380. @@ -65,7 +71,8 @@ class MANGOS_DLL_SPEC SpellAuraHolder
  381. void SetStackAmount(uint32 stackAmount);
  382. bool ModStackAmount(int32 num); // return true if last charge dropped
  383.  
  384. - Aura* GetAuraByEffectIndex(SpellEffectIndex index) const;
  385. + Aura* GetAuraByEffectIndex(SpellEffectIndex index);
  386. + Aura const* GetAura(SpellEffectIndex index) const;
  387.  
  388. uint32 GetId() const { return m_spellProto->Id; }
  389. SpellEntry const* GetSpellProto() const { return m_spellProto; }
  390. @@ -161,7 +168,9 @@ class MANGOS_DLL_SPEC SpellAuraHolder
  391. bool HasMechanicMask(uint32 mechanicMask) const;
  392.  
  393. ~SpellAuraHolder();
  394. +
  395. private:
  396. + void AddAura(Aura aura, SpellEffectIndex index);
  397. Unit* m_target;
  398. ObjectGuid m_casterGuid;
  399. ObjectGuid m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
  400. @@ -181,6 +190,8 @@ class MANGOS_DLL_SPEC SpellAuraHolder
  401. AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
  402. DiminishingGroup m_AuraDRGroup:8; // Diminishing
  403.  
  404. + AuraStorage m_aurasStorage; // Auras storage
  405. +
  406. bool m_permanent:1;
  407. bool m_isPassive:1;
  408. bool m_isDeathPersist:1;
  409. @@ -207,8 +218,8 @@ typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);
  410.  
  411. class MANGOS_DLL_SPEC Aura
  412. {
  413. + friend class SpellAuraHolder;
  414. friend struct ReapplyAffectedPassiveAurasHelper;
  415. - MANGOS_DLL_SPEC friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem);
  416.  
  417. public:
  418. //aura handlers
  419. @@ -421,7 +432,7 @@ class MANGOS_DLL_SPEC Aura
  420. m_periodicTick = maxticks - GetAuraDuration() / m_modifier.periodictime;
  421. }
  422.  
  423. - bool IsPositive() { return m_positive; }
  424. + bool IsPositive() const { return m_positive; }
  425. bool IsPersistent() const { return m_isPersistent; }
  426. bool IsAreaAura() const { return m_isAreaAura; }
  427. bool IsPeriodic() const { return m_isPeriodic; }
  428. @@ -532,7 +543,7 @@ class MANGOS_DLL_SPEC PersistentAreaAura : public Aura
  429.  
  430. class MANGOS_DLL_SPEC SingleEnemyTargetAura : public Aura
  431. {
  432. - MANGOS_DLL_SPEC friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem);
  433. + friend class SpellAuraHolder;
  434.  
  435. public:
  436. ~SingleEnemyTargetAura();
  437. @@ -543,6 +554,5 @@ class MANGOS_DLL_SPEC SingleEnemyTargetAura : public Aura
  438. ObjectGuid m_castersTargetGuid;
  439. };
  440.  
  441. -MANGOS_DLL_SPEC Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
  442. MANGOS_DLL_SPEC SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem = NULL);
  443. #endif
  444. diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
  445. index c7af1d5..d9fa76e 100644
  446. --- a/src/game/SpellEffects.cpp
  447. +++ b/src/game/SpellEffects.cpp
  448. @@ -4485,7 +4485,7 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx)
  449.  
  450. DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell: Aura is: %u", m_spellInfo->EffectApplyAuraName[eff_idx]);
  451.  
  452. - Aura* aur = CreateAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], m_spellAuraHolder, unitTarget, caster, m_CastItem);
  453. + Aura* aur = m_spellAuraHolder->CreateAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], unitTarget, caster, m_CastItem);
  454.  
  455. // Now Reduce spell duration using data received at spell hit
  456. int32 duration = aur->GetAuraMaxDuration();
  457. @@ -4510,8 +4510,6 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx)
  458. m_spellAuraHolder->SetAuraMaxDuration(duration);
  459. m_spellAuraHolder->SetAuraDuration(duration);
  460. }
  461. -
  462. - m_spellAuraHolder->AddAura(aur, eff_idx);
  463. }
  464.  
  465. void Spell::EffectUnlearnSpecialization(SpellEffectIndex eff_idx)
  466. @@ -5341,8 +5339,7 @@ void Spell::EffectApplyAreaAura(SpellEffectIndex eff_idx)
  467. if (!unitTarget->isAlive())
  468. return;
  469.  
  470. - AreaAura* Aur = new AreaAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], m_spellAuraHolder, unitTarget, m_caster, m_CastItem);
  471. - m_spellAuraHolder->AddAura(Aur, eff_idx);
  472. + m_spellAuraHolder->CreateAreaAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], unitTarget, m_caster, m_CastItem);
  473. }
  474.  
  475. void Spell::EffectSummonType(SpellEffectIndex eff_idx)
  476. diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
  477. index 8299300..0a68592 100644
  478. --- a/src/game/Unit.cpp
  479. +++ b/src/game/Unit.cpp
  480. @@ -4420,14 +4420,14 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder)
  481. {
  482. for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
  483. {
  484. - if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)))
  485. + if (Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)))
  486. {
  487. // m_auraname can be modified to SPELL_AURA_NONE for area auras, use original
  488. AuraType aurNameReal = AuraType(aurSpellInfo->EffectApplyAuraName[i]);
  489.  
  490. if (aurNameReal == SPELL_AURA_PERIODIC_DAMAGE && aur->GetAuraDuration() > 0)
  491. {
  492. - if (Aura *existing = foundHolder->GetAuraByEffectIndex(SpellEffectIndex(i)))
  493. + if (Aura* existing = foundHolder->GetAuraByEffectIndex(SpellEffectIndex(i)))
  494. {
  495. int32 remainingTicks = existing->GetAuraMaxTicks() - existing->GetAuraTicks();
  496. int32 remainingDamage = existing->GetModifier()->m_amount * remainingTicks;
  497. @@ -4905,14 +4905,11 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, U
  498. int32 basePoints = aur->GetBasePoints();
  499. // construct the new aura for the attacker - will never return NULL, it's just a wrapper for
  500. // some different constructors
  501. - Aura * new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, stealer, this);
  502. + Aura* new_aur = new_holder->CreateAura(spellProto, aur->GetEffIndex(), &basePoints, stealer, this, NULL);
  503.  
  504. // set periodic to do at least one tick (for case when original aura has been at last tick preparing)
  505. int32 periodic = aur->GetModifier()->periodictime;
  506. new_aur->GetModifier()->periodictime = periodic < new_max_dur ? periodic : new_max_dur;
  507. -
  508. - // add the new aura to stealer
  509. - new_holder->AddAura(new_aur, new_aur->GetEffIndex());
  510. }
  511.  
  512. if (holder->GetSpellProto()->AttributesEx7 & SPELL_ATTR_EX7_DISPEL_CHARGES)
  513. @@ -7117,10 +7114,10 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u
  514. else if (spellProto->SpellFamilyFlags.test<CF_PRIEST_SHADOW_WORD_DEATH_TARGET>())
  515. {
  516. // Glyph of Shadow word: Death
  517. - if (SpellAuraHolder const* glyph = GetSpellAuraHolder(55682))
  518. + if (SpellAuraHolder* glyph = GetSpellAuraHolder(55682))
  519. {
  520. - Aura const* hpPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_0);
  521. - Aura const* dmPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_1);
  522. + Aura* hpPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_0);
  523. + Aura* dmPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_1);
  524. if (hpPct && dmPct && pVictim->GetHealth() * 100 <= pVictim->GetMaxHealth() * hpPct->GetModifier()->m_amount)
  525. DoneTotalMod *= (dmPct->GetModifier()->m_amount + 100.0f) / 100.0f;
  526. }
  527. @@ -12158,8 +12155,7 @@ void Unit::_AddAura(uint32 spellID, uint32 duration)
  528. spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA ||
  529. spellInfo->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA )
  530. {
  531. - Aura *aura = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, this);
  532. - holder->AddAura(aura, SpellEffectIndex(i));
  533. + Aura *aura = holder->CreateAura(spellInfo, SpellEffectIndex(i), NULL, this, NULL, NULL);
  534. holder->SetAuraDuration(duration);
  535. DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Manually adding aura of spell %u, index %u, duration %u ms", spellID, i, duration);
  536. }
  537. diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp
  538. index f474af5..989a410 100644
  539. --- a/src/game/UnitAuraProcHandler.cpp
  540. +++ b/src/game/UnitAuraProcHandler.cpp
  541. @@ -4671,8 +4671,7 @@ SpellAuraProcResult Unit::HandleMendingAuraProc( Unit* /*pVictim*/, uint32 /*dam
  542. continue;
  543.  
  544. int32 basePoints = aur->GetBasePoints();
  545. - Aura * new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, target, caster);
  546. - new_holder->AddAura(new_aur, new_aur->GetEffIndex());
  547. + new_holder->CreateAura(spellProto, aur->GetEffIndex(), &basePoints, target, caster, NULL);
  548. }
  549. new_holder->SetAuraCharges(jumps, false);
Add Comment
Please, Sign In to add comment