aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-02-21 13:08:33 +0100
committerShauren <shauren.trinity@gmail.com>2015-02-21 13:08:33 +0100
commit68fceee10e6eede180ca444a2a7f2af2fe4ba5dc (patch)
tree5797248d23c302502f304c1f3614d8aaa6f08172 /src/server/game/Spells
parent6ff1764084d9234f35609a227567875cd95561a1 (diff)
Core/Spells: Removed leftovers of old cooldown handling
* Use ItemEffect.db2 data directly instead of copying it to another structure
Diffstat (limited to 'src/server/game/Spells')
-rw-r--r--src/server/game/Spells/Spell.cpp28
-rw-r--r--src/server/game/Spells/SpellEffects.cpp4
-rw-r--r--src/server/game/Spells/SpellHistory.cpp10
-rw-r--r--src/server/game/Spells/SpellHistory.h3
4 files changed, 24 insertions, 21 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 3279e524b0c..61315062b10 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4398,12 +4398,12 @@ void Spell::TakeCastItem()
bool expendable = false;
bool withoutCharges = false;
- for (uint8 i = 0; i < proto->Effects.size(); ++i)
+ for (uint8 i = 0; i < proto->Effects.size() && i < 5; ++i)
{
// item has limited charges
- if (proto->Effects[i].Charges)
+ if (proto->Effects[i]->Charges)
{
- if (proto->Effects[i].Charges < 0)
+ if (proto->Effects[i]->Charges < 0)
expendable = true;
int32 charges = m_CastItem->GetSpellCharges(i);
@@ -4640,11 +4640,11 @@ void Spell::TakeReagents()
// if CastItem is also spell reagent
if (castItemTemplate && castItemTemplate->GetId() == itemid)
{
- for (uint8 s = 0; s < castItemTemplate->Effects.size(); ++s)
+ for (uint8 s = 0; s < castItemTemplate->Effects.size() && s < 5; ++s)
{
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);
- if (castItemTemplate->Effects[s].Charges < 0 && abs(charges) < 2)
+ if (castItemTemplate->Effects[s]->Charges < 0 && abs(charges) < 2)
{
++itemcount;
break;
@@ -6014,8 +6014,8 @@ SpellCastResult Spell::CheckItems()
if (!proto)
return SPELL_FAILED_ITEM_NOT_READY;
- for (uint8 i = 0; i < proto->Effects.size(); ++i)
- if (proto->Effects[i].Charges)
+ for (uint8 i = 0; i < proto->Effects.size() && i < 5; ++i)
+ if (proto->Effects[i]->Charges)
if (m_CastItem->GetSpellCharges(i) == 0)
return SPELL_FAILED_NO_CHARGES_REMAIN;
@@ -6115,11 +6115,11 @@ SpellCastResult Spell::CheckItems()
ItemTemplate const* proto = m_CastItem->GetTemplate();
if (!proto)
return SPELL_FAILED_ITEM_NOT_READY;
- for (uint8 s = 0; s < proto->Effects.size(); ++s)
+ for (uint8 s = 0; s < proto->Effects.size() && s < 5; ++s)
{
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);
- if (proto->Effects[s].Charges < 0 && abs(charges) < 2)
+ if (proto->Effects[s]->Charges < 0 && abs(charges) < 2)
{
++itemcount;
break;
@@ -6220,9 +6220,9 @@ SpellCastResult Spell::CheckItems()
ItemTemplate const* proto = targetItem->GetTemplate();
for (uint8 e = 0; e < proto->Effects.size(); ++e)
{
- if (proto->Effects[e].SpellID && (
- proto->Effects[e].Trigger == ITEM_SPELLTRIGGER_ON_USE ||
- proto->Effects[e].Trigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE))
+ if (proto->Effects[e]->SpellID && (
+ proto->Effects[e]->Trigger == ITEM_SPELLTRIGGER_ON_USE ||
+ proto->Effects[e]->Trigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE))
{
isItemUsable = true;
break;
@@ -6399,8 +6399,8 @@ SpellCastResult Spell::CheckItems()
if (Item* pitem = player->GetItemByEntry(item_id))
{
- for (uint8 x = 0; x < pProto->Effects.size(); ++x)
- if (pProto->Effects[x].Charges != 0 && pitem->GetSpellCharges(x) == pProto->Effects[x].Charges)
+ for (uint8 x = 0; x < pProto->Effects.size() && x < 5; ++x)
+ if (pProto->Effects[x]->Charges != 0 && pitem->GetSpellCharges(x) == pProto->Effects[x]->Charges)
return SPELL_FAILED_ITEM_AT_MAX_CHARGES;
}
break;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index c08b3e6ec23..db332f2fc49 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -5655,8 +5655,8 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/)
if (Item* pItem = player->GetItemByEntry(item_id))
{
- for (size_t x = 0; x < pProto->Effects.size(); ++x)
- pItem->SetSpellCharges(x, pProto->Effects[x].Charges);
+ for (size_t x = 0; x < pProto->Effects.size() && x < 5; ++x)
+ pItem->SetSpellCharges(x, pProto->Effects[x]->Charges);
pItem->SetState(ITEM_CHANGED, player);
}
}
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index 4060122630d..4ad1311c10b 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -366,13 +366,13 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel
{
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId))
{
- for (uint8 idx = 0; idx < proto->Effects.size(); ++idx)
+ for (ItemEffectEntry const* itemEffect : proto->Effects)
{
- if (uint32(proto->Effects[idx].SpellID) == spellInfo->Id)
+ if (itemEffect->SpellID == spellInfo->Id)
{
- categoryId = proto->Effects[idx].Category;
- cooldown = proto->Effects[idx].Cooldown;
- categoryCooldown = proto->Effects[idx].CategoryCooldown;
+ categoryId = itemEffect->Category;
+ cooldown = itemEffect->Cooldown;
+ categoryCooldown = itemEffect->CategoryCooldown;
break;
}
}
diff --git a/src/server/game/Spells/SpellHistory.h b/src/server/game/Spells/SpellHistory.h
index 38ae922750c..a55f57aa9f4 100644
--- a/src/server/game/Spells/SpellHistory.h
+++ b/src/server/game/Spells/SpellHistory.h
@@ -107,7 +107,10 @@ public:
for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end();)
{
if (predicate(itr))
+ {
+ resetCooldowns.push_back(int32(itr->first));
ResetCooldown(itr, false);
+ }
else
++itr;
}