[7253] Check battleground status in GetSpellAllowedInLocationError for some spells for aura remove and spell casting cases.

This commit is contained in:
VladimirMangos 2009-02-09 15:36:54 +03:00
parent 100429f29c
commit e97c7ad9c5
6 changed files with 41 additions and 12 deletions

View file

@ -18935,7 +18935,7 @@ void Player::UpdateAreaDependentAuras( uint32 newArea )
for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();)
{ {
// use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date // use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date
if(GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea)!=0) if(GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea,GetBattleGroundId())!=0)
RemoveAura(iter); RemoveAura(iter);
else else
++iter; ++iter;

View file

@ -3825,7 +3825,8 @@ uint8 Spell::CanCast(bool strict)
return SPELL_FAILED_NOT_IN_ARENA; return SPELL_FAILED_NOT_IN_ARENA;
// zone check // zone check
if(uint8 res= GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),m_caster->GetZoneId(),m_caster->GetAreaId())) if (uint8 res= GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),m_caster->GetZoneId(),m_caster->GetAreaId(),
m_caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)m_caster)->GetBattleGroundId() : 0))
return res; return res;
// not let players cast spells at mount (and let do it to creatures) // not let players cast spells at mount (and let do it to creatures)

View file

@ -24,6 +24,7 @@
#include "World.h" #include "World.h"
#include "Chat.h" #include "Chat.h"
#include "Spell.h" #include "Spell.h"
#include "BattleGroundMgr.h"
SpellMgr::SpellMgr() SpellMgr::SpellMgr()
{ {
@ -2342,7 +2343,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
return true; return true;
} }
uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id) uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id, uint32 bgInstanceId)
{ {
// normal case // normal case
if( spellInfo->AreaGroupId > 0) if( spellInfo->AreaGroupId > 0)
@ -2427,27 +2428,40 @@ uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,u
return area_id == 4028 || area_id == 4029 || area_id == 4106 || area_id == 4031 ? 0 : SPELL_FAILED_INCORRECT_AREA; return area_id == 4028 || area_id == 4029 || area_id == 4106 || area_id == 4031 ? 0 : SPELL_FAILED_INCORRECT_AREA;
case 23333: // Warsong Flag case 23333: // Warsong Flag
case 23335: // Silverwing Flag case 23335: // Silverwing Flag
return map_id == 489 ? 0 : SPELL_FAILED_REQUIRES_AREA; return map_id == 489 && bgInstanceId ? 0 : SPELL_FAILED_REQUIRES_AREA;
case 34976: // Netherstorm Flag case 34976: // Netherstorm Flag
return map_id == 566 ? 0 : SPELL_FAILED_REQUIRES_AREA; return map_id == 566 && bgInstanceId ? 0 : SPELL_FAILED_REQUIRES_AREA;
case 2584: // Waiting to Resurrect case 2584: // Waiting to Resurrect
case 22011: // Spirit Heal Channel case 22011: // Spirit Heal Channel
case 22012: // Spirit Heal case 22012: // Spirit Heal
case 24171: // Resurrection Impact Visual case 24171: // Resurrection Impact Visual
case 42792: // Recently Dropped Flag case 42792: // Recently Dropped Flag
case 43681: // Inactive case 43681: // Inactive
case 44521: // Preparation
case 44535: // Spirit Heal (mana) case 44535: // Spirit Heal (mana)
{ {
MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); MapEntry const* mapEntry = sMapStore.LookupEntry(map_id);
if(!mapEntry) if(!mapEntry)
return SPELL_FAILED_INCORRECT_AREA; return SPELL_FAILED_INCORRECT_AREA;
return mapEntry->IsBattleGround() ? 0 : SPELL_FAILED_REQUIRES_AREA; return mapEntry->IsBattleGround() && bgInstanceId ? 0 : SPELL_FAILED_REQUIRES_AREA;
}
case 44521: // Preparation
{
if(!bgInstanceId)
return SPELL_FAILED_REQUIRES_AREA;
MapEntry const* mapEntry = sMapStore.LookupEntry(map_id);
if(!mapEntry)
return SPELL_FAILED_INCORRECT_AREA;
if(!mapEntry->IsBattleGround())
return SPELL_FAILED_REQUIRES_AREA;
BattleGround* bg = sBattleGroundMgr.GetBattleGround(bgInstanceId);
return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? 0 : SPELL_FAILED_REQUIRES_AREA;
} }
case 32724: // Gold Team (Alliance) case 32724: // Gold Team (Alliance)
case 32725: // Green Team (Alliance) case 32725: // Green Team (Alliance)
case 32727: // Arena Preparation
case 35774: // Gold Team (Horde) case 35774: // Gold Team (Horde)
case 35775: // Green Team (Horde) case 35775: // Green Team (Horde)
{ {
@ -2455,7 +2469,22 @@ uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,u
if(!mapEntry) if(!mapEntry)
return SPELL_FAILED_INCORRECT_AREA; return SPELL_FAILED_INCORRECT_AREA;
return mapEntry->IsBattleArena() ? 0 : SPELL_FAILED_REQUIRES_AREA; return mapEntry->IsBattleArena() && bgInstanceId ? 0 : SPELL_FAILED_REQUIRES_AREA;
}
case 32727: // Arena Preparation
{
if(!bgInstanceId)
return SPELL_FAILED_REQUIRES_AREA;
MapEntry const* mapEntry = sMapStore.LookupEntry(map_id);
if(!mapEntry)
return SPELL_FAILED_INCORRECT_AREA;
if(!mapEntry->IsBattleArena())
return SPELL_FAILED_REQUIRES_AREA;
BattleGround* bg = sBattleGroundMgr.GetBattleGround(bgInstanceId);
return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? 0 : SPELL_FAILED_REQUIRES_AREA;
} }
} }

View file

@ -363,7 +363,7 @@ bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellI
bool IsAuraAddedBySpell(uint32 auraType, uint32 spellId); bool IsAuraAddedBySpell(uint32 auraType, uint32 spellId);
uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id); uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id,uint32 bgInstanceId);
inline bool IsAreaEffectTarget( Targets target ) inline bool IsAreaEffectTarget( Targets target )
{ {

View file

@ -458,7 +458,6 @@ void Master::clearOnlineAccounts()
"UPDATE account SET online = 0 WHERE online > 0 " "UPDATE account SET online = 0 WHERE online > 0 "
"AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID); "AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID);
CharacterDatabase.Execute("UPDATE characters SET online = 0 WHERE online<>0"); CharacterDatabase.Execute("UPDATE characters SET online = 0 WHERE online<>0");
} }

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 "7252" #define REVISION_NR "7253"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__