[8251] Store in some DB tables only data for first rank. Author: VladimirMangos

* Allow add to DB data only for first rank in table `mangos_spell_bonus_data` and `mangos_spell_proc_event`.
    * Copy data for other ranks for speedup use at loading for this data and data from `spell_proc_item_enchant`.

--HG--
branch : trunk
This commit is contained in:
megamage committed 2009-07-31 10:21:57 +08:00
1 parent 4abac06cf0
commit 2bddcc4303
7 files changed
+533 -145

No files matched your search

+103 -53
View File
@@ -1204,6 +1204,13 @@ bool SpellMgr::IsAffectedByMod(SpellEntry const *spellInfo, SpellModifier *mod)
return false;
}
struct DoSpellProcEvent
{
DoSpellProcEvent(SpellProcEventEntry const& _spe) : spe(_spe) {}
void operator() (uint32 spell_id) { spellmgr.mSpellProcEventMap[spell_id] = spe; }
SpellProcEventEntry const& spe;
};
void SpellMgr::LoadSpellProcEvents()
{
mSpellProcEventMap.clear(); // need for reload case
@@ -1238,6 +1245,15 @@ void SpellMgr::LoadSpellProcEvents()
continue;
}
uint32 first_id = GetFirstSpellInChain(entry);
if ( first_id != entry )
{
sLog.outErrorDb("Spell %u listed in `spell_proc_event` is not first rank (%u) in chain", entry, first_id);
// prevent loading since it won't have an effect anyway
continue;
}
SpellProcEventEntry spe;
spe.schoolMask = fields[1].GetUInt32();
@@ -1253,6 +1269,10 @@ void SpellMgr::LoadSpellProcEvents()
mSpellProcEventMap[entry] = spe;
// also add to high ranks
DoSpellProcEvent worker(spe);
doForHighRanks(entry,worker);
if (spell->procFlags==0)
{
if (spe.procFlags == 0)
@@ -1274,6 +1294,74 @@ void SpellMgr::LoadSpellProcEvents()
sLog.outString( ">> Loaded %u extra spell proc event conditions", count );
}
struct DoSpellProcItemEnchant
{
DoSpellProcItemEnchant(SpellEnchantProcEntry const &_spe) : spe(_spe) {}
void operator() (uint32 spell_id) { spellmgr.mSpellEnchantProcEventMap[spell_id] = spe; }
SpellEnchantProcEntry const &spe;
};
void SpellMgr::LoadSpellEnchantProcData()
{
mSpellEnchantProcEventMap.clear(); // need for reload case
uint32 count = 0;
// 0 1 2 3
QueryResult *result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data");
if( !result )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.outString( ">> Loaded %u spell enchant proc event conditions", count );
return;
}
barGoLink bar( result->GetRowCount() );
do
{
Field *fields = result->Fetch();
bar.step();
uint32 entry = fields[0].GetUInt32();
SpellItemEnchantmentEntry const *ench = sSpellItemEnchantmentStore.LookupEntry(entry);
if (!ench)
{
sLog.outErrorDb("Enchancment %u listed in `spell_enchant_proc_data` does not exist", entry);
continue;
}
SpellEnchantProcEntry spe;
spe.customChance = fields[1].GetUInt32();
spe.PPMChance = fields[2].GetFloat();
spe.procEx = fields[3].GetUInt32();
// also add to high ranks
DoSpellProcItemEnchant worker(spe);
doForThisAndHighRanks(entry,worker);
++count;
} while( result->NextRow() );
delete result;
sLog.outString( ">> Loaded %u enchant proc data definitions", count);
}
struct DoSpellBonusess
{
DoSpellBonusess(SpellBonusEntry const& _spellBonus) : spellBonus(_spellBonus) {}
void operator() (uint32 spell_id) { spellmgr.mSpellBonusMap[spell_id] = spellBonus; }
SpellBonusEntry const& spellBonus;
};
void SpellMgr::LoadSpellBonusess()
{
mSpellBonusMap.clear(); // need for reload case
@@ -1296,13 +1384,22 @@ void SpellMgr::LoadSpellBonusess()
bar.step();
uint32 entry = fields[0].GetUInt32();
const SpellEntry *spell = sSpellStore.LookupEntry(entry);
SpellEntry const* spell = sSpellStore.LookupEntry(entry);
if (!spell)
{
sLog.outErrorDb("Spell %u listed in `spell_bonus_data` does not exist", entry);
continue;
}
uint32 first_id = GetFirstSpellInChain(entry);
if ( first_id != entry )
{
sLog.outErrorDb("Spell %u listed in `spell_bonus_data` is not first rank (%u) in chain", entry, first_id);
// prevent loading since it won't have an effect anyway
continue;
}
SpellBonusEntry sbe;
sbe.direct_damage = fields[1].GetFloat();
@@ -1312,6 +1409,11 @@ void SpellMgr::LoadSpellBonusess()
mSpellBonusMap[entry] = sbe;
++count;
// also add to high ranks
DoSpellBonusess worker(sbe);
doForHighRanks(entry,worker);
} while( result->NextRow() );
delete result;
@@ -3321,58 +3423,6 @@ bool IsDispelableBySpell(SpellEntry const * dispelSpell, uint32 spellId, bool de
return def;
}
void SpellMgr::LoadSpellEnchantProcData()
{
mSpellEnchantProcEventMap.clear(); // need for reload case
uint32 count = 0;
// 0 1 2 3
QueryResult *result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data");
if( !result )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.outString( ">> Loaded %u spell enchant proc event conditions", count );
return;
}
barGoLink bar( result->GetRowCount() );
do
{
Field *fields = result->Fetch();
bar.step();
uint32 enchantId = fields[0].GetUInt32();
SpellItemEnchantmentEntry const *ench = sSpellItemEnchantmentStore.LookupEntry(enchantId);
if (!ench)
{
sLog.outErrorDb("Enchancment %u listed in `spell_enchant_proc_data` does not exist", enchantId);
continue;
}
SpellEnchantProcEntry spe;
spe.customChance = fields[1].GetUInt32();
spe.PPMChance = fields[2].GetFloat();
spe.procEx = fields[3].GetUInt32();
mSpellEnchantProcEventMap[enchantId] = spe;
++count;
} while( result->NextRow() );
delete result;
sLog.outString( ">> Loaded %u enchant proc data definitions", count);
}
void SpellMgr::LoadSpellRequired()
{
mSpellsReqSpell.clear(); // need for reload case