diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Handlers/ItemHandler.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 18 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.h | 4 |
3 files changed, 28 insertions, 7 deletions
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 561a3f355af..514f315aae0 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -28,6 +28,7 @@ #include "ObjectMgr.h" #include "Opcodes.h" #include "Player.h" +#include "SpellMgr.h" #include "WorldSession.h" void WorldSession::HandleSplitItemOpcode(WorldPackets::Item::SplitItem& splitItem) @@ -1193,14 +1194,12 @@ void WorldSession::HandleUseCritterItem(WorldPackets::Item::UseCritterItem& useC return; int32 spellToLearn = item->GetTemplate()->Effects[1]->SpellID; - for (BattlePetSpeciesEntry const* entry : sBattlePetSpeciesStore) + + + if (BattlePetSpeciesEntry const* entry = sSpellMgr->GetBattlePetSpecies(uint32(spellToLearn))) { - if (entry->SummonSpellID == spellToLearn) - { - GetBattlePetMgr()->AddPet(entry->ID, entry->CreatureID, BattlePetMgr::RollPetBreed(entry->ID), BattlePetMgr::GetDefaultPetQuality(entry->ID)); - _player->UpdateCriteria(CRITERIA_TYPE_OWN_BATTLE_PET_COUNT); - break; - } + GetBattlePetMgr()->AddPet(entry->ID, entry->CreatureID, BattlePetMgr::RollPetBreed(entry->ID), BattlePetMgr::GetDefaultPetQuality(entry->ID)); + _player->UpdateCriteria(CRITERIA_TYPE_OWN_BATTLE_PET_COUNT); } _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index e3c405c9e96..5bb9d23c7db 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -20,6 +20,7 @@ #include "BattlefieldWG.h" #include "BattlegroundMgr.h" #include "Chat.h" +#include "Containers.h" #include "DB2Stores.h" #include "DatabaseEnv.h" #include "Log.h" @@ -2241,6 +2242,12 @@ void SpellMgr::LoadSpellInfoStore() mSpellInfoMap.resize(sSpellNameStore.GetNumRows(), NULL); std::unordered_map<uint32, SpellInfoLoadHelper> loadData; + std::unordered_map<int32, BattlePetSpeciesEntry const*> battlePetSpeciesByCreature; + std::unordered_map<uint32, BattlePetSpeciesEntry const*> battlePetSpeciesBySpellId; + for (BattlePetSpeciesEntry const* battlePetSpecies : sBattlePetSpeciesStore) + if (battlePetSpecies->CreatureID) + battlePetSpeciesByCreature[battlePetSpecies->CreatureID] = battlePetSpecies; + std::unordered_map<int32, SpellEffectEntryMap> effectsBySpell; std::unordered_map<uint32, SpellVisualMap> visualsBySpell; @@ -2257,6 +2264,12 @@ void SpellMgr::LoadSpellInfoStore() effectsForDifficulty.resize(std::size_t(effect->EffectIndex + 1)); effectsForDifficulty[effect->EffectIndex] = effect; + + if (effect->Effect == SPELL_EFFECT_SUMMON) + if (SummonPropertiesEntry const* summonProperties = sSummonPropertiesStore.LookupEntry(effect->EffectMiscValue[1])) + if (summonProperties->Slot == SUMMON_SLOT_MINIPET && summonProperties->Flags & SUMMON_PROP_FLAG_COMPANION) + if (BattlePetSpeciesEntry const* battlePetSpecies = Trinity::Containers::MapGetValuePtr(battlePetSpeciesByCreature, effect->EffectMiscValue[0])) + mBattlePets[effect->SpellID] = battlePetSpecies; } for (SpellAuraOptionsEntry const* auraOptions : sSpellAuraOptionsStore) @@ -3772,3 +3785,8 @@ uint32 SpellMgr::GetModelForTotem(uint32 spellId, uint8 race) const TC_LOG_ERROR("spells", "Spell %u with RaceID (%u) have no totem model data defined, set to default model.", spellId, race); return 0; } + +BattlePetSpeciesEntry const* SpellMgr::GetBattlePetSpecies(uint32 spellId) const +{ + return Trinity::Containers::MapGetValuePtr(mBattlePets, spellId); +} diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 710d4aadf08..6bf843cfff1 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -36,6 +36,7 @@ class SpellInfo; class Player; class Unit; class ProcEventInfo; +struct BattlePetSpeciesEntry; struct SkillLineAbilityEntry; struct SpellAuraOptionsEntry; struct SpellAuraRestrictionsEntry; @@ -701,6 +702,8 @@ class TC_GAME_API SpellMgr uint32 GetModelForTotem(uint32 spellId, uint8 race) const; + BattlePetSpeciesEntry const* GetBattlePetSpecies(uint32 spellId) const; + private: SpellInfo* _GetSpellInfo(uint32 spellId) { return spellId < GetSpellInfoStoreSize() ? mSpellInfoMap[spellId] : NULL; } @@ -764,6 +767,7 @@ class TC_GAME_API SpellMgr PetDefaultSpellsMap mPetDefaultSpellsMap; // only spells not listed in related mPetLevelupSpellMap entry SpellInfoMap mSpellInfoMap; SpellTotemModelMap mSpellTotemModel; + std::unordered_map<uint32, BattlePetSpeciesEntry const*> mBattlePets; }; #define sSpellMgr SpellMgr::instance() |