[8952] Use default gossip menu options if no options exist for "top level" menu.

Also not close gossip menu in cases where no action_menu_id is set.

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2009-12-08 21:47:34 +01:00
parent d604b0a120
commit 4ca8b0defc
5 changed files with 27 additions and 5 deletions

View file

@ -489,6 +489,16 @@ struct GameObjectInfo
default: return 0; default: return 0;
} }
} }
uint32 GetGossipMenuId() const
{
switch(type)
{
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.gossipID;
case GAMEOBJECT_TYPE_GOOBER: return goober.gossipID;
default: return 0;
}
}
}; };
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform

View file

@ -103,6 +103,7 @@ void GossipMenu::ClearMenu()
{ {
m_gItems.clear(); m_gItems.clear();
m_gItemsData.clear(); m_gItemsData.clear();
m_gMenuId = 0;
} }
PlayerMenu::PlayerMenu( WorldSession *session ) : pSession(session) PlayerMenu::PlayerMenu( WorldSession *session ) : pSession(session)

View file

@ -12188,6 +12188,10 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
GossipMenuItemsMapBounds pMenuItemBounds = sObjectMgr.GetGossipMenuItemsMapBounds(menuId); GossipMenuItemsMapBounds pMenuItemBounds = sObjectMgr.GetGossipMenuItemsMapBounds(menuId);
// if default menuId and no menu options exist for this, use options from default options
if (pMenuItemBounds.first == pMenuItemBounds.second && menuId == GetDefaultGossipMenuForSource(pSource))
pMenuItemBounds = sObjectMgr.GetGossipMenuItemsMapBounds(0);
for(GossipMenuItemsMap::const_iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr) for(GossipMenuItemsMap::const_iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
{ {
bool bCanTalk = true; bool bCanTalk = true;
@ -12405,10 +12409,6 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me
PrepareGossipMenu(pSource, pMenuData.m_gAction_menu); PrepareGossipMenu(pSource, pMenuData.m_gAction_menu);
SendPreparedGossip(pSource); SendPreparedGossip(pSource);
} }
else
{
PlayerTalkClass->CloseGossip();
}
if (pMenuData.m_gAction_poi) if (pMenuData.m_gAction_poi)
PlayerTalkClass->SendPointOfInterest(pMenuData.m_gAction_poi); PlayerTalkClass->SendPointOfInterest(pMenuData.m_gAction_poi);
@ -12519,6 +12519,16 @@ uint32 Player::GetGossipTextId(uint32 menuId)
return textId; return textId;
} }
uint32 Player::GetDefaultGossipMenuForSource(WorldObject *pSource)
{
if (pSource->GetTypeId() == TYPEID_UNIT)
return ((Creature*)pSource)->GetCreatureInfo()->GossipMenuId;
else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT)
return((GameObject*)pSource)->GetGOInfo()->GetGossipMenuId();
return 0;
}
/*********************************************************/ /*********************************************************/
/*** QUEST SYSTEM ***/ /*** QUEST SYSTEM ***/
/*********************************************************/ /*********************************************************/

View file

@ -1305,6 +1305,7 @@ class MANGOS_DLL_SPEC Player : public Unit
uint32 GetGossipTextId(uint32 menuId); uint32 GetGossipTextId(uint32 menuId);
uint32 GetGossipTextId(WorldObject *pSource); uint32 GetGossipTextId(WorldObject *pSource);
uint32 GetDefaultGossipMenuForSource(WorldObject *pSource);
/*********************************************************/ /*********************************************************/
/*** QUEST SYSTEM ***/ /*** QUEST SYSTEM ***/

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 "8951" #define REVISION_NR "8952"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__