[9938] Correct premature call of TalkedToCreature.

Only use TalkedToCreature when gossip does not have any following sub menu (and of course when the prepared npc options does not include any gossip)

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-05-20 00:06:09 +02:00
parent 85e3100bc7
commit b881c06104
3 changed files with 26 additions and 17 deletions

View file

@ -278,7 +278,6 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data)
if (!Script->GossipHello(_player, pCreature))
{
_player->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
_player->PrepareGossipMenu(pCreature, pCreature->GetCreatureInfo()->GossipMenuId);
_player->SendPreparedGossip(pCreature);
}

View file

@ -12564,9 +12564,11 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
if (pMenuItemBounds.first == pMenuItemBounds.second && menuId == GetDefaultGossipMenuForSource(pSource))
pMenuItemBounds = sObjectMgr.GetGossipMenuItemsMapBounds(0);
bool canTalkToCredit = true;
for(GossipMenuItemsMap::const_iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
{
bool bCanTalk = true;
bool hasMenuItem = true;
if (itr->second.cond_1 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1))
continue;
@ -12590,14 +12592,14 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
{
case GOSSIP_OPTION_QUESTGIVER:
PrepareQuestMenu(pSource->GetGUID());
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_ARMORER:
bCanTalk = false; // added in special mode
hasMenuItem = false; // added in special mode
break;
case GOSSIP_OPTION_SPIRITHEALER:
if (!isDead())
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_VENDOR:
{
@ -12605,21 +12607,21 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
if (!vItems || vItems->Empty())
{
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", pCreature->GetGUIDLow(), pCreature->GetEntry());
bCanTalk = false;
hasMenuItem = false;
}
break;
}
case GOSSIP_OPTION_TRAINER:
if (!pCreature->isCanTrainingOf(this, false))
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_UNLEARNTALENTS:
if (!pCreature->isCanTrainingAndResetTalentsOf(this))
bCanTalk = false;
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)
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_TAXIVENDOR:
if (GetSession()->SendLearnNewTaxiNode(pCreature))
@ -12627,13 +12629,16 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
break;
case GOSSIP_OPTION_BATTLEFIELD:
if (!pCreature->isCanInteractWithBattleMaster(this, false))
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_STABLEPET:
if (getClass() != CLASS_HUNTER)
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_GOSSIP:
if (itr->second.action_menu_id) // has sub menu, so do not "talk" with this NPC yet
canTalkToCredit = false;
break;
case GOSSIP_OPTION_SPIRITGUIDE:
case GOSSIP_OPTION_INNKEEPER:
case GOSSIP_OPTION_BANKER:
@ -12643,7 +12648,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
break; // no checks
default:
sLog.outErrorDb("Creature entry %u have unknown gossip option %u for menu %u", pCreature->GetEntry(), itr->second.option_id, itr->second.menu_id);
bCanTalk = false;
hasMenuItem = false;
break;
}
}
@ -12651,24 +12656,26 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
{
GameObject *pGo = (GameObject*)pSource;
canTalkToCredit = false;
switch(itr->second.option_id)
{
case GOSSIP_OPTION_QUESTGIVER:
if (pGo->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
PrepareQuestMenu(pSource->GetGUID());
bCanTalk = false;
hasMenuItem = false;
break;
case GOSSIP_OPTION_GOSSIP:
if (pGo->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER && pGo->GetGoType() != GAMEOBJECT_TYPE_GOOBER)
bCanTalk = false;
hasMenuItem = false;
break;
default:
bCanTalk = false;
hasMenuItem = false;
break;
}
}
if (bCanTalk)
if (hasMenuItem)
{
std::string strOptionText = itr->second.option_text;
std::string strBoxText = itr->second.box_text;
@ -12694,6 +12701,9 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
}
}
if (canTalkToCredit)
TalkedToCreature(((Creature*)pSource)->GetEntry(), ((Creature*)pSource)->GetGUID());
// some gossips aren't handled in normal way ... so we need to do it this way .. TODO: handle it in normal way ;-)
/*if (pMenu->Empty())
{

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9937"
#define REVISION_NR "9938"
#endif // __REVISION_NR_H__