From 4ca8b0defca1056a5f461931d537350a2e53d66e Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Tue, 8 Dec 2009 21:47:34 +0100 Subject: [PATCH] [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 --- src/game/GameObject.h | 10 ++++++++++ src/game/GossipDef.cpp | 1 + src/game/Player.cpp | 18 ++++++++++++++---- src/game/Player.h | 1 + src/shared/revision_nr.h | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/game/GameObject.h b/src/game/GameObject.h index db0a49665..3d2b2a426 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -489,6 +489,16 @@ struct GameObjectInfo 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 diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 5b269da61..a192457e2 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -103,6 +103,7 @@ void GossipMenu::ClearMenu() { m_gItems.clear(); m_gItemsData.clear(); + m_gMenuId = 0; } PlayerMenu::PlayerMenu( WorldSession *session ) : pSession(session) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 37ac59a8d..2fa5ce06c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12188,6 +12188,10 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 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) { bool bCanTalk = true; @@ -12405,10 +12409,6 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me PrepareGossipMenu(pSource, pMenuData.m_gAction_menu); SendPreparedGossip(pSource); } - else - { - PlayerTalkClass->CloseGossip(); - } if (pMenuData.m_gAction_poi) PlayerTalkClass->SendPointOfInterest(pMenuData.m_gAction_poi); @@ -12519,6 +12519,16 @@ uint32 Player::GetGossipTextId(uint32 menuId) 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 ***/ /*********************************************************/ diff --git a/src/game/Player.h b/src/game/Player.h index 477701718..501495b29 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1305,6 +1305,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetGossipTextId(uint32 menuId); uint32 GetGossipTextId(WorldObject *pSource); + uint32 GetDefaultGossipMenuForSource(WorldObject *pSource); /*********************************************************/ /*** QUEST SYSTEM ***/ diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 21b763cb5..bc1c4623d 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 "8951" + #define REVISION_NR "8952" #endif // __REVISION_NR_H__