Core: Use new SpellInfo class in core. Sadly, this commit is not compatibile with some of the custom code. To make your code work again you may need to change:
*SpellEntry is now SpellInfo *GetSpellProto is now GetSpellInfo *SpellEntry::Effect*[effIndex] is now avalible under SpellInfo.Effects[effIndex].* *sSpellStore.LookupEntry is no longer valid, use sSpellMgr->GetSpellInfo() *SpellFunctions from SpellMgr.h like DoSpellStuff(spellId) are now: spellInfo->DoStuff() *SpellMgr::CalculateEffectValue and similar functions are now avalible in SpellEffectInfo class. *GET_SPELL macro is removed, code which used it is moved to SpellMgr::LoadDbcDataCorrections *code which affected dbc data in SpellMgr::LoadSpellCustomAttr is now moved to LoadDbcDataCorrections
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "Item.h"
|
||||
#include "UpdateData.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
void WorldSession::HandleSplitItemOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
@@ -363,7 +364,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
// send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
|
||||
// use `item_template` or if not set then only use spell cooldowns
|
||||
SpellEntry const* spell = sSpellStore.LookupEntry(pProto->Spells[s].SpellId);
|
||||
SpellInfo const* spell = sSpellMgr->GetSpellInfo(pProto->Spells[s].SpellId);
|
||||
if (spell)
|
||||
{
|
||||
bool db_data = pProto->Spells[s].SpellCooldown >= 0 || pProto->Spells[s].SpellCategoryCooldown >= 0;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "Battleground.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
enum StableResultCode
|
||||
{
|
||||
@@ -177,7 +178,8 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
if (sSpellMgr->IsPrimaryProfessionFirstRankSpell(tSpell->learnedSpell[i]))
|
||||
SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(tSpell->learnedSpell[i]);
|
||||
if (learnedSpellInfo && learnedSpellInfo->IsPrimaryProfessionFirstRank())
|
||||
primary_prof_first_rank = true;
|
||||
}
|
||||
if (!valid)
|
||||
@@ -201,13 +203,10 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
|
||||
{
|
||||
if (!tSpell->learnedSpell[i])
|
||||
continue;
|
||||
if (SpellChainNode const* chain_node = sSpellMgr->GetSpellChainNode(tSpell->learnedSpell[i]))
|
||||
if (uint32 prevSpellId = sSpellMgr->GetPrevSpellInChain(tSpell->learnedSpell[i]))
|
||||
{
|
||||
if (chain_node->prev)
|
||||
{
|
||||
data << uint32(chain_node->prev);
|
||||
++maxReq;
|
||||
}
|
||||
data << uint32(prevSpellId);
|
||||
++maxReq;
|
||||
}
|
||||
if (maxReq == 3)
|
||||
break;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Pet.h"
|
||||
#include "World.h"
|
||||
#include "Group.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
void WorldSession::HandleDismissCritter(WorldPacket &recv_data)
|
||||
{
|
||||
@@ -84,7 +85,7 @@ void WorldSession::HandlePetAction(WorldPacket & recv_data)
|
||||
|
||||
if (!pet->isAlive())
|
||||
{
|
||||
SpellEntry const* spell = (flag == ACT_ENABLED || flag == ACT_PASSIVE) ? sSpellStore.LookupEntry(spellid) : NULL;
|
||||
SpellInfo const* spell = (flag == ACT_ENABLED || flag == ACT_PASSIVE) ? sSpellMgr->GetSpellInfo(spellid) : NULL;
|
||||
if (!spell)
|
||||
return;
|
||||
if (!(spell->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD))
|
||||
@@ -288,7 +289,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
|
||||
unit_target = ObjectAccessor::GetUnit(*_player, guid2);
|
||||
|
||||
// do not cast unknown spells
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
||||
if (!spellInfo)
|
||||
{
|
||||
sLog->outError("WORLD: unknown PET spell id %i", spellid);
|
||||
@@ -301,12 +302,12 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
|
||||
|
||||
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_AREA_ENEMY_SRC || spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_AREA_ENEMY_DST || spellInfo->EffectImplicitTargetA[i] == TARGET_DEST_DYNOBJ_ENEMY)
|
||||
if (spellInfo->Effects[i].TargetA == TARGET_UNIT_AREA_ENEMY_SRC || spellInfo->Effects[i].TargetA == TARGET_UNIT_AREA_ENEMY_DST || spellInfo->Effects[i].TargetA == TARGET_DEST_DYNOBJ_ENEMY)
|
||||
return;
|
||||
}
|
||||
|
||||
// do not cast not learned spells
|
||||
if (!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
|
||||
if (!pet->HasSpell(spellid) || spellInfo->IsPassive())
|
||||
return;
|
||||
|
||||
// Clear the flags as if owner clicked 'attack'. AI will reset them
|
||||
@@ -554,26 +555,29 @@ void WorldSession::HandlePetSetAction(WorldPacket & recv_data)
|
||||
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
|
||||
if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
|
||||
{
|
||||
//sign for autocast
|
||||
if (act_state == ACT_ENABLED && spell_id)
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id))
|
||||
{
|
||||
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isPet())
|
||||
((Pet*)pet)->ToggleAutocast(spell_id, true);
|
||||
else
|
||||
for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
|
||||
if ((*itr)->GetEntry() == pet->GetEntry())
|
||||
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spell_id, true);
|
||||
}
|
||||
//sign for no/turn off autocast
|
||||
else if (act_state == ACT_DISABLED && spell_id)
|
||||
{
|
||||
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isPet())
|
||||
((Pet*)pet)->ToggleAutocast(spell_id, false);
|
||||
else
|
||||
for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
|
||||
if ((*itr)->GetEntry() == pet->GetEntry())
|
||||
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spell_id, false);
|
||||
//sign for autocast
|
||||
if (act_state == ACT_ENABLED)
|
||||
{
|
||||
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isPet())
|
||||
((Pet*)pet)->ToggleAutocast(spellInfo, true);
|
||||
else
|
||||
for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
|
||||
if ((*itr)->GetEntry() == pet->GetEntry())
|
||||
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, true);
|
||||
}
|
||||
//sign for no/turn off autocast
|
||||
else if (act_state == ACT_DISABLED)
|
||||
{
|
||||
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isPet())
|
||||
((Pet*)pet)->ToggleAutocast(spellInfo, false);
|
||||
else
|
||||
for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
|
||||
if ((*itr)->GetEntry() == pet->GetEntry())
|
||||
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
charmInfo->SetActionBar(position[i], spell_id, ActiveStates(act_state));
|
||||
@@ -706,8 +710,9 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
||||
// do not add not learned spells/ passive spells
|
||||
if (!pet->HasSpell(spellid) || IsAutocastableSpell(spellid))
|
||||
if (!pet->HasSpell(spellid) || spellInfo->IsAutocastable())
|
||||
return;
|
||||
|
||||
CharmInfo *charmInfo = pet->GetCharmInfo();
|
||||
@@ -718,11 +723,11 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
|
||||
if (pet->isPet())
|
||||
((Pet*)pet)->ToggleAutocast(spellid, state);
|
||||
((Pet*)pet)->ToggleAutocast(spellInfo, state);
|
||||
else
|
||||
pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
|
||||
pet->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, state);
|
||||
|
||||
charmInfo->SetSpellAutocast(spellid, state);
|
||||
charmInfo->SetSpellAutocast(spellInfo, state);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
|
||||
@@ -750,7 +755,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
sLog->outError("WORLD: unknown PET spell id %i", spellId);
|
||||
@@ -765,7 +770,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
|
||||
// do not cast not learned spells
|
||||
if (!caster->HasSpell(spellId) || IsPassiveSpell(spellId))
|
||||
if (!caster->HasSpell(spellId) || spellInfo->IsPassive())
|
||||
return;
|
||||
|
||||
SpellCastTargets targets;
|
||||
|
||||
@@ -139,9 +139,9 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
{
|
||||
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(proto->Spells[i].SpellId))
|
||||
if (SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(proto->Spells[i].SpellId))
|
||||
{
|
||||
if (IsNonCombatSpell(spellInfo))
|
||||
if (spellInfo->CanBeUsedInCombat())
|
||||
{
|
||||
pUser->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT, pItem, NULL);
|
||||
return;
|
||||
@@ -170,7 +170,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||
pUser->SendEquipError(EQUIP_ERR_NONE, pItem, NULL);
|
||||
|
||||
// send spell error
|
||||
if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId))
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
// for implicit area/coord target spells
|
||||
if (!targets.GetUnitTarget())
|
||||
@@ -341,7 +341,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
|
||||
if (!spellInfo)
|
||||
{
|
||||
@@ -353,7 +353,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
if (mover->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
// not have spell in spellbook or spell passive and not casted by client
|
||||
if (!mover->ToPlayer()->HasActiveSpell (spellId) || IsPassiveSpell(spellId))
|
||||
if (!mover->ToPlayer()->HasActiveSpell (spellId) || spellInfo->IsPassive())
|
||||
{
|
||||
//cheater? kick? ban?
|
||||
recvPacket.rfinish(); // prevent spam at ignore packet
|
||||
@@ -363,7 +363,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
else
|
||||
{
|
||||
// not have spell in spellbook or spell passive and not casted by client
|
||||
if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || IsPassiveSpell(spellId))
|
||||
if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive())
|
||||
{
|
||||
//cheater? kick? ban?
|
||||
recvPacket.rfinish(); // prevent spam at ignore packet
|
||||
@@ -373,7 +373,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
|
||||
// Client is resending autoshot cast opcode when other spell is casted during shoot rotation
|
||||
// Skip it to prevent "interrupt" message
|
||||
if (IsAutoRepeatRangedSpell(spellInfo) && _player->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)
|
||||
if (spellInfo->IsAutoRepeatRangedSpell() && _player->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)
|
||||
&& _player->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_spellInfo == spellInfo)
|
||||
{
|
||||
recvPacket.rfinish();
|
||||
@@ -395,7 +395,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
// auto-selection buff level base at target level (in spellInfo)
|
||||
if (targets.GetUnitTarget())
|
||||
{
|
||||
SpellEntry const *actualSpellInfo = sSpellMgr->SelectAuraRankForPlayerLevel(spellInfo, targets.GetUnitTarget()->getLevel());
|
||||
SpellInfo const *actualSpellInfo = spellInfo->GetAuraRankForLevel(targets.GetUnitTarget()->getLevel());
|
||||
|
||||
// if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message
|
||||
if (actualSpellInfo)
|
||||
@@ -423,20 +423,20 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
|
||||
uint32 spellId;
|
||||
recvPacket >> spellId;
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
return;
|
||||
|
||||
// not allow remove non positive spells and spells with attr SPELL_ATTR0_CANT_CANCEL
|
||||
if (!IsPositiveSpell(spellId) || (spellInfo->Attributes & SPELL_ATTR0_CANT_CANCEL))
|
||||
if (!spellInfo->IsPositive() || (spellInfo->Attributes & SPELL_ATTR0_CANT_CANCEL))
|
||||
return;
|
||||
|
||||
// don't allow cancelling passive auras (some of them are visible)
|
||||
if (IsPassiveSpell(spellInfo))
|
||||
if (spellInfo->IsPassive())
|
||||
return;
|
||||
|
||||
// channeled spell case (it currently casted then)
|
||||
if (IsChanneledSpell(spellInfo))
|
||||
if (spellInfo->IsChanneled())
|
||||
{
|
||||
if (Spell* curSpell = _player->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
|
||||
if (curSpell->m_spellInfo->Id == spellId)
|
||||
@@ -457,7 +457,7 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
|
||||
recvPacket >> guid;
|
||||
recvPacket >> spellId;
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
sLog->outError("WORLD: unknown PET spell id %u", spellId);
|
||||
@@ -541,7 +541,7 @@ void WorldSession::HandleSelfResOpcode(WorldPacket & /*recv_data*/)
|
||||
|
||||
if (_player->GetUInt32Value(PLAYER_SELF_RES_SPELL))
|
||||
{
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL));
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL));
|
||||
if (spellInfo)
|
||||
_player->CastSpell(_player, spellInfo, false, 0);
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
|
||||
// not accept if spell can't be casted now (cheating)
|
||||
if (uint32 my_spell_id = my_trade->GetSpell())
|
||||
{
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(my_spell_id);
|
||||
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(my_spell_id);
|
||||
Item* castItem = my_trade->GetSpellCastItem();
|
||||
|
||||
if (!spellEntry || !his_trade->GetItem(TRADE_SLOT_NONTRADED) ||
|
||||
@@ -373,7 +373,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
|
||||
// not accept if spell can't be casted now (cheating)
|
||||
if (uint32 his_spell_id = his_trade->GetSpell())
|
||||
{
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(his_spell_id);
|
||||
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(his_spell_id);
|
||||
Item* castItem = his_trade->GetSpellCastItem();
|
||||
|
||||
if (!spellEntry || !my_trade->GetItem(TRADE_SLOT_NONTRADED) || (his_trade->HasSpellCastItem() && !castItem))
|
||||
|
||||
Reference in New Issue
Block a user