[10423] Load most spell chains data from SkillLineAbility.dbc

* Output error for redundent data in table
* Drop detected data from `spell_chain`
This commit is contained in:
VladimirMangos 2010-08-30 07:28:36 +04:00
parent 63ac861fc9
commit a62d9e2817
6 changed files with 266 additions and 1100 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,75 @@
ALTER TABLE db_version CHANGE COLUMN required_10422_01_mangos_spell_proc_event required_10423_01_mangos_spell_chain bit;
DELETE FROM spell_chain WHERE spell_id IN (
100, 6178, 11578, 78, 284, 285, 1608, 11564, 11565, 11566, 11567, 25286, 29707,
30324, 47449, 47450, 12294, 21551, 21552, 21553, 25248, 30330, 47485, 47486,
772, 6546, 6547, 6548, 11572, 11573, 11574, 25208, 46845, 47465, 6343, 8198,
8204, 8205, 11580, 11581, 25264, 47501, 47502, 53, 2589, 2590, 2591, 8721, 11279,
11280, 11281, 25300, 26863, 48656, 48657, 5277, 26669, 1966, 6768, 8637, 11303,
25302, 27448, 48658, 48659, 1752, 1757, 1758, 1759, 1760, 8621, 11293, 11294,
26861, 26862, 48637, 48638, 2983, 8696, 11305, 16511, 17347, 17348, 26864, 48660,
6770, 2070, 11297, 51724, 1856, 1857, 26889, 5211, 6798, 8983, 5487, 9634, 1082,
3029, 5201, 9849, 9850, 27000, 48569, 48570, 8998, 9000, 9892, 31709, 27004,
48575, 1850, 9821, 33357, 99, 1735, 9490, 9747, 9898, 26998, 48559, 48560, 22568,
22827, 22828, 22829, 31018, 24248, 48576, 48577, 33943, 40120, 33745, 48567,
48568, 22570, 49802, 33878, 33986, 33987, 48563, 48564, 33876, 33982, 33983,
48565, 48566, 6807, 6808, 6809, 8972, 9745, 9880, 9881, 26996, 48479, 48480,
9005, 9823, 9827, 27006, 49803, 1822, 1823, 1824, 9904, 27003, 48573, 48574,
6785, 6787, 9866, 9867, 27005, 48578, 48579, 1079, 9492, 9493, 9752, 9894, 9896,
27008, 49799, 49800, 5221, 6800, 8992, 9829, 9830, 27001, 27002, 48571, 48572,
779, 780, 769, 9754, 9908, 26997, 48561, 48562, 5217, 6793, 9845, 9846, 50212,
50213, 7294, 10298, 10299, 10300, 10301, 27150, 54043, 6307, 7804, 7805, 11766,
11767, 27268, 47982, 2947, 8316, 8317, 11770, 11771, 27269, 47983, 3110, 7799,
7800, 7801, 7802, 11762, 11763, 27267, 47964, 19505, 19731, 19734, 19736, 27276,
27277, 48011, 54049, 54050, 54051, 54052, 54053, 19244, 19647, 17253, 17255,
17256, 17257, 17258, 17259, 17260, 17261, 27050, 52473, 52474, 17767, 17850,
17851, 17852, 17853, 17854, 27272, 47987, 47988, 7812, 19438, 19440, 19441,
19442, 19443, 27273, 47985, 47986, 17735, 17750, 17751, 17752, 27271, 33701,
47989, 47990, 3716, 7809, 7810, 7811, 11774, 11775, 27270, 47984, 7814, 7815,
7816, 11778, 11779, 11780, 27274, 47991, 47992, 6360, 7813, 11784, 11785, 27275,
24450, 24452, 24453, 59881, 59882, 59883, 59884, 59885, 59886, 50256, 53526,
53528, 53529, 53532, 53533, 35290, 35291, 35292, 35293, 35294, 35295, 24423,
24577, 24578, 24579, 27051, 55487, 49966, 49967, 49968, 49969, 49970, 49971,
49972, 49973, 49974, 52475, 52476, 50498, 53578, 53579, 53580, 53581, 53582,
16827, 16828, 16829, 16830, 16831, 16832, 3010, 3009, 27049, 52471, 52472, 24640,
24583, 24586, 24587, 27060, 55728, 8676, 8724, 8725, 11267, 11268, 11269, 27441,
48689, 48690, 48691, 26679, 48673, 48674, 32645, 32684, 57992, 57993, 2098, 6760,
6761, 6762, 8623, 8624, 11299, 11300, 31016, 26865, 48667, 48668, 703, 8631,
8632, 8633, 11289, 11290, 26839, 26884, 48675, 48676, 408, 8643, 1329, 34411,
34412, 34413, 48663, 48666, 1943, 8639, 8640, 11273, 11274, 11275, 26867, 48671,
48672, 5171, 6774, 6673, 5242, 6192, 11549, 11550, 11551, 25289, 2048, 47436,
845, 7369, 11608, 11609, 20569, 25231, 47519, 47520, 469, 47439, 47440, 1160,
6190, 11554, 11555, 11556, 25202, 25203, 47437, 5308, 20658, 20660, 20661, 20662,
25234, 25236, 47470, 47471, 1464, 8820, 11604, 11605, 25241, 25242, 47474, 47475,
20243, 30016, 30022, 47497, 47498, 6572, 6574, 7379, 11600, 11601, 25288, 25269,
30357, 57823, 23922, 23923, 23924, 23925, 25258, 30356, 47487, 47488, 465, 10290,
643, 10291, 1032, 10292, 10293, 27149, 48941, 48942, 19891, 19899, 19900, 27153,
48947, 19888, 19897, 19898, 27152, 48945, 19876, 19895, 19896, 27151, 48943,
2649, 14916, 14917, 14918, 14919, 14920, 14921, 27047, 61676, 633, 2800, 10310,
27154, 48788, 50271, 53571, 53572, 53573, 53574, 53575, 50541, 53537, 53538,
53540, 53542, 53543, 24844, 25008, 25009, 25010, 25011, 25012, 33698, 33699,
33700, 47993, 30213, 30219, 30223, 47994, 30151, 30194, 30198, 47996, 34889,
35323, 55482, 55483, 55484, 55485, 50274, 53593, 53594, 53596, 53597, 53598,
35387, 35389, 35392, 55555, 55556, 55557, 48721, 49939, 49940, 49941, 45902,
49926, 49927, 49928, 49929, 49930, 55050, 55258, 55259, 55260, 55261, 55262,
49143, 51416, 51417, 51418, 51419, 55268, 45477, 49896, 49903, 49904, 49909,
49020, 51423, 51424, 51425, 49158, 51325, 51326, 51327, 51328, 43265, 49936,
49937, 49938, 47541, 49895, 49894, 49893, 49892, 49998, 49999, 45463, 49923,
49924, 45462, 49917, 49918, 49919, 49920, 49921, 55090, 55265, 55270, 55271,
54644, 55488, 55489, 55490, 55491, 55492, 54680, 55495, 55496, 55497, 55498,
55499, 55749, 55750, 55751, 55752, 55753, 55754, 56626, 56627, 56628, 56629,
56630, 56631, 58604, 58607, 58608, 58609, 58610, 58611, 61193, 61194, 61195,
61196, 61197, 61198, 2259, 3101, 3464, 11611, 28596, 51304, 2018, 3100, 3538,
9785, 29844, 51300, 2550, 3102, 3413, 18260, 33359, 51296, 7411, 7412, 7413,
13920, 28029, 51313, 4036, 4037, 4038, 12656, 30350, 51306, 3273, 3274, 7924,
10846, 27028, 45542, 7620, 7731, 7732, 18248, 33095, 51294, 2366, 2368, 3570,
11993, 28695, 50300, 45357, 45358, 45359, 45360, 45361, 45363, 25229, 25230,
28894, 28895, 28897, 51311, 2108, 3104, 3811, 10662, 32549, 51302, 2575, 2576,
3564, 10248, 29354, 50310, 33388, 33391, 34090, 34091, 8613, 8617, 8618, 10768,
32678, 50305, 3908, 3909, 3910, 12180, 26790, 51309, 55428, 55480, 55500, 55501,
55502, 55503, 53120, 53121, 53122, 53123, 53124, 53040, 53125, 53662, 53663,
53664, 53665, 53666, 54424, 57564, 57565, 57566, 57567, 21084, 20154, 50518,
53558, 53559, 53560, 53561, 53562, 24604, 64491, 64492, 64493, 64494, 64495,
50519, 53564, 53565, 53566, 53567, 53568, 50245, 53544, 53545, 53546, 53547,
53548
);

View file

@ -91,6 +91,7 @@ pkgdata_DATA = \
10416_01_mangos_spell_proc_event.sql \
10419_01_mangos_spell_chain.sql \
10422_01_mangos_spell_proc_event.sql \
10423_01_mangos_spell_chain.sql \
README
## Additional files to include when running 'make dist'
@ -162,4 +163,5 @@ EXTRA_DIST = \
10416_01_mangos_spell_proc_event.sql \
10419_01_mangos_spell_chain.sql \
10422_01_mangos_spell_proc_event.sql \
10423_01_mangos_spell_chain.sql \
README

View file

@ -2307,6 +2307,73 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo,
return NULL;
}
typedef UNORDERED_MAP<uint32,uint32> AbilitySpellPrevMap;
static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellPrevMap const& prevRanks, uint32 spell_id, uint32 prev_id, uint32 deep = 30)
{
// spell already listed in chains store
SpellChainMap::const_iterator chain_itr = chainMap.find(spell_id);
if (chain_itr != chainMap.end())
{
ASSERT(chain_itr->second.prev == prev_id && "LoadSpellChains_AbilityHelper: Conflicting data in talents or spell abilities dbc");
return;
}
// prev rank listed in main chain table (can fill correct data directly)
SpellChainMap::const_iterator prev_chain_itr = chainMap.find(prev_id);
if (prev_chain_itr != chainMap.end())
{
SpellChainNode node;
node.prev = prev_id;
node.first = prev_chain_itr->second.first;
node.rank = prev_chain_itr->second.rank+1;
node.req = 0;
chainMap[spell_id] = node;
return;
}
// prev spell not listed in prev ranks store, so it first rank
AbilitySpellPrevMap::const_iterator prev_itr = prevRanks.find(prev_id);
if (prev_itr == prevRanks.end())
{
SpellChainNode prev_node;
prev_node.prev = 0;
prev_node.first = prev_id;
prev_node.rank = 1;
prev_node.req = 0;
chainMap[prev_id] = prev_node;
SpellChainNode node;
node.prev = prev_id;
node.first = prev_id;
node.rank = 2;
node.req = 0;
chainMap[spell_id] = node;
return;
}
if (deep == 0)
{
ASSERT(false && "LoadSpellChains_AbilityHelper: Infinity cycle in spell ability data");
return;
}
// prev rank listed, so process it first
LoadSpellChains_AbilityHelper(chainMap, prevRanks, prev_id, prev_itr->second, deep-1);
// prev rank must be listed now
prev_chain_itr = chainMap.find(prev_id);
if (prev_chain_itr == chainMap.end())
return;
SpellChainNode node;
node.prev = prev_id;
node.first = prev_chain_itr->second.first;
node.rank = prev_chain_itr->second.rank+1;
node.req = 0;
chainMap[spell_id] = node;
}
void SpellMgr::LoadSpellChains()
{
mSpellChains.clear(); // need for reload case
@ -2345,6 +2412,83 @@ void SpellMgr::LoadSpellChains()
}
}
// load known data from spell abilities
{
// we can calculate ranks only after full data generation
AbilitySpellPrevMap prevRanks;
for(SkillLineAbilityMap::const_iterator ab_itr = mSkillLineAbilityMap.begin(); ab_itr != mSkillLineAbilityMap.end(); ++ab_itr)
{
uint32 spell_id = ab_itr->first;
// skip GM/test/internal spells.begin Its not have ranks anyway
if (ab_itr->second->skillId == SKILL_INTERNAL)
continue;
// some forward spells not exist and can be ignored (some outdated data)
SpellEntry const* spell_entry = sSpellStore.LookupEntry(spell_id);
if (!spell_entry) // no cases
continue;
// ignore spell without forwards (non ranked or missing info in skill abilities)
uint32 forward_id = ab_itr->second->forward_spellid;
if (!forward_id)
continue;
// some forward spells not exist and can be ignored (some outdated data)
SpellEntry const* forward_entry = sSpellStore.LookupEntry(forward_id);
if (!forward_entry)
continue;
// some forward spells still exist but excluded from real use as ranks and not listed in skill abilities now
SkillLineAbilityMap::const_iterator forward_ab_low = mSkillLineAbilityMap.lower_bound(forward_id);
SkillLineAbilityMap::const_iterator forward_ab_up = mSkillLineAbilityMap.upper_bound(forward_id);
if (forward_ab_low == forward_ab_up)
continue;
// spell already listed in chains store
SpellChainMap::const_iterator chain_itr = mSpellChains.find(forward_id);
if (chain_itr != mSpellChains.end())
{
ASSERT(chain_itr->second.prev == spell_id && "Conflicting data in talents or spell abilities dbc");
continue;
}
// spell already listed in prev ranks store
AbilitySpellPrevMap::const_iterator prev_itr = prevRanks.find(forward_id);
if (prev_itr != prevRanks.end())
{
ASSERT(prev_itr->second == spell_id && "Conflicting data in talents or spell abilities dbc");
continue;
}
// prev rank listed in main chain table (can fill correct data directly)
SpellChainMap::const_iterator prev_chain_itr = mSpellChains.find(spell_id);
if (prev_chain_itr != mSpellChains.end())
{
SpellChainNode node;
node.prev = spell_id;
node.first = prev_chain_itr->second.first;
node.rank = prev_chain_itr->second.rank+1;
node.req = 0;
mSpellChains[forward_id] = node;
continue;
}
// need temporary store for later rank calculation
prevRanks[forward_id] = spell_id;
}
while (!prevRanks.empty())
{
uint32 spell_id = prevRanks.begin()->first;
uint32 prev_id = prevRanks.begin()->second;
prevRanks.erase(prevRanks.begin());
LoadSpellChains_AbilityHelper(mSpellChains, prevRanks, spell_id, prev_id);
}
}
// load custom case
QueryResult *result = WorldDatabase.Query("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain");
if (!result)
@ -2358,7 +2502,9 @@ void SpellMgr::LoadSpellChains()
return;
}
uint32 count = 0;
uint32 dbc_count = mSpellChains.size();
uint32 new_count = 0;
uint32 req_count = 0;
barGoLink bar( (int)result->GetRowCount() );
do
@ -2380,9 +2526,41 @@ void SpellMgr::LoadSpellChains()
continue;
}
if (mSpellChains.find(spell_id) != mSpellChains.end())
SpellChainMap::iterator chain_itr = mSpellChains.find(spell_id);
if (chain_itr != mSpellChains.end())
{
sLog.outErrorDb("Spell %u already added (talent?) and non need in `spell_chain`",spell_id);
if (chain_itr->second.rank != node.rank)
{
sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected rank %u by DBC data.",
spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.rank);
continue;
}
if (chain_itr->second.prev != node.prev)
{
sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected prev %u by DBC data.",
spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.prev);
continue;
}
if (chain_itr->second.first != node.first)
{
sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected first %u by DBC data.",
spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.first);
continue;
}
// update req field by table data
if (node.req)
{
chain_itr->second.req = node.req;
++req_count;
continue;
}
// in other case redundant
sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) already added (talent or spell ability with forward) and non need in `spell_chain`",
spell_id,node.prev,node.first,node.rank,node.req);
continue;
}
@ -2417,7 +2595,7 @@ void SpellMgr::LoadSpellChains()
continue;
}
// talents not required data in spell chain for work, but must be checked if present for intergrity
// talents not required data in spell chain for work, but must be checked if present for integrity
if(TalentSpellPos const* pos = GetTalentSpellPos(spell_id))
{
if(node.rank!=pos->rank+1)
@ -2454,7 +2632,7 @@ void SpellMgr::LoadSpellChains()
mSpellChains[spell_id] = node;
++count;
++new_count;
} while( result->NextRow() );
delete result;
@ -2535,7 +2713,7 @@ void SpellMgr::LoadSpellChains()
}
sLog.outString();
sLog.outString( ">> Loaded %u spell chain records", count );
sLog.outString( ">> Loaded %u spell chain records (%u from DBC data with %u req field updates, and %u loaded from table)", dbc_count+new_count, dbc_count, req_count, new_count);
}
void SpellMgr::LoadSpellLearnSkills()

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10422"
#define REVISION_NR "10423"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10332_02_characters_pet_aura"
#define REVISION_DB_MANGOS "required_10422_01_mangos_spell_proc_event"
#define REVISION_DB_MANGOS "required_10423_01_mangos_spell_chain"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__