aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/SpellMgr.cpp')
-rw-r--r--src/server/game/Spells/SpellMgr.cpp212
1 files changed, 85 insertions, 127 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 84cbbe90b7e..0ab8b919664 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -68,24 +68,24 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
case SPELLFAMILY_GENERIC:
{
// Entrapment -- 135373
- if (spellproto->SpellIconID == 20 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39588)
+ if (spellproto->SpellIconID == 20 && spellproto->GetSpellVisual() == 39588)
return DIMINISHING_ROOT;
// Intimidation -- 24394
- if (spellproto->SpellIconID == 166 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 2816)
+ if (spellproto->SpellIconID == 166 && spellproto->GetSpellVisual() == 2816)
return DIMINISHING_STUN;
// Pulverize (Primal Earth Elemental) -- 118345
- if (spellproto->SpellIconID == 4507 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39877)
+ if (spellproto->SpellIconID == 4507 && spellproto->GetSpellVisual() == 39877)
return DIMINISHING_STUN;
// Static Charge (Capacitor Totem) -- 118905
- if (spellproto->SpellIconID == 54 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 24442)
+ if (spellproto->SpellIconID == 54 && spellproto->GetSpellVisual() == 24442)
return DIMINISHING_STUN;
// Remorseless Winter -- 115001
- if (spellproto->SpellIconID == 5744 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 23514)
+ if (spellproto->SpellIconID == 5744 && spellproto->GetSpellVisual() == 23514)
return DIMINISHING_STUN;
// Gorefiend's Grasp -- 108199
- if (spellproto->SpellIconID == 5743 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 28937)
+ if (spellproto->SpellIconID == 5743 && spellproto->GetSpellVisual() == 28937)
return DIMINISHING_AOE_KNOCKBACK;
break;
}
@@ -150,7 +150,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
if (spellproto->SpellFamilyFlags[1] & 0x8000000)
return DIMINISHING_INCAPACITATE;
// Blood Horror -- 137143, no flags (17986)
- if (spellproto->SpellIconID == 6447 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 26758)
+ if (spellproto->SpellIconID == 6447 && spellproto->GetSpellVisual() == 26758)
return DIMINISHING_INCAPACITATE;
// Fear -- 118699
@@ -194,11 +194,11 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
if (spellproto->SpellFamilyFlags[0] & 0x2000)
return DIMINISHING_STUN;
// Rake -- 163505 -- no flags on the stun, 20490
- if (spellproto->SpellIconID == 494 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 38283)
+ if (spellproto->SpellIconID == 494 && spellproto->GetSpellVisual() == 38283)
return DIMINISHING_STUN;
// Incapacitating Roar -- 99, no flags on the stun, 14
- if (spellproto->SpellIconID == 960 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 38528)
+ if (spellproto->SpellIconID == 960 && spellproto->GetSpellVisual() == 38528)
return DIMINISHING_INCAPACITATE;
// Cyclone -- 33786
@@ -220,7 +220,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
if (spellproto->SpellFamilyFlags[0] & 0x200)
return DIMINISHING_ROOT;
// Mass Entanglement -- 102359, no flags on the root, 13535
- if (spellproto->SpellIconID == 5782 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 38269)
+ if (spellproto->SpellIconID == 5782 && spellproto->GetSpellVisual() == 38269)
return DIMINISHING_ROOT;
// Faerie Fire -- 770, 20 seconds in PvP (6.0)
@@ -259,14 +259,14 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
// return DIMINISHING_AOE_KNOCKBACK;
// Charge (Tenacity pet) -- 53148, no flags (5526)
- if (spellproto->SpellIconID == 1559 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39480)
+ if (spellproto->SpellIconID == 1559 && spellproto->GetSpellVisual() == 39480)
return DIMINISHING_ROOT;
// Narrow Escape -- 136634, no flags (17964)
if (spellproto->SpellIconID == 3342 && spellproto->SchoolMask == 8)
return DIMINISHING_ROOT;
// Binding Shot -- 117526, no flags (15581)
- if (spellproto->SpellIconID == 4612 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 6859)
+ if (spellproto->SpellIconID == 4612 && spellproto->GetSpellVisual() == 6859)
return DIMINISHING_STUN;
// Freezing Trap -- 3355
@@ -313,7 +313,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
if (spellproto->SpellFamilyFlags[2] & 0x4000)
return DIMINISHING_ROOT;
// Frost Shock (with Frozen Power) -- 63685, no flags (6918)
- if (spellproto->SpellIconID == 193 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39876)
+ if (spellproto->SpellIconID == 193 && spellproto->GetSpellVisual() == 39876)
return DIMINISHING_ROOT;
break;
}
@@ -324,31 +324,31 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
return DIMINISHING_SILENCE;
// Chains of Ice (with Chilblains) -- 96294, no flags (13020)
- if (spellproto->SpellIconID == 180 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 20135)
+ if (spellproto->SpellIconID == 180 && spellproto->GetSpellVisual() == 20135)
return DIMINISHING_ROOT;
// Asphyxiate -- 108194
if (spellproto->SpellFamilyFlags[2] & 0x100000)
return DIMINISHING_STUN;
// Gnaw (Ghoul) -- 91800, no flags (12511)
- if (spellproto->SpellIconID == 3010 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 38760)
+ if (spellproto->SpellIconID == 3010 && spellproto->GetSpellVisual() == 38760)
return DIMINISHING_STUN;
// Monstrous Blow (Ghoul w/ Dark Transformation active) -- 91797, no flags (12510)
- if (spellproto->SpellIconID == 15 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 38761)
+ if (spellproto->SpellIconID == 15 && spellproto->GetSpellVisual() == 38761)
return DIMINISHING_STUN;
break;
}
case SPELLFAMILY_PRIEST:
{
// Glyph of Mind Blast -- 87194, no flags (10092)
- if (spellproto->SpellIconID == 2114 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 38927)
+ if (spellproto->SpellIconID == 2114 && spellproto->GetSpellVisual() == 38927)
return DIMINISHING_ROOT;
// Void Tendrils -- 114404, no flags (15067)
- if (spellproto->SpellIconID == 5816 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 25199)
+ if (spellproto->SpellIconID == 5816 && spellproto->GetSpellVisual() == 25199)
return DIMINISHING_ROOT;
// Dominate Mind -- 605
- if (spellproto->SpellFamilyFlags[0] & 0x20000 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39068)
+ if (spellproto->SpellFamilyFlags[0] & 0x20000 && spellproto->GetSpellVisual() == 39068)
return DIMINISHING_INCAPACITATE;
// Holy Word: Chastise -- 88625
if (spellproto->SpellFamilyFlags[2] & 0x20)
@@ -369,7 +369,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
case SPELLFAMILY_MONK:
{
// Disable -- 116706, no flags (15483)
- if (spellproto->SpellIconID == 23 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39984)
+ if (spellproto->SpellIconID == 23 && spellproto->GetSpellVisual() == 39984)
return DIMINISHING_ROOT;
// Charging Ox Wave -- 119392
@@ -383,13 +383,13 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto)
return DIMINISHING_STUN;
// Glyph of Breath of Fire -- 123393, no flags (16504)
- if (spellproto->SpellIconID == 15 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 25408)
+ if (spellproto->SpellIconID == 15 && spellproto->GetSpellVisual() == 25408)
return DIMINISHING_INCAPACITATE;
// Paralysis -- 115078
if (spellproto->SpellFamilyFlags[2] & 0x800000)
return DIMINISHING_INCAPACITATE;
// Ring of Peace -- 137460, no flags (18006)
- if (spellproto->SpellIconID == 7195 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 39999)
+ if (spellproto->SpellIconID == 7195 && spellproto->GetSpellVisual() == 39999)
return DIMINISHING_INCAPACITATE;
break;
}
@@ -443,7 +443,7 @@ int32 GetDiminishingReturnsLimitDuration(SpellInfo const* spellproto)
case SPELLFAMILY_HUNTER:
{
// Binding Shot - 3 seconds in PvP (6.0)
- if (spellproto->SpellIconID == 4612 && spellproto->GetSpellVisual(DIFFICULTY_NONE) == 6859)
+ if (spellproto->SpellIconID == 4612 && spellproto->GetSpellVisual() == 6859)
return 3 * IN_MILLISECONDS;
// Wyvern Sting - 6 seconds in PvP (6.0)
if (spellproto->SpellFamilyFlags[1] & 0x1000)
@@ -1260,113 +1260,71 @@ void SpellMgr::LoadSpellRanks()
{
uint32 oldMSTime = getMSTime();
- // 0 1 2
- QueryResult result = WorldDatabase.Query("SELECT first_spell_id, spell_id, rank from spell_ranks ORDER BY first_spell_id, rank");
-
- if (!result)
+ std::map<uint32 /*spell*/, uint32 /*next*/> chains;
+ std::set<uint32> hasPrev;
+ for (SkillLineAbilityEntry const* skillAbility : sSkillLineAbilityStore)
{
- TC_LOG_INFO("server.loading", ">> Loaded 0 spell rank records. DB table `spell_ranks` is empty.");
- return;
- }
-
- uint32 count = 0;
- bool finished = false;
-
- do
- {
- // spellid, rank
- std::list < std::pair < int32, int32 > > rankChain;
- int32 currentSpell = -1;
- int32 lastSpell = -1;
-
- // fill one chain
- while (currentSpell == lastSpell && !finished)
- {
- Field* fields = result->Fetch();
-
- currentSpell = fields[0].GetUInt32();
- if (lastSpell == -1)
- lastSpell = currentSpell;
- uint32 spell_id = fields[1].GetUInt32();
- uint32 rank = fields[2].GetUInt8();
-
- // don't drop the row if we're moving to the next rank
- if (currentSpell == lastSpell)
- {
- rankChain.push_back(std::make_pair(spell_id, rank));
- if (!result->NextRow())
- finished = true;
- }
- else
- break;
- }
- // check if chain is made with valid first spell
- SpellInfo const* first = GetSpellInfo(lastSpell);
- if (!first)
- {
- TC_LOG_ERROR("sql.sql", "The spell rank identifier(first_spell_id) %u listed in `spell_ranks` does not exist!", lastSpell);
- continue;
- }
- // check if chain is long enough
- if (rankChain.size() < 2)
- {
- TC_LOG_ERROR("sql.sql", "There is only 1 spell rank for identifier(first_spell_id) %u in `spell_ranks`, entry is not needed!", lastSpell);
+ if (!skillAbility->SupercedesSpell)
continue;
- }
- int32 curRank = 0;
- bool valid = true;
- // check spells in chain
- for (std::list<std::pair<int32, int32> >::iterator itr = rankChain.begin(); itr!= rankChain.end(); ++itr)
- {
- SpellInfo const* spell = GetSpellInfo(itr->first);
- if (!spell)
- {
- TC_LOG_ERROR("sql.sql", "The spell %u (rank %u) listed in `spell_ranks` for chain %u does not exist!", itr->first, itr->second, lastSpell);
- valid = false;
- break;
- }
- ++curRank;
- if (itr->second != curRank)
- {
- TC_LOG_ERROR("sql.sql", "The spell %u (rank %u) listed in `spell_ranks` for chain %u does not have a proper rank value (should be %u)!", itr->first, itr->second, lastSpell, curRank);
- valid = false;
- break;
- }
- }
- if (!valid)
+
+ if (!GetSpellInfo(skillAbility->SupercedesSpell) || !GetSpellInfo(skillAbility->SpellID))
continue;
- int32 prevRank = 0;
- // insert the chain
- std::list<std::pair<int32, int32> >::iterator itr = rankChain.begin();
- do
- {
- ++count;
- int32 addedSpell = itr->first;
- if (mSpellInfoMap[addedSpell]->ChainEntry)
- TC_LOG_ERROR("sql.sql", "The spell %u (rank: %u, first: %u) listed in `spell_ranks` already has ChainEntry from dbc.", addedSpell, itr->second, lastSpell);
+ chains[skillAbility->SupercedesSpell] = skillAbility->SpellID;
+ hasPrev.insert(skillAbility->SpellID);
+ }
- mSpellChains[addedSpell].first = GetSpellInfo(lastSpell);
- mSpellChains[addedSpell].last = GetSpellInfo(rankChain.back().first);
- mSpellChains[addedSpell].rank = itr->second;
- mSpellChains[addedSpell].prev = GetSpellInfo(prevRank);
- mSpellInfoMap[addedSpell]->ChainEntry = &mSpellChains[addedSpell];
- prevRank = addedSpell;
- ++itr;
+ // each key in chains that isn't present in hasPrev is a first rank
+ for (auto itr = chains.begin(); itr != chains.end(); ++itr)
+ {
+ if (hasPrev.count(itr->first))
+ continue;
- if (itr == rankChain.end())
+ SpellInfo const* first = AssertSpellInfo(itr->first);
+ SpellInfo const* next = AssertSpellInfo(itr->second);
+
+ mSpellChains[itr->first].first = first;
+ mSpellChains[itr->first].prev = nullptr;
+ mSpellChains[itr->first].next = next;
+ mSpellChains[itr->first].last = next;
+ mSpellChains[itr->first].rank = 1;
+ mSpellInfoMap[itr->first]->ChainEntry = &mSpellChains[itr->first];
+
+ mSpellChains[itr->second].first = first;
+ mSpellChains[itr->second].prev = first;
+ mSpellChains[itr->second].next = nullptr;
+ mSpellChains[itr->second].last = next;
+ mSpellChains[itr->second].rank = 2;
+ mSpellInfoMap[itr->second]->ChainEntry = &mSpellChains[itr->second];
+
+ uint8 rank = 3;
+ auto nextItr = chains.find(itr->second);
+ while (nextItr != chains.end())
+ {
+ SpellInfo const* prev = AssertSpellInfo(nextItr->first); // already checked in previous iteration (or above, in case this is the first one)
+ SpellInfo const* last = AssertSpellInfo(nextItr->second);
+
+ mSpellChains[nextItr->first].next = last;
+
+ mSpellChains[nextItr->second].first = first;
+ mSpellChains[nextItr->second].prev = prev;
+ mSpellChains[nextItr->second].next = nullptr;
+ mSpellChains[nextItr->second].last = last;
+ mSpellChains[nextItr->second].rank = rank++;
+ mSpellInfoMap[nextItr->second]->ChainEntry = &mSpellChains[nextItr->second];
+
+ // fill 'last'
+ do
{
- mSpellChains[addedSpell].next = NULL;
- break;
- }
- else
- mSpellChains[addedSpell].next = GetSpellInfo(itr->first);
+ mSpellChains[prev->Id].last = last;
+ prev = mSpellChains[prev->Id].prev;
+ } while (prev);
+
+ nextItr = chains.find(nextItr->second);
}
- while (true);
}
- while (!finished);
- TC_LOG_INFO("server.loading", ">> Loaded %u spell rank records in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded %u spell rank records in %u ms", uint32(mSpellChains.size()), GetMSTimeDiffToNow(oldMSTime));
}
void SpellMgr::LoadSpellRequired()
@@ -1450,8 +1408,8 @@ void SpellMgr::LoadSpellLearnSkills()
if (effect && effect->Effect == SPELL_EFFECT_SKILL)
{
SpellLearnSkillNode dbc_node;
- dbc_node.skill = effect->MiscValue;
- dbc_node.step = effect->CalcValue();
+ dbc_node.skill = uint16(effect->MiscValue);
+ dbc_node.step = uint16(effect->CalcValue());
if (dbc_node.skill != SKILL_RIDING)
dbc_node.value = 1;
else
@@ -1677,7 +1635,7 @@ void SpellMgr::LoadSpellTargetPositions()
// target facing is in degrees for 6484 & 9268... (blizz sucks)
if (effect->PositionFacing > 2 * M_PI)
- st.target_Orientation = effect->PositionFacing * M_PI / 180;
+ st.target_Orientation = effect->PositionFacing * float(M_PI) / 180;
else
st.target_Orientation = effect->PositionFacing;
@@ -2375,7 +2333,7 @@ void SpellMgr::LoadPetLevelupSpellMap()
if (skillLine->SkillLine != creatureFamily->SkillLine[j])
continue;
- if (skillLine->AquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
+ if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
continue;
SpellInfo const* spell = GetSpellInfo(skillLine->SpellID);
@@ -2936,7 +2894,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
if (!spellInfo->_IsPositiveEffect(EFFECT_2, false))
spellInfo->AttributesCu |= SPELL_ATTR0_CU_NEGATIVE_EFF2;
- if (spellInfo->GetSpellVisual(DIFFICULTY_NONE) == 3879)
+ if (spellInfo->GetSpellVisual() == 3879)
spellInfo->AttributesCu |= SPELL_ATTR0_CU_CONE_BACK;
if (talentSpells.count(spellInfo->Id))
@@ -3475,7 +3433,7 @@ void SpellMgr::LoadSpellInfoCorrections()
spellInfo->AuraInterruptFlags |= AURA_INTERRUPT_FLAG_CAST | AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_JUMP;
break;
case 5420: // Tree of Life (Passive)
- spellInfo->Stances = UI64LIT(1) << (FORM_TREE - 1);
+ spellInfo->Stances = UI64LIT(1) << (FORM_TREE_OF_LIFE - 1);
break;
case 49376: // Feral Charge (Cat Form)
spellInfo->AttributesEx3 &= ~SPELL_ATTR3_CANT_TRIGGER_PROC;
@@ -3552,7 +3510,7 @@ void SpellMgr::LoadPetFamilySpellsStore()
if (skillLine->SkillLine != cFamily->SkillLine[0] && skillLine->SkillLine != cFamily->SkillLine[1])
continue;
- if (skillLine->AquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
+ if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
continue;
sPetFamilySpellsStore[i].insert(spellInfo->ID);