diff --git a/src/game/WorldHandlers/GossipDef.cpp b/src/game/WorldHandlers/GossipDef.cpp index 0abc55c0..a6417bea 100644 --- a/src/game/WorldHandlers/GossipDef.cpp +++ b/src/game/WorldHandlers/GossipDef.cpp @@ -41,7 +41,7 @@ GossipMenu::~GossipMenu() ClearMenu(); } -void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, bool Coded) +void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, uint32 BoxMoney, bool Coded) { MANGOS_ASSERT(m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS); @@ -53,7 +53,7 @@ void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSe gItem.m_gSender = dtSender; gItem.m_gOptionId = dtAction; gItem.m_gBoxMessage = BoxMessage; - + gItem.m_gBoxMoney = BoxMoney; m_gItems.push_back(gItem); } @@ -78,9 +78,14 @@ void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, bool Coded) AddMenuItem(Icon, std::string(Message ? Message : ""), Coded); } -void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, bool Coded) +void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, bool Coded) { - AddMenuItem(Icon, std::string(Message ? Message : ""), dtSender, dtAction, std::string(BoxMessage ? BoxMessage : ""), Coded); + AddMenuItem(Icon, std::string(Message ? Message : ""), dtSender, dtAction, "", 0,Coded); +} + +void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded) +{ + AddMenuItem(Icon, std::string(Message ? Message : ""), dtSender, dtAction, std::string(BoxMessage ? BoxMessage : ""), BoxMoney, Coded); } void GossipMenu::AddMenuItem(uint8 Icon, int32 itemText, uint32 dtSender, uint32 dtAction, int32 boxText, bool Coded) @@ -173,7 +178,9 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid) data << uint32(iI); data << uint8(gItem.m_gIcon); data << uint8(gItem.m_gCoded); // makes pop up box password + //data << uint32(gItem.m_gBoxMoney); data << gItem.m_gMessage; // text for gossip item, max 0x800 + // data << gItem.m_gBoxMessage; } data << uint32(mQuestMenu.MenuItemCount()); // max count 0x20 diff --git a/src/game/WorldHandlers/GossipDef.h b/src/game/WorldHandlers/GossipDef.h index 406ced7c..e0a97aa2 100644 --- a/src/game/WorldHandlers/GossipDef.h +++ b/src/game/WorldHandlers/GossipDef.h @@ -138,6 +138,7 @@ struct GossipMenuItem uint32 m_gSender; uint32 m_gOptionId; std::string m_gBoxMessage; + uint32 m_gBoxMoney; }; typedef std::vector GossipMenuItemList; @@ -166,12 +167,12 @@ class GossipMenu ~GossipMenu(); void AddMenuItem(uint8 Icon, const std::string& Message, bool Coded = false); - void AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, bool Coded = false); + void AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, uint32 BoxMoney = 0, bool Coded = false); // for using from scripts, don't must be inlined void AddMenuItem(uint8 Icon, char const* Message, bool Coded = false); - void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, bool Coded = false); - + void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, bool Coded = false); + void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney = 0, bool Coded =false); void AddMenuItem(uint8 Icon, int32 itemText, uint32 dtSender, uint32 dtAction, int32 boxText, bool Coded = false); void SetMenuId(uint32 menu_id) { m_gMenuId = menu_id; } diff --git a/src/game/WorldHandlers/NPCHandler.cpp b/src/game/WorldHandlers/NPCHandler.cpp index b0cd7d07..0ea4291b 100644 --- a/src/game/WorldHandlers/NPCHandler.cpp +++ b/src/game/WorldHandlers/NPCHandler.cpp @@ -490,6 +490,13 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data) return; } + if (!sScriptMgr.OnGossipSelect(_player, item, sender, action, code.empty() ? NULL : code.c_str())) + { + DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - item script for %s not found or you can't interact with it.", item->GetProto()->Name1); + return; + } + + // Used by Eluna #ifdef ENABLE_ELUNA sEluna->HandleGossipSelectOption(GetPlayer(), item, GetPlayer()->PlayerTalkClass->GossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GossipOptionAction(gossipListId), code); diff --git a/src/game/WorldHandlers/ScriptMgr.cpp b/src/game/WorldHandlers/ScriptMgr.cpp index 217017b6..071d187c 100644 --- a/src/game/WorldHandlers/ScriptMgr.cpp +++ b/src/game/WorldHandlers/ScriptMgr.cpp @@ -2600,6 +2600,20 @@ bool ScriptMgr::OnGossipHello(Player* pPlayer, GameObject* pGameObject) #endif } +bool ScriptMgr::OnGossipHello(Player* pPlayer, Item* pItem) +{ + // Used by Eluna +#ifdef ENABLE_ELUNA +// TODO ELUNA handler +#endif /* ENABLE_ELUNA */ + +#ifdef ENABLE_SD3 + return SD3::ItemGossipHello(pPlayer, pItem); +#else + return false; +#endif +} + bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code) { #ifdef ENABLE_ELUNA @@ -2669,6 +2683,27 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 #endif } +bool ScriptMgr::OnGossipSelect(Player* pPlayer, Item* pItem, uint32 sender, uint32 action, const char* code) +{ + // Used by Eluna +#ifdef ENABLE_ELUNA +// TODO Add Eluna handlers +#endif /* ENABLE_ELUNA */ + +#ifdef ENABLE_SD3 + if (code) + { + return SD3::ItemGossipSelectWithCode(pPlayer, pItem, sender, action, code); + } + else + { + return SD3::ItemGossipSelect(pPlayer, pItem, sender, action); + } +#else + return false; +#endif +} + bool ScriptMgr::OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest) { // Used by Eluna diff --git a/src/game/WorldHandlers/ScriptMgr.h b/src/game/WorldHandlers/ScriptMgr.h index 4383381f..e8309c9a 100644 --- a/src/game/WorldHandlers/ScriptMgr.h +++ b/src/game/WorldHandlers/ScriptMgr.h @@ -664,8 +664,10 @@ class ScriptMgr char const* GetScriptLibraryVersion() const; bool OnGossipHello(Player* pPlayer, Creature* pCreature); bool OnGossipHello(Player* pPlayer, GameObject* pGameObject); + bool OnGossipHello(Player* pPlayer, Item* pItem); bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code); bool OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code); + bool OnGossipSelect(Player* pPlayer, Item* pItem, uint32 sender, uint32 action, const char* code); bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest); bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest); diff --git a/src/modules/SD3 b/src/modules/SD3 index ee5ee41c..b4fea426 160000 --- a/src/modules/SD3 +++ b/src/modules/SD3 @@ -1 +1 @@ -Subproject commit ee5ee41c913c4935e9d1ec8ced7508c93b942f2b +Subproject commit b4fea426319568b0eeb50a551aacbdb826ce758d