[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

@ -728,14 +728,19 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
if (!isTrainer()) if (!isTrainer())
return false; return false;
// pet trainers not have spells in fact now
if (GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS)
{
TrainerSpellData const* trainer_spells = GetTrainerSpells(); TrainerSpellData const* trainer_spells = GetTrainerSpells();
// for not pet trainer expected not empty trainer list always
if (!trainer_spells || trainer_spells->spellList.empty()) if (!trainer_spells || trainer_spells->spellList.empty())
{ {
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.", sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.",
GetGUIDLow(),GetEntry()); GetGUIDLow(),GetEntry());
return false; return false;
} }
}
switch(GetCreatureInfo()->trainer_type) switch(GetCreatureInfo()->trainer_type)
{ {
@ -763,9 +768,12 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
break; break;
case TRAINER_TYPE_PETS: case TRAINER_TYPE_PETS:
if (pPlayer->getClass() != CLASS_HUNTER) if (pPlayer->getClass() != CLASS_HUNTER)
{
if (msg)
{ {
pPlayer->PlayerTalkClass->ClearMenus(); pPlayer->PlayerTalkClass->ClearMenus();
pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetGUID()); pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetGUID());
}
return false; return false;
} }
break; break;

View file

@ -12764,6 +12764,11 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
break; break;
} }
case GOSSIP_OPTION_TRAINER: case GOSSIP_OPTION_TRAINER:
// pet trainers not have spells in fact now
/* FIXME: gossip menu with single unlearn pet talents option not show by some reason
if (pCreature->GetCreatureInfo()->trainer_type == TRAINER_TYPE_PETS)
hasMenuItem = false;
else */
if (!pCreature->IsTrainerOf(this, false)) if (!pCreature->IsTrainerOf(this, false))
hasMenuItem = false; hasMenuItem = false;
break; break;
@ -12772,7 +12777,14 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
hasMenuItem = false; hasMenuItem = false;
break; break;
case GOSSIP_OPTION_UNLEARNPETSKILLS: case GOSSIP_OPTION_UNLEARNPETSKILLS:
if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || pCreature->GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS || pCreature->GetCreatureInfo()->trainer_class != CLASS_HUNTER) if (pCreature->GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS || pCreature->GetCreatureInfo()->trainer_class != CLASS_HUNTER)
hasMenuItem = false;
else if (Pet * pet = GetPet())
{
if (pet->getPetType() != HUNTER_PET || pet->m_spells.size() <= 1)
hasMenuItem = false;
}
else
hasMenuItem = false; hasMenuItem = false;
break; break;
case GOSSIP_OPTION_TAXIVENDOR: case GOSSIP_OPTION_TAXIVENDOR:

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10768" #define REVISION_NR "10769"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__