Skip to content

Commit

Permalink
[9938] Correct premature call of TalkedToCreature.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NoFantasy committed May 19, 2010
1 parent a4b82a6 commit bc21500
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/game/NPCHandler.cpp
Expand Up @@ -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);
}
Expand Down
40 changes: 25 additions & 15 deletions src/game/Player.cpp
Expand Up @@ -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;
Expand All @@ -12590,50 +12592,53 @@ 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:
{
VendorItemData const* vItems = pCreature->GetVendorItems();
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))
return;
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:
Expand All @@ -12643,32 +12648,34 @@ 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;
}
}
else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT)
{
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;
Expand All @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9937"
#define REVISION_NR "9938"
#endif // __REVISION_NR_H__

2 comments on commit bc21500

@insider42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I has many crashes with same dump but with different "menuId" value. here the one of them http://paste2.org/p/842699
Crashes started from this revision
I'm using 9948 rev with some mods (but these mods doesn't touch gossip system)

@technoir42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm

Please sign in to comment.