[10769] Fixed trainer flags uses for pet trainers.

* Not exclude trainer flags for client for pet trainers.
* Not report error for pet trianers empty spell lists.

TODO:
* Add check for redundent trainer spell data for pet trainers at server startup
* Need hide train gossip option for pet trainers, but currently without it gossip
  window not open for pet trainer by some unknown reason.
This commit is contained in:
VladimirMangos 2010-11-22 00:29:06 +03:00
parent 24d410701f
commit ce09cb70a2
3 changed files with 38 additions and 18 deletions

View file

@ -725,24 +725,29 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
{
if(!isTrainer())
if (!isTrainer())
return false;
TrainerSpellData const* trainer_spells = GetTrainerSpells();
if(!trainer_spells || trainer_spells->spellList.empty())
// pet trainers not have spells in fact now
if (GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS)
{
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.",
GetGUIDLow(),GetEntry());
return false;
TrainerSpellData const* trainer_spells = GetTrainerSpells();
// for not pet trainer expected not empty trainer list always
if (!trainer_spells || trainer_spells->spellList.empty())
{
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.",
GetGUIDLow(),GetEntry());
return false;
}
}
switch(GetCreatureInfo()->trainer_type)
{
case TRAINER_TYPE_CLASS:
if(pPlayer->getClass() != GetCreatureInfo()->trainer_class)
if (pPlayer->getClass() != GetCreatureInfo()->trainer_class)
{
if(msg)
if (msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->trainer_class)
@ -762,17 +767,20 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
}
break;
case TRAINER_TYPE_PETS:
if(pPlayer->getClass() != CLASS_HUNTER)
if (pPlayer->getClass() != CLASS_HUNTER)
{
pPlayer->PlayerTalkClass->ClearMenus();
pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetGUID());
if (msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetGUID());
}
return false;
}
break;
case TRAINER_TYPE_MOUNTS:
if(GetCreatureInfo()->trainer_race && pPlayer->getRace() != GetCreatureInfo()->trainer_race)
if (GetCreatureInfo()->trainer_race && pPlayer->getRace() != GetCreatureInfo()->trainer_race)
{
if(msg)
if (msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->trainer_class)
@ -793,9 +801,9 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
}
break;
case TRAINER_TYPE_TRADESKILLS:
if(GetCreatureInfo()->trainer_spell && !pPlayer->HasSpell(GetCreatureInfo()->trainer_spell))
if (GetCreatureInfo()->trainer_spell && !pPlayer->HasSpell(GetCreatureInfo()->trainer_spell))
{
if(msg)
if (msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
pPlayer->PlayerTalkClass->SendGossipMenu(11031, GetGUID());