[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

@ -22,7 +22,7 @@
DROP TABLE IF EXISTS `db_version`; DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` ( CREATE TABLE `db_version` (
`version` varchar(120) default NULL, `version` varchar(120) default NULL,
`required_7369_01_mangos_quest_template` bit(1) default NULL `required_7376_01_mangos_spell_area` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
-- --
@ -13295,7 +13295,7 @@ CREATE TABLE `spell_area` (
`quest_start` mediumint(8) unsigned NOT NULL default '0', `quest_start` mediumint(8) unsigned NOT NULL default '0',
`quest_start_active` tinyint(1) unsigned NOT NULL default '0', `quest_start_active` tinyint(1) unsigned NOT NULL default '0',
`quest_end` mediumint(8) unsigned NOT NULL default '0', `quest_end` mediumint(8) unsigned NOT NULL default '0',
`aura_spell` mediumint(8) unsigned NOT NULL default '0', `aura_spell` mediumint(8) NOT NULL default '0',
`racemask` mediumint(8) unsigned NOT NULL default '0', `racemask` mediumint(8) unsigned NOT NULL default '0',
`gender` tinyint(1) unsigned NOT NULL default '2', `gender` tinyint(1) unsigned NOT NULL default '2',
`autocast` tinyint(1) unsigned NOT NULL default '0', `autocast` tinyint(1) unsigned NOT NULL default '0',

View file

@ -0,0 +1,4 @@
ALTER TABLE db_version CHANGE COLUMN required_7369_01_mangos_quest_template required_7376_01_mangos_spell_area bit;
ALTER TABLE spell_area
CHANGE COLUMN `aura_spell` `aura_spell` mediumint(8) NOT NULL default '0';

View file

@ -189,6 +189,7 @@ pkgdata_DATA = \
7332_01_mangos_command.sql \ 7332_01_mangos_command.sql \
7349_01_mangos_spell_area.sql \ 7349_01_mangos_spell_area.sql \
7369_01_mangos_quest_template.sql \ 7369_01_mangos_quest_template.sql \
7376_01_mangos_spell_area.sql \
README README
## Additional files to include when running 'make dist' ## Additional files to include when running 'make dist'
@ -358,4 +359,5 @@ EXTRA_DIST = \
7332_01_mangos_command.sql \ 7332_01_mangos_command.sql \
7349_01_mangos_spell_area.sql \ 7349_01_mangos_spell_area.sql \
7369_01_mangos_quest_template.sql \ 7369_01_mangos_quest_template.sql \
7376_01_mangos_spell_area.sql \
README README

View file

@ -2073,22 +2073,6 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
return; return;
} }
// some auras applied at aura apply
if(GetEffIndex()==0 && m_target->GetTypeId()==TYPEID_PLAYER)
{
SpellAreaForAreaMapBounds saBounds = spellmgr.GetSpellAreaForAuraMapBounds(GetId());
if(saBounds.first != saBounds.second)
{
uint32 zone = m_target->GetZoneId();
uint32 area = m_target->GetAreaId();
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
if(itr->second->autocast && itr->second->IsFitToRequirements((Player*)m_target,zone,area))
if( !m_target->HasAura(itr->second->spellId,0) )
m_target->CastSpell(m_target,itr->second->spellId,true);
}
}
} }
// AT REMOVE // AT REMOVE
else else
@ -2177,21 +2161,6 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
} }
} }
// some auras remove at aura remove
if(GetEffIndex()==0 && m_target->GetTypeId()==TYPEID_PLAYER)
{
SpellAreaForAreaMapBounds saBounds = spellmgr.GetSpellAreaForAuraMapBounds(GetId());
if(saBounds.first != saBounds.second)
{
uint32 zone = m_target->GetZoneId();
uint32 area = m_target->GetAreaId();
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
if(!itr->second->IsFitToRequirements((Player*)m_target,zone,area))
m_target->RemoveAurasDueToSpell(itr->second->spellId);
}
}
} }
// AT APPLY & REMOVE // AT APPLY & REMOVE
@ -2416,6 +2385,29 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
m_target->RemovePetAura(petSpell); m_target->RemovePetAura(petSpell);
return; return;
} }
if(GetEffIndex()==0 && m_target->GetTypeId()==TYPEID_PLAYER)
{
SpellAreaForAreaMapBounds saBounds = spellmgr.GetSpellAreaForAuraMapBounds(GetId());
if(saBounds.first != saBounds.second)
{
uint32 zone = m_target->GetZoneId();
uint32 area = m_target->GetAreaId();
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
{
// some auras remove at aura remove
if(!itr->second->IsFitToRequirements((Player*)m_target,zone,area))
m_target->RemoveAurasDueToSpell(itr->second->spellId);
// some auras applied at aura apply
else if(itr->second->autocast)
{
if( !m_target->HasAura(itr->second->spellId,0) )
m_target->CastSpell(m_target,itr->second->spellId,true);
}
}
}
}
} }
void Aura::HandleAuraMounted(bool apply, bool Real) void Aura::HandleAuraMounted(bool apply, bool Real)
@ -6688,6 +6680,29 @@ void Aura::HandlePhase(bool apply, bool Real)
m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false); m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false);
((Player*)m_target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL); ((Player*)m_target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL);
if(GetEffIndex()==0)
{
SpellAreaForAreaMapBounds saBounds = spellmgr.GetSpellAreaForAuraMapBounds(GetId());
if(saBounds.first != saBounds.second)
{
uint32 zone = m_target->GetZoneId();
uint32 area = m_target->GetAreaId();
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
{
// some auras remove at aura remove
if(!itr->second->IsFitToRequirements((Player*)m_target,zone,area))
m_target->RemoveAurasDueToSpell(itr->second->spellId);
// some auras applied at aura apply
else if(itr->second->autocast)
{
if( !m_target->HasAura(itr->second->spellId,0) )
m_target->CastSpell(m_target,itr->second->spellId,true);
}
}
}
}
} }
else else
m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false); m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false);

View file

@ -2387,7 +2387,7 @@ void SpellMgr::LoadSpellAreas()
spellArea.questStart = fields[2].GetUInt32(); spellArea.questStart = fields[2].GetUInt32();
spellArea.questStartCanActive = fields[3].GetBool(); spellArea.questStartCanActive = fields[3].GetBool();
spellArea.questEnd = fields[4].GetUInt32(); spellArea.questEnd = fields[4].GetUInt32();
spellArea.auraSpell = fields[5].GetUInt32(); spellArea.auraSpell = fields[5].GetInt32();
spellArea.raceMask = fields[6].GetUInt32(); spellArea.raceMask = fields[6].GetUInt32();
spellArea.gender = Gender(fields[7].GetUInt8()); spellArea.gender = Gender(fields[7].GetUInt8());
spellArea.autocast = fields[8].GetBool(); spellArea.autocast = fields[8].GetBool();
@ -2398,10 +2398,35 @@ void SpellMgr::LoadSpellAreas()
continue; 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); 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; 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)) if(spellArea.areaId && !GetAreaEntryByAreaID(spellArea.areaId))
@ -2433,33 +2458,33 @@ void SpellMgr::LoadSpellAreas()
if(spellArea.auraSpell) if(spellArea.auraSpell)
{ {
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellArea.auraSpell); SpellEntry const* spellInfo = sSpellStore.LookupEntry(abs(spellArea.auraSpell));
if(!spellInfo) 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; 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; 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; continue;
} }
// not allow autocast chains by auraSpell field // not allow autocast chains by auraSpell field (but allow use as alternative if not present)
if(spellArea.autocast) if(spellArea.autocast && spellArea.auraSpell > 0)
{ {
bool chain = false; bool chain = false;
SpellAreaForAuraMapBounds saBound = GetSpellAreaForAuraMapBounds(spellArea.spellId); SpellAreaForAuraMapBounds saBound = GetSpellAreaForAuraMapBounds(spellArea.spellId);
for(SpellAreaForAuraMap::const_iterator itr = saBound.first; itr != saBound.second; ++itr) 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; chain = true;
break; break;
@ -2475,7 +2500,7 @@ void SpellMgr::LoadSpellAreas()
SpellAreaMapBounds saBound2 = GetSpellAreaMapBounds(spellArea.auraSpell); SpellAreaMapBounds saBound2 = GetSpellAreaMapBounds(spellArea.auraSpell);
for(SpellAreaMap::const_iterator itr2 = saBound2.first; itr2 != saBound2.second; ++itr2) 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; chain = true;
break; break;
@ -2523,7 +2548,7 @@ void SpellMgr::LoadSpellAreas()
// for search at aura apply // for search at aura apply
if(spellArea.auraSpell) if(spellArea.auraSpell)
mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(spellArea.auraSpell,sa)); mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell),sa));
++count; ++count;
} while( result->NextRow() ); } while( result->NextRow() );
@ -2810,8 +2835,14 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
if(auraSpell) if(auraSpell)
{ {
// not have expected aura // not have expected aura
if(!player || !player->HasAura(auraSpell,0)) if(!player)
return false; 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; return true;

View file

@ -690,7 +690,7 @@ struct SpellArea
uint32 areaId; // zone/subzone/or 0 is not limited to zone uint32 areaId; // zone/subzone/or 0 is not limited to zone
uint32 questStart; // quest start (quest must be active or rewarded for spell apply) uint32 questStart; // quest start (quest must be active or rewarded for spell apply)
uint32 questEnd; // quest end (quest don't must be rewarded for spell apply) uint32 questEnd; // quest end (quest don't must be rewarded for spell apply)
uint32 auraSpell; // spell aura must be applied for spell apply int32 auraSpell; // spell aura must be applied for spell apply )if possitive) and it don't must be applied in other case
uint32 raceMask; // can be applied only to races uint32 raceMask; // can be applied only to races
Gender gender; // can be applied only to gender Gender gender; // can be applied only to gender
bool questStartCanActive; // if true then quest start can be active (not only rewarded) bool questStartCanActive; // if true then quest start can be active (not only rewarded)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7375" #define REVISION_NR "7376"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__