Fix spell_area not checking for zoneID for quests
Port From (https://github.com/TrinityCore/TrinityCore/commit/e1598fa1d64b46fc53607182898fae2da172957b)
This commit is contained in:
@@ -1871,22 +1871,51 @@ namespace Game.Entities
|
||||
SendQuestUpdate(questId);
|
||||
}
|
||||
|
||||
void SendQuestUpdate(uint questid)
|
||||
void SendQuestUpdate(uint questId)
|
||||
{
|
||||
uint zone, area;
|
||||
GetZoneAndAreaId(out zone, out area);
|
||||
|
||||
var saBounds = Global.SpellMgr.GetSpellAreaForQuestAreaMapBounds(area, questid);
|
||||
var saBounds = Global.SpellMgr.GetSpellAreaForQuestMapBounds(questId);
|
||||
if (!saBounds.Empty())
|
||||
{
|
||||
List<uint> aurasToRemove = new();
|
||||
List<uint> aurasToCast = new();
|
||||
GetZoneAndAreaId(out uint zone, out uint area);
|
||||
|
||||
foreach (var spell in saBounds)
|
||||
{
|
||||
if (spell.flags.HasAnyFlag(SpellAreaFlag.AutoRemove) && !spell.IsFitToRequirements(this, zone, area))
|
||||
RemoveAurasDueToSpell(spell.spellId);
|
||||
aurasToRemove.Add(spell.spellId);
|
||||
else if (spell.flags.HasAnyFlag(SpellAreaFlag.AutoCast) && !spell.flags.HasAnyFlag(SpellAreaFlag.IgnoreAutocastOnQuestStatusChange))
|
||||
if (!HasAura(spell.spellId))
|
||||
CastSpell(this, spell.spellId, true);
|
||||
aurasToCast.Add(spell.spellId);
|
||||
}
|
||||
|
||||
// Auras matching the requirements will be inside the aurasToCast container.
|
||||
// Auras not matching the requirements may prevent using auras matching the requirements.
|
||||
// aurasToCast will erase conflicting auras in aurasToRemove container to handle spells used by multiple quests.
|
||||
|
||||
for (var c = 0; c < aurasToRemove.Count;)
|
||||
{
|
||||
bool auraRemoved = false;
|
||||
|
||||
foreach (var i in aurasToCast)
|
||||
{
|
||||
if (aurasToRemove[c] == i)
|
||||
{
|
||||
aurasToRemove.Remove(aurasToRemove[c]);
|
||||
auraRemoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!auraRemoved)
|
||||
++c;
|
||||
}
|
||||
|
||||
foreach (var spellId in aurasToCast)
|
||||
if (!HasAura(spellId))
|
||||
CastSpell(this, spellId, true);
|
||||
|
||||
foreach (var spellId in aurasToRemove)
|
||||
RemoveAurasDueToSpell(spellId);
|
||||
}
|
||||
|
||||
UpdateVisibleGameobjectsOrSpellClicks();
|
||||
|
||||
@@ -621,11 +621,6 @@ namespace Game.Entities
|
||||
return mSpellAreaForAreaMap.LookupByKey(area_id);
|
||||
}
|
||||
|
||||
public List<SpellArea> GetSpellAreaForQuestAreaMapBounds(uint area_id, uint quest_id)
|
||||
{
|
||||
return mSpellAreaForQuestAreaMap.LookupByKey(Tuple.Create(area_id, quest_id));
|
||||
}
|
||||
|
||||
public SpellInfo GetSpellInfo(uint spellId, Difficulty difficulty)
|
||||
{
|
||||
var list = mSpellInfoMap.LookupByKey(spellId);
|
||||
@@ -1969,7 +1964,6 @@ namespace Game.Entities
|
||||
mSpellAreaForQuestMap.Clear();
|
||||
mSpellAreaForQuestEndMap.Clear();
|
||||
mSpellAreaForAuraMap.Clear();
|
||||
mSpellAreaForQuestAreaMap.Clear();
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
SQLResult result = DB.World.Query("SELECT spell, area, quest_start, quest_start_status, quest_end_status, quest_end, aura_spell, racemask, gender, flags FROM spell_area");
|
||||
@@ -2131,9 +2125,19 @@ namespace Game.Entities
|
||||
if (spellArea.areaId != 0)
|
||||
mSpellAreaForAreaMap.AddRange(spellArea.areaId, sa);
|
||||
|
||||
// for search at quest start/reward
|
||||
if (spellArea.questStart != 0)
|
||||
mSpellAreaForQuestMap.AddRange(spellArea.questStart, sa);
|
||||
// for search at quest update checks
|
||||
if (spellArea.questStart != 0 || spellArea.questEnd != 0)
|
||||
{
|
||||
if (spellArea.questStart == spellArea.questEnd)
|
||||
mSpellAreaForQuestMap.AddRange(spellArea.questStart, sa);
|
||||
else
|
||||
{
|
||||
if (spellArea.questStart != 0)
|
||||
mSpellAreaForQuestMap.AddRange(spellArea.questStart, sa);
|
||||
if (spellArea.questEnd != 0)
|
||||
mSpellAreaForQuestMap.AddRange(spellArea.questEnd, sa);
|
||||
}
|
||||
}
|
||||
|
||||
// for search at quest start/reward
|
||||
if (spellArea.questEnd != 0)
|
||||
@@ -2143,12 +2147,6 @@ namespace Game.Entities
|
||||
if (spellArea.auraSpell != 0)
|
||||
mSpellAreaForAuraMap.AddRange((uint)Math.Abs(spellArea.auraSpell), sa);
|
||||
|
||||
if (spellArea.areaId != 0 && spellArea.questStart != 0)
|
||||
mSpellAreaForQuestAreaMap.AddRange(Tuple.Create(spellArea.areaId, spellArea.questStart), sa);
|
||||
|
||||
if (spellArea.areaId != 0 && spellArea.questEnd != 0)
|
||||
mSpellAreaForQuestAreaMap.AddRange(Tuple.Create(spellArea.areaId, spellArea.questEnd), sa);
|
||||
|
||||
++count;
|
||||
} while (result.NextRow());
|
||||
|
||||
@@ -4756,7 +4754,6 @@ namespace Game.Entities
|
||||
MultiMap<uint, SpellArea> mSpellAreaForQuestEndMap = new();
|
||||
MultiMap<uint, SpellArea> mSpellAreaForAuraMap = new();
|
||||
MultiMap<uint, SpellArea> mSpellAreaForAreaMap = new();
|
||||
MultiMap<Tuple<uint, uint>, SpellArea> mSpellAreaForQuestAreaMap = new();
|
||||
MultiMap<uint, SkillLineAbilityRecord> mSkillLineAbilityMap = new();
|
||||
Dictionary<uint, MultiMap<uint, uint>> mPetLevelupSpellMap = new();
|
||||
Dictionary<uint, PetDefaultSpellsEntry> mPetDefaultSpellsMap = new(); // only spells not listed in related mPetLevelupSpellMap entry
|
||||
|
||||
Reference in New Issue
Block a user