From ce09cb70a298d95363c146b41d704fa12389d571 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 22 Nov 2010 00:29:06 +0300 Subject: [PATCH] [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. --- src/game/Creature.cpp | 40 ++++++++++++++++++++++++---------------- src/game/Player.cpp | 14 +++++++++++++- src/shared/revision_nr.h | 2 +- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 011b39700..1de4c829c 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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()); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index a81e31715..9021f4688 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12764,6 +12764,11 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) break; } 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)) hasMenuItem = false; break; @@ -12772,7 +12777,14 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) hasMenuItem = false; break; 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; break; case GOSSIP_OPTION_TAXIVENDOR: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8b161dfa2..e7e8d582a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10768" + #define REVISION_NR "10769" #endif // __REVISION_NR_H__