From 2441c2a69fdf014564e80b776233051aeecc0a8a Mon Sep 17 00:00:00 2001 From: GriffonHeart Date: Thu, 1 Jan 2009 22:40:52 +0300 Subject: [PATCH] [6997] Fixed: In 3.0.3 spell data have area group id instead area id. Signed-off-by: VladimirMangos --- src/game/PetHandler.cpp | 3 --- src/game/Player.cpp | 2 +- src/game/Spell.cpp | 10 ++++---- src/game/SpellMgr.cpp | 41 ++++++++++++++++++++---------- src/game/SpellMgr.h | 2 +- src/shared/Database/DBCStores.cpp | 2 ++ src/shared/Database/DBCStores.h | 1 + src/shared/Database/DBCStructure.h | 8 +++++- src/shared/Database/DBCfmt.cpp | 1 + src/shared/revision_nr.h | 2 +- 10 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 1a34358f0..5af2384b4 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -246,9 +246,6 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) case SPELL_FAILED_REQUIRES_SPELL_FOCUS: data << uint32(spellInfo->RequiresSpellFocus); break; - case SPELL_FAILED_REQUIRES_AREA: - data << uint32(spellInfo->AreaId); - break; } SendPacket(&data); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 62cd36378..347c24305 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -18671,7 +18671,7 @@ void Player::UpdateAreaDependentAuras( uint32 newArea ) 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 - if(!IsSpellAllowedInLocation(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea)) + if(GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea)!=0) RemoveAura(iter); else ++iter; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 4ac59c53f..0e6380c49 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2713,8 +2713,8 @@ void Spell::SendCastResult(uint8 result) case 45373: // Bloodberry Elixir data << uint32(4075); break; - default: // default case - data << uint32(m_spellInfo->AreaId); + default: // default case (don't must be) + data << uint32(0); break; } break; @@ -3652,8 +3652,8 @@ uint8 Spell::CanCast(bool strict) return SPELL_FAILED_NOT_IN_ARENA; // zone check - if(!IsSpellAllowedInLocation(m_spellInfo,m_caster->GetMapId(),m_caster->GetZoneId(),m_caster->GetAreaId())) - return SPELL_FAILED_REQUIRES_AREA; + if(uint8 res= GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),m_caster->GetZoneId(),m_caster->GetAreaId())) + return res; // not let players cast spells at mount (and let do it to creatures) if( m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell && @@ -4279,7 +4279,7 @@ uint8 Spell::CanCast(bool strict) return SPELL_FAILED_NO_MOUNTS_ALLOWED; // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells - if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaId) + if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaGroupId) return SPELL_FAILED_NO_MOUNTS_ALLOWED; ShapeshiftForm form = m_caster->m_form; diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 999f05f0f..442c2d376 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2257,11 +2257,24 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) return true; } -bool IsSpellAllowedInLocation(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) { // normal case - if( spellInfo->AreaId > 0 && spellInfo->AreaId != zone_id && spellInfo->AreaId != area_id ) - return false; + if( spellInfo->AreaGroupId > 0) + { + bool found = false; + + AreaGroupEntry const* groupEntry = sAreaGroupStore.LookupEntry(spellInfo->AreaGroupId); + if(groupEntry) + { + for (uint8 i=0; i<7; i++) + if( groupEntry->AreaId[i] == zone_id || groupEntry->AreaId[i] == area_id ) + found = true; + } + + if(!found) + return SPELL_FAILED_INCORRECT_AREA; + } // elixirs (all area dependent elixirs have family SPELLFAMILY_POTION, use this for speedup) if(spellInfo->SpellFamilyName==SPELLFAMILY_POTION) @@ -2271,24 +2284,24 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z if(mask & ELIXIR_BATTLE_MASK) { if(spellInfo->Id==45373) // Bloodberry Elixir - return zone_id==4075; + return zone_id==4075 ? 0 : SPELL_FAILED_REQUIRES_AREA; } if(mask & ELIXIR_UNSTABLE_MASK) { // in the Blade's Edge Mountains Plateaus and Gruul's Lair. - return zone_id ==3522 || map_id==565; + return zone_id ==3522 || map_id==565 ? 0 : SPELL_FAILED_INCORRECT_AREA; } if(mask & ELIXIR_SHATTRATH_MASK) { // in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple, Sunwell Plateau if(zone_id ==3607 || map_id==534 || map_id==564 || zone_id==4075) - return true; + return 0; MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if(!mapEntry) - return false; + return SPELL_FAILED_INCORRECT_AREA; - return mapEntry->multimap_id==206; + return mapEntry->multimap_id==206 ? 0 : SPELL_FAILED_INCORRECT_AREA; } // elixirs not have another limitations @@ -2304,25 +2317,25 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if(!mapEntry) - return false; + return SPELL_FAILED_INCORRECT_AREA; - return mapEntry->multimap_id==206; + return mapEntry->multimap_id==206 ? 0 : SPELL_FAILED_REQUIRES_AREA; } case 41617: // Cenarion Mana Salve case 41619: // Cenarion Healing Salve { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if(!mapEntry) - return false; + return SPELL_FAILED_INCORRECT_AREA; - return mapEntry->multimap_id==207; + return mapEntry->multimap_id==207 ? 0 : SPELL_FAILED_REQUIRES_AREA; } case 40216: // Dragonmaw Illusion case 42016: // Dragonmaw Illusion - return area_id == 3759 || area_id == 3966 || area_id == 3939; + return area_id == 3759 || area_id == 3966 || area_id == 3939 ? 0 : SPELL_FAILED_INCORRECT_AREA; } - return true; + return 0; } void SpellMgr::LoadSkillLineAbilityMap() diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 8154adf23..5e9f41a6a 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -351,7 +351,7 @@ bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellI bool IsAuraAddedBySpell(uint32 auraType, uint32 spellId); -bool IsSpellAllowedInLocation(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); inline bool IsAreaEffectTarget( Targets target ) { diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index 0ae6f663b..c314c667c 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -30,6 +30,7 @@ typedef std::map AreaFlagByAreaID; typedef std::map AreaFlagByMapID; DBCStorage sAreaStore(AreaTableEntryfmt); +DBCStorage sAreaGroupStore(AreaGroupEntryfmt); static AreaFlagByAreaID sAreaFlagByAreaID; static AreaFlagByMapID sAreaFlagByMapID; // for instances without generated *.map files @@ -215,6 +216,7 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementStore, dbcPath,"Achievement.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementCriteriaStore, dbcPath,"Achievement_Criteria.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore, dbcPath,"AreaTrigger.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaGroupStore, dbcPath,"AreaGroup.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBankBagSlotPricesStore, dbcPath,"BankBagSlotPrices.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore, dbcPath,"BattlemasterList.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBarberShopStyleStore, dbcPath,"BarberShopStyle.dbc"); diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index 8143ec704..92b1eba83 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -133,6 +133,7 @@ class DBCStorage extern DBCStorage sAchievementStore; extern DBCStorage sAchievementCriteriaStore; extern DBCStorage sAreaStore;// recommend access using functions +extern DBCStorage sAreaGroupStore; extern DBCStorage sAreaTriggerStore; extern DBCStorage sBankBagSlotPricesStore; extern DBCStorage sBarberShopStyleStore; diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index 839687f3d..39873ef9b 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -485,6 +485,12 @@ struct AreaTableEntry uint32 team; // 28 }; +struct AreaGroupEntry +{ + uint32 AreaGroupId; // 0 + uint32 AreaId[7]; // 1-7 +}; + struct AreaTriggerEntry { uint32 id; // 0 m_ID @@ -1152,7 +1158,7 @@ struct SpellEntry //uint32 MinReputation; // 223 m_minReputation not used //uint32 RequiredAuraVision; // 224 m_requiredAuraVision not used uint32 TotemCategory[2]; // 225-226 m_requiredTotemCategoryID - int32 AreaId; // 227 m_requiredAreasID + int32 AreaGroupId; // 227 m_requiredAreaGroupId uint32 SchoolMask; // 228 m_schoolMask uint32 runeCostID; // 229 m_runeCostID //uint32 spellMissileID; // 230 m_spellMissileID not used diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp index b78608c2d..00101f180 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/shared/Database/DBCfmt.cpp @@ -19,6 +19,7 @@ const char Achievementfmt[]="niixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxxi"; const char AchievementCriteriafmt[]="niiiiiiiixxxxxxxxxxxxxxxxxiixix"; const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxxx"; +const char AreaGroupEntryfmt[]="niiiiiii"; const char AreaTriggerEntryfmt[]="niffffffff"; const char BankBagSlotPricesEntryfmt[]="ni"; const char BarberShopStyleEntryfmt[]="nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii"; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4175ffc05..7e3804ea7 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6996" + #define REVISION_NR "6997" #endif // __REVISION_NR_H__