[7376] Allow store in spell_area.aura_spell negative values for "not has aura" requirement.

Also
* Allow have in aura_spell spells with SPELL_AURA_PHASE in first effect.
* Allow negative aura_spell chaining in spell_area table.
* Better check at loading duplicate data (by requiremnt set) in spell_area table.
This commit is contained in:
VladimirMangos 2009-03-04 01:22:03 +03:00
parent 0d96837d48
commit fee3278e57
7 changed files with 103 additions and 51 deletions

View file

@ -2387,7 +2387,7 @@ void SpellMgr::LoadSpellAreas()
spellArea.questStart = fields[2].GetUInt32();
spellArea.questStartCanActive = fields[3].GetBool();
spellArea.questEnd = fields[4].GetUInt32();
spellArea.auraSpell = fields[5].GetUInt32();
spellArea.auraSpell = fields[5].GetInt32();
spellArea.raceMask = fields[6].GetUInt32();
spellArea.gender = Gender(fields[7].GetUInt8());
spellArea.autocast = fields[8].GetBool();
@ -2398,10 +2398,35 @@ void SpellMgr::LoadSpellAreas()
continue;
}
if(mSpellAreaForAuraMap.find(spellArea.spellId)!=mSpellAreaForAuraMap.end())
{
sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that already listed in table itself", spell,spellArea.auraSpell);
continue;
bool ok = true;
SpellAreaMapBounds sa_bounds = GetSpellAreaMapBounds(spellArea.spellId);
for(SpellAreaMap::const_iterator itr = sa_bounds.first; itr != sa_bounds.second; ++itr)
{
if(spellArea.spellId && itr->second.spellId && spellArea.spellId != itr->second.spellId)
continue;
if(spellArea.areaId && itr->second.areaId && spellArea.areaId!= itr->second.areaId)
continue;
if(spellArea.questStart && itr->second.questStart && spellArea.questStart!= itr->second.questStart)
continue;
if(spellArea.auraSpell && itr->second.auraSpell && spellArea.auraSpell!= itr->second.auraSpell)
continue;
if(spellArea.raceMask && itr->second.raceMask && (spellArea.raceMask & itr->second.raceMask)==0)
continue;
if(spellArea.gender != GENDER_NONE && itr->second.gender != GENDER_NONE && spellArea.gender!= itr->second.gender)
continue;
// duplicate by requirements
ok =false;
break;
}
if(!ok)
{
sLog.outErrorDb("Spell %u listed in `spell_area` already listed with similar requirements.", spell);
continue;
}
}
if(spellArea.areaId && !GetAreaEntryByAreaID(spellArea.areaId))
@ -2433,33 +2458,33 @@ void SpellMgr::LoadSpellAreas()
if(spellArea.auraSpell)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellArea.auraSpell);
SpellEntry const* spellInfo = sSpellStore.LookupEntry(abs(spellArea.auraSpell));
if(!spellInfo)
{
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell,spellArea.auraSpell);
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell,abs(spellArea.auraSpell));
continue;
}
if(spellInfo->EffectApplyAuraName[0]!=SPELL_AURA_DUMMY)
if(spellInfo->EffectApplyAuraName[0]!=SPELL_AURA_DUMMY && spellInfo->EffectApplyAuraName[0]!=SPELL_AURA_PHASE)
{
sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy aura in effect 0", spell,spellArea.auraSpell);
sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy/phase aura in effect 0", spell,abs(spellArea.auraSpell));
continue;
}
if(spellArea.auraSpell==spellArea.spellId)
if(abs(spellArea.auraSpell)==spellArea.spellId)
{
sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell,spellArea.auraSpell);
sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell,abs(spellArea.auraSpell));
continue;
}
// not allow autocast chains by auraSpell field
if(spellArea.autocast)
// not allow autocast chains by auraSpell field (but allow use as alternative if not present)
if(spellArea.autocast && spellArea.auraSpell > 0)
{
bool chain = false;
SpellAreaForAuraMapBounds saBound = GetSpellAreaForAuraMapBounds(spellArea.spellId);
for(SpellAreaForAuraMap::const_iterator itr = saBound.first; itr != saBound.second; ++itr)
{
if(itr->second->autocast)
if(itr->second->autocast && itr->second->auraSpell > 0)
{
chain = true;
break;
@ -2475,7 +2500,7 @@ void SpellMgr::LoadSpellAreas()
SpellAreaMapBounds saBound2 = GetSpellAreaMapBounds(spellArea.auraSpell);
for(SpellAreaMap::const_iterator itr2 = saBound2.first; itr2 != saBound2.second; ++itr2)
{
if(itr2->second.autocast && itr2->second.auraSpell)
if(itr2->second.autocast && itr2->second.auraSpell > 0)
{
chain = true;
break;
@ -2523,7 +2548,7 @@ void SpellMgr::LoadSpellAreas()
// for search at aura apply
if(spellArea.auraSpell)
mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(spellArea.auraSpell,sa));
mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell),sa));
++count;
} while( result->NextRow() );
@ -2810,8 +2835,14 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
if(auraSpell)
{
// not have expected aura
if(!player || !player->HasAura(auraSpell,0))
if(!player)
return false;
if(auraSpell > 0)
// have expected aura
return player->HasAura(auraSpell,0);
else
// not have expected aura
return !player->HasAura(-auraSpell,0);
}
return true;