[10867] Implement templates for trainer spell data in npc_trainer_template.

New table let avoid duplication similar trainer spells for different trainers.
This commit is contained in:
VladimirMangos 2010-12-13 15:10:16 +03:00
parent f228a1c08d
commit 1d8f222621
15 changed files with 229 additions and 77 deletions

View file

@ -730,10 +730,11 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
// pet trainers not have spells in fact now
if (GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS)
{
TrainerSpellData const* trainer_spells = GetTrainerSpells();
TrainerSpellData const* cSpells = GetTrainerSpells();
TrainerSpellData const* tSpells = GetTrainerTemplateSpells();
// for not pet trainer expected not empty trainer list always
if (!trainer_spells || trainer_spells->spellList.empty())
if ((!cSpells || cSpells->spellList.empty()) && (!tSpells || tSpells->spellList.empty()))
{
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.",
GetGUIDLow(),GetEntry());
@ -2181,7 +2182,8 @@ VendorItemData const* Creature::GetVendorItems() const
VendorItemData const* Creature::GetVendorTemplateItems() const
{
return GetCreatureInfo()->vendorId ? sObjectMgr.GetNpcVendorItemList(GetCreatureInfo()->vendorId) : NULL;
uint32 vendorId = GetCreatureInfo()->vendorId;
return vendorId ? sObjectMgr.GetNpcVendorItemList(vendorId) : NULL;
}
uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
@ -2256,6 +2258,12 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
return vCount->count;
}
TrainerSpellData const* Creature::GetTrainerTemplateSpells() const
{
uint32 trainerId = GetCreatureInfo()->trainerId;
return trainerId ? sObjectMgr.GetNpcTrainerTemplateSpells(trainerId) : NULL;
}
TrainerSpellData const* Creature::GetTrainerSpells() const
{
return sObjectMgr.GetNpcTrainerSpells(GetEntry());