diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 0871a2a9c..943296244 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -24,7 +24,7 @@ #include "WorldSession.h" #include "Formulas.h" -GossipMenu::GossipMenu() +GossipMenu::GossipMenu(WorldSession* session) : m_session(session) { m_gItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use m_gMenuId = 0; @@ -78,6 +78,16 @@ void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, u 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, uint32 BoxMoney, bool Coded) +{ + uint32 loc_idx = m_session->GetSessionDbLocaleIndex(); + + char const* item_text = itemText ? sObjectMgr.GetMangosString(itemText, loc_idx) : ""; + char const* box_text = boxText ? sObjectMgr.GetMangosString(boxText, loc_idx) : ""; + + AddMenuItem(Icon, std::string(item_text), dtSender, dtAction, std::string(box_text), BoxMoney, Coded); +} + uint32 GossipMenu::MenuItemSender( unsigned int ItemId ) { if ( ItemId >= m_gItems.size() ) @@ -109,7 +119,7 @@ void GossipMenu::ClearMenu() m_gMenuId = 0; } -PlayerMenu::PlayerMenu( WorldSession *session ) : pSession(session) +PlayerMenu::PlayerMenu(WorldSession *session) : mGossipMenu(session) { } @@ -173,7 +183,7 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, uint64 objectGUID) data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation std::string Title = pQuest->GetTitle(); - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(questID)) if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty()) @@ -181,14 +191,14 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, uint64 objectGUID) data << Title; // max 0x200 } - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); //DEBUG_LOG( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) ); } void PlayerMenu::CloseGossip() { WorldPacket data( SMSG_GOSSIP_COMPLETE, 0 ); - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); //DEBUG_LOG( "WORLD: Sent SMSG_GOSSIP_COMPLETE" ); } @@ -204,7 +214,7 @@ void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flag data << uint32(Data); data << locName; - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); //DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI"); } @@ -219,7 +229,7 @@ void PlayerMenu::SendPointOfInterest( uint32 poi_id ) std::string icon_name = poi->icon_name; - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) if (PointOfInterestLocale const *pl = sObjectMgr.GetPointOfInterestLocale(poi_id)) if (pl->IconName.size() > size_t(loc_idx) && !pl->IconName[loc_idx].empty()) @@ -233,7 +243,7 @@ void PlayerMenu::SendPointOfInterest( uint32 poi_id ) data << uint32(poi->data); data << icon_name; - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); //DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI"); } @@ -268,7 +278,7 @@ void PlayerMenu::SendTalking( uint32 textID ) Text_0[i] = pGossip->Options[i].Text_0; Text_1[i] = pGossip->Options[i].Text_1; } - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID)) @@ -305,7 +315,7 @@ void PlayerMenu::SendTalking( uint32 textID ) } } } - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); } @@ -328,7 +338,7 @@ void PlayerMenu::SendTalking( char const * title, char const * text ) data << uint32(0); } - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); } @@ -397,7 +407,7 @@ void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, const std::string& Titl { std::string title = pQuest->GetTitle(); - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if(QuestLocale const *ql = sObjectMgr.GetQuestLocale(questID)) @@ -416,7 +426,7 @@ void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, const std::string& Titl } } data.put(count_pos, count); - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID)); } @@ -426,7 +436,7 @@ void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID ) data << uint64(npcGUID); data << uint8(questStatus); - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID), questStatus); } @@ -436,7 +446,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID std::string Details = pQuest->GetDetails(); std::string Objectives = pQuest->GetObjectives(); - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) @@ -510,12 +520,12 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID } // send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney - if (pSession->GetPlayer()->getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (GetMenuSession()->GetPlayer()->getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) data << uint32(pQuest->GetRewMoneyMaxLevel()); else data << uint32(pQuest->GetRewOrReqMoney()); - data << uint32(pQuest->XPValue(pSession->GetPlayer())); + data << uint32(pQuest->XPValue(GetMenuSession()->GetPlayer())); } // TODO: fixme. rewarded honor points @@ -547,7 +557,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID data << uint32(pQuest->DetailsEmoteDelay[i]); // DetailsEmoteDelay (in ms) } - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId()); } @@ -566,7 +576,7 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) ObjectiveText[i] = pQuest->ObjectiveText[i]; - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) @@ -698,7 +708,7 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; ++iI) data << ObjectiveText[iI]; - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest->GetQuestId() ); } @@ -707,7 +717,7 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, std::string Title = pQuest->GetTitle(); std::string OfferRewardText = pQuest->GetOfferRewardText(); - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) @@ -775,15 +785,16 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, } // send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney - if (pSession->GetPlayer()->getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (GetMenuSession()->GetPlayer()->getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) data << uint32(pQuest->GetRewMoneyMaxLevel()); else data << uint32(pQuest->GetRewOrReqMoney()); - data << uint32(pQuest->XPValue(pSession->GetPlayer())); // xp + // xp + data << uint32(pQuest->XPValue(GetMenuSession()->GetPlayer())); // TODO: fixme. rewarded honor points. Multiply with 10 to satisfy client - data << uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorAddition())); + data << uint32(10*MaNGOS::Honor::hk_honor_at_level(GetMenuSession()->GetPlayer()->getLevel(), pQuest->GetRewHonorAddition())); data << float(pQuest->GetRewHonorMultiplier()); data << uint32(0x08); // unused by client? @@ -804,7 +815,7 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, data << int32(0); //data << int32(pQuest->RewRepValue[i]); - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId() ); } @@ -816,7 +827,7 @@ void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID std::string Title = pQuest->GetTitle(); std::string RequestItemsText = pQuest->GetRequestItemsText(); - int loc_idx = pSession->GetSessionDbLocaleIndex(); + int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) { if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) @@ -884,6 +895,6 @@ void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID data << uint32(0x08); // flags3 data << uint32(0x10); // flags4 - pSession->SendPacket( &data ); + GetMenuSession()->SendPacket( &data ); DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId() ); } diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h index 98caf2277..60b98bc41 100644 --- a/src/game/GossipDef.h +++ b/src/game/GossipDef.h @@ -156,7 +156,7 @@ typedef std::vector QuestMenuItemList; class MANGOS_DLL_SPEC GossipMenu { public: - GossipMenu(); + explicit GossipMenu(WorldSession* session); ~GossipMenu(); void AddMenuItem(uint8 Icon, const std::string& Message, bool Coded = false); @@ -166,6 +166,8 @@ class MANGOS_DLL_SPEC GossipMenu void AddMenuItem(uint8 Icon, char const* Message, bool Coded = false); void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded = false); + void AddMenuItem(uint8 Icon, int32 itemText, uint32 dtSender, uint32 dtAction, int32 boxText, uint32 BoxMoney, bool Coded = false); + void SetMenuId(uint32 menu_id) { m_gMenuId = menu_id; } uint32 GetMenuId() { return m_gMenuId; } @@ -197,11 +199,16 @@ class MANGOS_DLL_SPEC GossipMenu void ClearMenu(); + WorldSession* GetMenuSession() const { return m_session; } + protected: GossipMenuItemList m_gItems; GossipMenuItemDataList m_gItemsData; uint32 m_gMenuId; + + private: + WorldSession* m_session; }; class QuestMenu @@ -239,15 +246,16 @@ class MANGOS_DLL_SPEC PlayerMenu private: GossipMenu mGossipMenu; QuestMenu mQuestMenu; - WorldSession* pSession; public: - PlayerMenu( WorldSession *Session ); + explicit PlayerMenu(WorldSession *Session); ~PlayerMenu(); GossipMenu& GetGossipMenu() { return mGossipMenu; } QuestMenu& GetQuestMenu() { return mQuestMenu; } + WorldSession* GetMenuSession() const { return mGossipMenu.GetMenuSession(); } + bool Empty() const { return mGossipMenu.Empty() && mQuestMenu.Empty(); } void ClearMenus(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d64bc4b67..c64418ca0 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 "10304" + #define REVISION_NR "10305" #endif // __REVISION_NR_H__