*fixed crashpoint in spell difficulty handler

*added more checks at loading
*better searcher

--HG--
branch : trunk
This commit is contained in:
Rat
2010-04-22 19:39:19 +02:00
parent 00c2674553
commit 144dbd11dd
2 changed files with 24 additions and 14 deletions
+11 -5
View File
@@ -404,16 +404,22 @@ void LoadDBCStores(const std::string& dataPath)
SpellDifficultyEntry const *spellDiff = sSpellDifficultyStore.LookupEntry(i); SpellDifficultyEntry const *spellDiff = sSpellDifficultyStore.LookupEntry(i);
if (!spellDiff) if (!spellDiff)
continue; continue;
SpellDifficultyEntry newEntry;
for (int x = 0; x < MAX_DIFFICULTY; ++x) for (int x = 0; x < MAX_DIFFICULTY; ++x)
{ {
if (spellDiff->SpellID[x] <= 0 || !sSpellStore.LookupEntry(spellDiff->SpellID[x])) if (spellDiff->SpellID[x] <= 0 || !sSpellStore.LookupEntry(spellDiff->SpellID[x]))
{ {
if(spellDiff->SpellID[x] > 0)//don't drop error if spell is <= 0, not all modes have spells and there are unknown negative values if (spellDiff->SpellID[x] > 0)//don't show error if spell is <= 0, not all modes have spells and there are unknown negative values
sLog.outDebug("spelldifficulty_dbc: spell %i at field id:%u at spellid%i does not exist in SpellStore (spell.dbc), skipped loading", spellDiff->SpellID[x], spellDiff->ID, x); sLog.outErrorDb("spelldifficulty_dbc: spell %i at field id:%u at spellid%i does not exist in SpellStore (spell.dbc), loaded as 0", spellDiff->SpellID[x], spellDiff->ID, x);
newEntry.SpellID[x] = 0;//spell was <= 0 or invalid, set to 0
} else newEntry.SpellID[x] = spellDiff->SpellID[x];
}
if (newEntry.SpellID[0] <= 0 || newEntry.SpellID[1] <= 0)//id0-1 must be always set!
continue; continue;
}
spellmgr.SetSpellDifficultyId(uint32(spellDiff->SpellID[x]), spellDiff->ID); for (int x = 0; x < MAX_DIFFICULTY; ++x)
} spellmgr.SetSpellDifficultyId(uint32(newEntry.SpellID[x]), spellDiff->ID);
} }
// create talent spells set // create talent spells set
+6 -2
View File
@@ -1055,7 +1055,7 @@ class SpellMgr
SpellEntry const* newSpell = sSpellStore.LookupEntry(SpellDiff->SpellID[mode]); SpellEntry const* newSpell = sSpellStore.LookupEntry(SpellDiff->SpellID[mode]);
if (!newSpell) if (!newSpell)
{ {
sLog.outDebug("GetSpellForDifficultyFromSpell: spell %u not found in spell, this should never happen.", newSpell->Id);//alerady checked at startup sLog.outDebug("GetSpellForDifficultyFromSpell: spell %u not found in SpellStore. Check spelldifficulty_dbc!", SpellDiff->SpellID[mode]);
return spell; return spell;
} }
sLog.outDebug("GetSpellForDifficultyFromSpell: spellid for spell %u in mode %u is %u ", spell->Id, mode, newSpell->Id); sLog.outDebug("GetSpellForDifficultyFromSpell: spellid for spell %u in mode %u is %u ", spell->Id, mode, newSpell->Id);
@@ -1320,7 +1320,11 @@ class SpellMgr
return false; return false;
return true; return true;
} }
uint32 GetSpellDifficultyId(uint32 spellId) { return mSpellDifficultySearcherMap[spellId] ? mSpellDifficultySearcherMap[spellId] : 0; } uint32 GetSpellDifficultyId(uint32 spellId)
{
SpellDifficultySearcherMap::const_iterator i = mSpellDifficultySearcherMap.find(spellId);
return i == mSpellDifficultySearcherMap.end() ? 0 : (*i).second;
}
void SetSpellDifficultyId(uint32 spellId, uint32 id) { mSpellDifficultySearcherMap[spellId] = id; } void SetSpellDifficultyId(uint32 spellId, uint32 id) { mSpellDifficultySearcherMap[spellId] = id; }
const SpellsRequiringSpellMap GetSpellsRequiringSpell() const SpellsRequiringSpellMap GetSpellsRequiringSpell()