*fixed crashpoint in spell difficulty handler
*added more checks at loading *better searcher --HG-- branch : trunk
This commit is contained in:
+13
-7
@@ -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;
|
||||||
for(int x = 0; x < MAX_DIFFICULTY; ++x)
|
|
||||||
|
SpellDifficultyEntry newEntry;
|
||||||
|
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);
|
||||||
continue;
|
newEntry.SpellID[x] = 0;//spell was <= 0 or invalid, set to 0
|
||||||
}
|
} else newEntry.SpellID[x] = spellDiff->SpellID[x];
|
||||||
spellmgr.SetSpellDifficultyId(uint32(spellDiff->SpellID[x]), spellDiff->ID);
|
|
||||||
}
|
}
|
||||||
|
if (newEntry.SpellID[0] <= 0 || newEntry.SpellID[1] <= 0)//id0-1 must be always set!
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int x = 0; x < MAX_DIFFICULTY; ++x)
|
||||||
|
spellmgr.SetSpellDifficultyId(uint32(newEntry.SpellID[x]), spellDiff->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create talent spells set
|
// create talent spells set
|
||||||
|
|||||||
+11
-7
@@ -1022,17 +1022,17 @@ class SpellMgr
|
|||||||
SpellEntry const* GetSpellForDifficultyFromSpell(SpellEntry const* spell, Unit* Caster)
|
SpellEntry const* GetSpellForDifficultyFromSpell(SpellEntry const* spell, Unit* Caster)
|
||||||
{
|
{
|
||||||
//spell never can be NULL in this case!
|
//spell never can be NULL in this case!
|
||||||
if(!Caster->ToCreature() || !Caster->ToCreature()->GetMap() || !Caster->ToCreature()->GetMap()->IsDungeon())
|
if (!Caster->ToCreature() || !Caster->ToCreature()->GetMap() || !Caster->ToCreature()->GetMap()->IsDungeon())
|
||||||
return spell;
|
return spell;
|
||||||
|
|
||||||
uint32 mode = uint32(Caster->ToCreature()->GetMap()->GetSpawnMode());
|
uint32 mode = uint32(Caster->ToCreature()->GetMap()->GetSpawnMode());
|
||||||
if(mode >= MAX_DIFFICULTY)
|
if (mode >= MAX_DIFFICULTY)
|
||||||
{
|
{
|
||||||
sLog.outError("GetSpellForDifficultyFromSpell: Incorrect Difficulty for spell %u.", spell->Id);
|
sLog.outError("GetSpellForDifficultyFromSpell: Incorrect Difficulty for spell %u.", spell->Id);
|
||||||
return spell;//return source spell
|
return spell;//return source spell
|
||||||
}
|
}
|
||||||
uint32 SpellDiffId = GetSpellDifficultyId(spell->Id);
|
uint32 SpellDiffId = GetSpellDifficultyId(spell->Id);
|
||||||
if(!SpellDiffId)
|
if (!SpellDiffId)
|
||||||
return spell;//return source spell, it has only REGULAR_DIFFICULTY
|
return spell;//return source spell, it has only REGULAR_DIFFICULTY
|
||||||
|
|
||||||
SpellDifficultyEntry const *SpellDiff = sSpellDifficultyStore.LookupEntry(SpellDiffId);
|
SpellDifficultyEntry const *SpellDiff = sSpellDifficultyStore.LookupEntry(SpellDiffId);
|
||||||
@@ -1041,13 +1041,13 @@ class SpellMgr
|
|||||||
sLog.outDebug("GetSpellForDifficultyFromSpell: SpellDifficultyEntry not found for spell %u. This Should never happen.", spell->Id);
|
sLog.outDebug("GetSpellForDifficultyFromSpell: SpellDifficultyEntry not found for spell %u. This Should never happen.", spell->Id);
|
||||||
return spell;//return source spell
|
return spell;//return source spell
|
||||||
}
|
}
|
||||||
if(SpellDiff->SpellID[mode] <= 0 && mode > DUNGEON_DIFFICULTY_HEROIC)
|
if (SpellDiff->SpellID[mode] <= 0 && mode > DUNGEON_DIFFICULTY_HEROIC)
|
||||||
{
|
{
|
||||||
uint8 baseMode = mode;
|
uint8 baseMode = mode;
|
||||||
mode -= 2;
|
mode -= 2;
|
||||||
sLog.outDebug("GetSpellForDifficultyFromSpell: spell %u mode %u spell is NULL, using mode %u", spell->Id, baseMode, mode);
|
sLog.outDebug("GetSpellForDifficultyFromSpell: spell %u mode %u spell is NULL, using mode %u", spell->Id, baseMode, mode);
|
||||||
}
|
}
|
||||||
if(SpellDiff->SpellID[mode] <= 0)
|
if (SpellDiff->SpellID[mode] <= 0)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("GetSpellForDifficultyFromSpell: spell %u mode %u spell is 0. Check spelldifficulty_dbc!", spell->Id, mode);
|
sLog.outErrorDb("GetSpellForDifficultyFromSpell: spell %u mode %u spell is 0. Check spelldifficulty_dbc!", spell->Id, mode);
|
||||||
return spell;
|
return spell;
|
||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user