mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[8637] Added special check in load time for TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT, code cleanup.
- Added check for presence of implicit spell focus for TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT - Avoid double creature lookup in loading code - Code style cleanup - Old commented code part removed Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
parent
901eea0813
commit
ed0b01c65c
2 changed files with 45 additions and 52 deletions
|
|
@ -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<GameObjectInfo>(targetEntry))
|
||||
if (!sGOStorage.LookupEntry<GameObjectInfo>(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<CreatureInfo>(targetEntry))
|
||||
if (const CreatureInfo* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(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<CreatureInfo>(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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8636"
|
||||
#define REVISION_NR "8637"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue