diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 656db9b7d..b35f722e9 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2143,7 +2143,7 @@ void SpellMgr::LoadSpellScriptTarget() QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM spell_script_target"); - if(!result) + if (!result) { barGoLink bar(1); @@ -2167,46 +2167,65 @@ void SpellMgr::LoadSpellScriptTarget() SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); - if(!spellProto) + if (!spellProto) { sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.",spellId,targetEntry); continue; } bool targetfound = false; - for(int i = 0; i <3; ++i) + for (int i = 0; i < 3; ++i) { - if( spellProto->EffectImplicitTargetA[i]==TARGET_SCRIPT || - spellProto->EffectImplicitTargetB[i]==TARGET_SCRIPT || - spellProto->EffectImplicitTargetA[i]==TARGET_SCRIPT_COORDINATES || - spellProto->EffectImplicitTargetB[i]==TARGET_SCRIPT_COORDINATES || - spellProto->EffectImplicitTargetA[i]==TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || - spellProto->EffectImplicitTargetB[i]==TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT ) + if( spellProto->EffectImplicitTargetA[i] == TARGET_SCRIPT || + spellProto->EffectImplicitTargetB[i] == TARGET_SCRIPT || + spellProto->EffectImplicitTargetA[i] == TARGET_SCRIPT_COORDINATES || + spellProto->EffectImplicitTargetB[i] == TARGET_SCRIPT_COORDINATES || + spellProto->EffectImplicitTargetA[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || + spellProto->EffectImplicitTargetB[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT ) { targetfound = true; break; } } - if(!targetfound) + if (!targetfound) { - sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not have any implicit target TARGET_SCRIPT(38) or TARGET_SCRIPT_COORDINATES (46) or TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT (40).",spellId,targetEntry); + sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not have any implicit target TARGET_SCRIPT(38) or TARGET_SCRIPT_COORDINATES (46) or TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT (40).", spellId, targetEntry); continue; } - if( type >= MAX_SPELL_TARGET_TYPE ) + if ( type >= MAX_SPELL_TARGET_TYPE ) { sLog.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.",type,targetEntry); continue; } - switch(type) + // More checks on TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT + bool ok = true; + for (int i = 0; i < 3; ++i) + { + if (spellProto->EffectImplicitTargetA[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || + spellProto->EffectImplicitTargetB[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT) + { + if (spellProto->RequiresSpellFocus) + { + sLog.outErrorDb("Table `spell_script_target`: spellId %u for TargetEnty %u of type TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT is wrong because spell has implicit ReqSpellFocus %u.", spellId, targetEntry, spellProto->RequiresSpellFocus); + ok = false; + break; + } + } + } + if (!ok) + continue; + + // Checks by target type + switch (type) { case SPELL_TARGET_TYPE_GAMEOBJECT: { - if( targetEntry==0 ) + if (!targetEntry) break; - if(!sGOStorage.LookupEntry(targetEntry)) + if (!sGOStorage.LookupEntry(targetEntry)) { sLog.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.",targetEntry); continue; @@ -2214,26 +2233,25 @@ void SpellMgr::LoadSpellScriptTarget() break; } default: - { - if( targetEntry==0 ) + if (!targetEntry) { sLog.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).",type); continue; } - if(!sCreatureStorage.LookupEntry(targetEntry)) + if (const CreatureInfo* cInfo = sCreatureStorage.LookupEntry(targetEntry)) + { + if (spellId == 30427 && !cInfo->SkinLootId) + { + sLog.outErrorDb("Table `spell_script_target` has creature %u as a target of spellid 30427, but this creature has no skinlootid. Gas extraction will not work!", cInfo->Entry); + continue; + } + } + else { sLog.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.",targetEntry); continue; } - const CreatureInfo* cInfo = sCreatureStorage.LookupEntry(targetEntry); - - if(spellId == 30427 && !cInfo->SkinLootId) - { - sLog.outErrorDb("Table `spell_script_target` has creature %u as a target of spellid 30427, but this creature has no skinlootid. Gas extraction will not work!", cInfo->Entry); - continue; - } break; - } } mSpellScriptTarget.insert(SpellScriptTarget::value_type(spellId,SpellTargetEntry(SpellTargetType(type),targetEntry))); @@ -2243,31 +2261,6 @@ void SpellMgr::LoadSpellScriptTarget() delete result; - // Check all spells - /* Disabled (lot errors at this moment) - for(uint32 i = 1; i < sSpellStore.nCount; ++i) - { - SpellEntry const * spellInfo = sSpellStore.LookupEntry(i); - if(!spellInfo) - continue; - - bool found = false; - for(int j=0; j<3; ++j) - { - if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT ) - { - SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(spellInfo->Id); - SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(spellInfo->Id); - if(lower==upper) - { - sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = %u (TARGET_SCRIPT), but does not have record in `spell_script_target`",spellInfo->Id,TARGET_SCRIPT); - break; // effects of spell - } - } - } - } - */ - sLog.outString(); sLog.outString(">> Loaded %u Spell Script Targets", count); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e87514580..9113686f3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8636" + #define REVISION_NR "8637" #endif // __REVISION_NR_H__