diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index d630f8c6e..5a61c4e93 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -29,6 +29,7 @@ #include "SpellMgr.h" #include "ArenaTeam.h" #include "ProgressBar.h" +#include "Mail.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" #include "Language.h" @@ -1829,9 +1830,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) } } - uint32 itemTextId = sObjectMgr.CreateItemText( text ); - - MailDraft draft(subject, itemTextId); + MailDraft draft(subject, text); if(item) { diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index 1a8425c42..343c83133 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -26,6 +26,7 @@ #include "Player.h" #include "UpdateMask.h" #include "AuctionHouseMgr.h" +#include "Mail.h" #include "Util.h" //please DO NOT use iterator++, because it is slower than ++iterator!!! diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 4f26b1394..f8a975192 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -33,6 +33,7 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" +#include "Mail.h" #include "Policies/SingletonImp.h" @@ -134,9 +135,6 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout; sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() ); - //prepare mail data... : - uint32 itemTextId = sObjectMgr.CreateItemText( msgAuctionWonBody.str() ); - // set owner to bidder (to prevent delete item with sender char deleting) // owner in `data` will set at mail receive and item extracting CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow()); @@ -152,7 +150,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! // will delete item or place to receiver mail list - MailDraft(msgAuctionWonSubject.str(), itemTextId) + MailDraft(msgAuctionWonSubject.str(), msgAuctionWonBody.str()) .AddItem(pItem) .SendMailTo(MailReceiver(bidder,auction->bidder), auction, MAIL_CHECK_MASK_AUCTION); } @@ -189,9 +187,7 @@ void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); - uint32 itemTextId = sObjectMgr.CreateItemText( msgAuctionSalePendingBody.str() ); - - MailDraft(msgAuctionSalePendingSubject.str(), itemTextId) + MailDraft(msgAuctionSalePendingSubject.str(), msgAuctionSalePendingBody.str()) .SendMailTo(MailReceiver(owner,auction->owner), auction, MAIL_CHECK_MASK_AUCTION); } } @@ -222,8 +218,6 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); - uint32 itemTextId = sObjectMgr.CreateItemText( auctionSuccessfulBody.str() ); - uint32 profit = auction->bid + auction->deposit - auctionCut; if (owner) @@ -235,7 +229,7 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) owner->GetSession()->SendAuctionOwnerNotification( auction ); } - MailDraft(msgAuctionSuccessfulSubject.str(), itemTextId) + MailDraft(msgAuctionSuccessfulSubject.str(), auctionSuccessfulBody.str()) .AddMoney(profit) .SendMailTo(MailReceiver(owner,auction->owner), auction, MAIL_CHECK_MASK_AUCTION, HOUR); } diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 368bab43b..b9561045b 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -29,6 +29,7 @@ #include "Group.h" #include "ObjectGuid.h" #include "ObjectMgr.h" +#include "Mail.h" #include "WorldPacket.h" #include "Util.h" #include "Formulas.h" @@ -965,7 +966,7 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) snprintf(textBuf,300,textFormat.c_str(),GetName(),GetName()); uint32 itemTextId = sObjectMgr.CreateItemText( textBuf ); - MailDraft(subject, itemTextId) + MailDraft(subject, textBuf) .AddItem(markItem) .SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry)); } diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 69022ce56..cf3537543 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -31,6 +31,7 @@ #include "Language.h" #include "CellImpl.h" #include "InstanceSaveMgr.h" +#include "Mail.h" #include "Util.h" #ifdef _DEBUG_VMAPS #include "VMapFactory.h" @@ -1978,9 +1979,7 @@ bool ChatHandler::HandleSendMailCommand(const char* args) // from console show not existed sender MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); - uint32 itemTextId = !text.empty() ? sObjectMgr.CreateItemText( text ) : 0; - - MailDraft(subject, itemTextId) + MailDraft(subject, text) .SendMailTo(MailReceiver(target,GUID_LOPART(target_guid)),sender); std::string nameLink = playerLink(target_name); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 91400aede..103b08a27 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -44,6 +44,7 @@ #include "SkillExtraItems.h" #include "SystemConfig.h" #include "Config/ConfigEnv.h" +#include "Mail.h" #include "Util.h" #include "ItemEnchantmentMgr.h" #include "BattleGroundMgr.h" @@ -6297,10 +6298,8 @@ bool ChatHandler::HandleSendItemsCommand(const char* args) // from console show not existed sender MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); - uint32 itemTextId = !text.empty() ? sObjectMgr.CreateItemText( text ) : 0; - // fill mail - MailDraft draft(subject, itemTextId); + MailDraft draft(subject, text); for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) { @@ -6357,9 +6356,7 @@ bool ChatHandler::HandleSendMoneyCommand(const char* args) // from console show not existed sender MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); - uint32 itemTextId = !text.empty() ? sObjectMgr.CreateItemText( text ) : 0; - - MailDraft(subject, itemTextId) + MailDraft(subject, text) .AddMoney(money) .SendMailTo(MailReceiver(receiver,GUID_LOPART(receiver_guid)),sender); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 67fd3427f..5f11e0f48 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -907,6 +907,19 @@ MailReceiver::MailReceiver( Player* receiver,uint32 receiver_lowguid ) : m_recei { ASSERT(!receiver || receiver->GetGUIDLow() == receiver_lowguid); } + +/** + * Creates a new MailDraft object using subject and contect texts. + * + * @param subject The subject of the mail. + * @param itemText The text of the body of the mail. + */ +MailDraft::MailDraft( std::string subject, std::string text ) : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_subject(subject), +m_bodyId(!text.empty() ? sObjectMgr.CreateItemText(text) : 0), m_money(0), m_COD(0) +{ + +} + /** * Adds an item to the MailDraft. * diff --git a/src/game/Mail.h b/src/game/Mail.h index df45eddc4..c29b46451 100644 --- a/src/game/Mail.h +++ b/src/game/Mail.h @@ -109,15 +109,15 @@ enum MailAuctionAnswers class MailSender { public: // Constructors - /** - * Creates a new MailSender object. - * - * @param messageType the type of the mail. - * @param sender_guidlow_or_entry The lower part of the GUID of the player sending - * this mail, or the Entry of the non-player object. - * @param stationery The stationary associated with this MailSender. - * - */ + /** + * Creates a new MailSender object. + * + * @param messageType the type of the mail. + * @param sender_guidlow_or_entry The lower part of the GUID of the player sending + * this mail, or the Entry of the non-player object. + * @param stationery The stationary associated with this MailSender. + * + */ MailSender(MailMessageType messageType, uint32 sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_NORMAL) : m_messageType(messageType), m_senderId(sender_guidlow_or_entry), m_stationery(stationery) { @@ -170,30 +170,37 @@ class MailReceiver */ class MailDraft { - /** - * Holds a Map of GUIDs of items and pointers to the items. - */ - typedef std::map MailItemMap; + /** + * Holds a Map of GUIDs of items and pointers to the items. + */ + typedef std::map MailItemMap; public: // Constructors - /** - * Creates a new MailDraft object. - * - * @param mailTemplateId The ID of the Template to be used. - * @param a boolean specifying whether the mail needs items or not. - * - */ + /** + * Creates a new MailDraft object using mail template id. + * + * @param mailTemplateId The ID of the Template to be used. + * @param a boolean specifying whether the mail needs items or not. + * + */ explicit MailDraft(uint16 mailTemplateId, bool need_items = true) : m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_bodyId(0), m_money(0), m_COD(0) {} /** - * Creates a new MailDraft object. + * Creates a new MailDraft object using subject text and content text id. * * @param subject The subject of the mail. * @param itemTextId The id of the body of the mail. */ MailDraft(std::string subject, uint32 itemTextId = 0) : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_subject(subject), m_bodyId(itemTextId), m_money(0), m_COD(0) {} + /** + * Creates a new MailDraft object using subject and contect texts. + * + * @param subject The subject of the mail. + * @param itemText The text of the body of the mail. + */ + MailDraft(std::string subject, std::string text); public: // Accessors /// Returns the template ID used for this MailDraft. uint16 GetMailTemplateId() const { return m_mailTemplateId; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index b6997b746..f863a4cff 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -44,6 +44,7 @@ #include "Util.h" #include "WaypointManager.h" #include "GossipDef.h" +#include "Mail.h" #include diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 8df515bc4..0cd054708 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -31,7 +31,6 @@ #include "ItemPrototype.h" #include "NPCHandler.h" #include "Database/DatabaseEnv.h" -#include "Mail.h" #include "Map.h" #include "ObjectAccessor.h" #include "ObjectGuid.h" diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2992f68e4..c45fc3fb6 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -60,6 +60,7 @@ #include "Spell.h" #include "SocialMgr.h" #include "AchievementMgr.h" +#include "Mail.h" #include diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 299583e7d..a3d5580ce 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 "9601" + #define REVISION_NR "9602" #endif // __REVISION_NR_H__