mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[9602] Simplify creating mail draft with content text, cleanup includes.
This commit is contained in:
parent
b20f9138f6
commit
a27ff3e79d
12 changed files with 58 additions and 46 deletions
|
|
@ -29,6 +29,7 @@
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
#include "ArenaTeam.h"
|
#include "ArenaTeam.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
|
#include "Mail.h"
|
||||||
#include "GridNotifiersImpl.h"
|
#include "GridNotifiersImpl.h"
|
||||||
#include "CellImpl.h"
|
#include "CellImpl.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
|
|
@ -1829,9 +1830,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 itemTextId = sObjectMgr.CreateItemText( text );
|
MailDraft draft(subject, text);
|
||||||
|
|
||||||
MailDraft draft(subject, itemTextId);
|
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "UpdateMask.h"
|
#include "UpdateMask.h"
|
||||||
#include "AuctionHouseMgr.h"
|
#include "AuctionHouseMgr.h"
|
||||||
|
#include "Mail.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
//please DO NOT use iterator++, because it is slower than ++iterator!!!
|
//please DO NOT use iterator++, because it is slower than ++iterator!!!
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
|
#include "Mail.h"
|
||||||
|
|
||||||
#include "Policies/SingletonImp.h"
|
#include "Policies/SingletonImp.h"
|
||||||
|
|
||||||
|
|
@ -134,9 +135,6 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
|
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
|
||||||
sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() );
|
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)
|
// set owner to bidder (to prevent delete item with sender char deleting)
|
||||||
// owner in `data` will set at mail receive and item extracting
|
// 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());
|
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 !!
|
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
|
||||||
|
|
||||||
// will delete item or place to receiver mail list
|
// will delete item or place to receiver mail list
|
||||||
MailDraft(msgAuctionWonSubject.str(), itemTextId)
|
MailDraft(msgAuctionWonSubject.str(), msgAuctionWonBody.str())
|
||||||
.AddItem(pItem)
|
.AddItem(pItem)
|
||||||
.SendMailTo(MailReceiver(bidder,auction->bidder), auction, MAIL_CHECK_MASK_AUCTION);
|
.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());
|
sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str());
|
||||||
|
|
||||||
uint32 itemTextId = sObjectMgr.CreateItemText( msgAuctionSalePendingBody.str() );
|
MailDraft(msgAuctionSalePendingSubject.str(), msgAuctionSalePendingBody.str())
|
||||||
|
|
||||||
MailDraft(msgAuctionSalePendingSubject.str(), itemTextId)
|
|
||||||
.SendMailTo(MailReceiver(owner,auction->owner), auction, MAIL_CHECK_MASK_AUCTION);
|
.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());
|
sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str());
|
||||||
|
|
||||||
uint32 itemTextId = sObjectMgr.CreateItemText( auctionSuccessfulBody.str() );
|
|
||||||
|
|
||||||
uint32 profit = auction->bid + auction->deposit - auctionCut;
|
uint32 profit = auction->bid + auction->deposit - auctionCut;
|
||||||
|
|
||||||
if (owner)
|
if (owner)
|
||||||
|
|
@ -235,7 +229,7 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
|
||||||
owner->GetSession()->SendAuctionOwnerNotification( auction );
|
owner->GetSession()->SendAuctionOwnerNotification( auction );
|
||||||
}
|
}
|
||||||
|
|
||||||
MailDraft(msgAuctionSuccessfulSubject.str(), itemTextId)
|
MailDraft(msgAuctionSuccessfulSubject.str(), auctionSuccessfulBody.str())
|
||||||
.AddMoney(profit)
|
.AddMoney(profit)
|
||||||
.SendMailTo(MailReceiver(owner,auction->owner), auction, MAIL_CHECK_MASK_AUCTION, HOUR);
|
.SendMailTo(MailReceiver(owner,auction->owner), auction, MAIL_CHECK_MASK_AUCTION, HOUR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "Mail.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "Formulas.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());
|
snprintf(textBuf,300,textFormat.c_str(),GetName(),GetName());
|
||||||
uint32 itemTextId = sObjectMgr.CreateItemText( textBuf );
|
uint32 itemTextId = sObjectMgr.CreateItemText( textBuf );
|
||||||
|
|
||||||
MailDraft(subject, itemTextId)
|
MailDraft(subject, textBuf)
|
||||||
.AddItem(markItem)
|
.AddItem(markItem)
|
||||||
.SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry));
|
.SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "CellImpl.h"
|
#include "CellImpl.h"
|
||||||
#include "InstanceSaveMgr.h"
|
#include "InstanceSaveMgr.h"
|
||||||
|
#include "Mail.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#ifdef _DEBUG_VMAPS
|
#ifdef _DEBUG_VMAPS
|
||||||
#include "VMapFactory.h"
|
#include "VMapFactory.h"
|
||||||
|
|
@ -1978,9 +1979,7 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||||
// from console show not existed sender
|
// from console show not existed sender
|
||||||
MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
||||||
|
|
||||||
uint32 itemTextId = !text.empty() ? sObjectMgr.CreateItemText( text ) : 0;
|
MailDraft(subject, text)
|
||||||
|
|
||||||
MailDraft(subject, itemTextId)
|
|
||||||
.SendMailTo(MailReceiver(target,GUID_LOPART(target_guid)),sender);
|
.SendMailTo(MailReceiver(target,GUID_LOPART(target_guid)),sender);
|
||||||
|
|
||||||
std::string nameLink = playerLink(target_name);
|
std::string nameLink = playerLink(target_name);
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include "SkillExtraItems.h"
|
#include "SkillExtraItems.h"
|
||||||
#include "SystemConfig.h"
|
#include "SystemConfig.h"
|
||||||
#include "Config/ConfigEnv.h"
|
#include "Config/ConfigEnv.h"
|
||||||
|
#include "Mail.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "ItemEnchantmentMgr.h"
|
#include "ItemEnchantmentMgr.h"
|
||||||
#include "BattleGroundMgr.h"
|
#include "BattleGroundMgr.h"
|
||||||
|
|
@ -6297,10 +6298,8 @@ bool ChatHandler::HandleSendItemsCommand(const char* args)
|
||||||
// from console show not existed sender
|
// from console show not existed sender
|
||||||
MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
||||||
|
|
||||||
uint32 itemTextId = !text.empty() ? sObjectMgr.CreateItemText( text ) : 0;
|
|
||||||
|
|
||||||
// fill mail
|
// fill mail
|
||||||
MailDraft draft(subject, itemTextId);
|
MailDraft draft(subject, text);
|
||||||
|
|
||||||
for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
|
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
|
// from console show not existed sender
|
||||||
MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
||||||
|
|
||||||
uint32 itemTextId = !text.empty() ? sObjectMgr.CreateItemText( text ) : 0;
|
MailDraft(subject, text)
|
||||||
|
|
||||||
MailDraft(subject, itemTextId)
|
|
||||||
.AddMoney(money)
|
.AddMoney(money)
|
||||||
.SendMailTo(MailReceiver(receiver,GUID_LOPART(receiver_guid)),sender);
|
.SendMailTo(MailReceiver(receiver,GUID_LOPART(receiver_guid)),sender);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -907,6 +907,19 @@ MailReceiver::MailReceiver( Player* receiver,uint32 receiver_lowguid ) : m_recei
|
||||||
{
|
{
|
||||||
ASSERT(!receiver || receiver->GetGUIDLow() == receiver_lowguid);
|
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.
|
* Adds an item to the MailDraft.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ class MailDraft
|
||||||
|
|
||||||
public: // Constructors
|
public: // Constructors
|
||||||
/**
|
/**
|
||||||
* Creates a new MailDraft object.
|
* Creates a new MailDraft object using mail template id.
|
||||||
*
|
*
|
||||||
* @param mailTemplateId The ID of the Template to be used.
|
* @param mailTemplateId The ID of the Template to be used.
|
||||||
* @param a boolean specifying whether the mail needs items or not.
|
* @param a boolean specifying whether the mail needs items or not.
|
||||||
|
|
@ -187,13 +187,20 @@ class MailDraft
|
||||||
: m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_bodyId(0), m_money(0), m_COD(0)
|
: 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 subject The subject of the mail.
|
||||||
* @param itemTextId The id of the body of the mail.
|
* @param itemTextId The id of the body of the mail.
|
||||||
*/
|
*/
|
||||||
MailDraft(std::string subject, uint32 itemTextId = 0)
|
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) {}
|
: 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
|
public: // Accessors
|
||||||
/// Returns the template ID used for this MailDraft.
|
/// Returns the template ID used for this MailDraft.
|
||||||
uint16 GetMailTemplateId() const { return m_mailTemplateId; }
|
uint16 GetMailTemplateId() const { return m_mailTemplateId; }
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "WaypointManager.h"
|
#include "WaypointManager.h"
|
||||||
#include "GossipDef.h"
|
#include "GossipDef.h"
|
||||||
|
#include "Mail.h"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
#include "ItemPrototype.h"
|
#include "ItemPrototype.h"
|
||||||
#include "NPCHandler.h"
|
#include "NPCHandler.h"
|
||||||
#include "Database/DatabaseEnv.h"
|
#include "Database/DatabaseEnv.h"
|
||||||
#include "Mail.h"
|
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
#include "Spell.h"
|
#include "Spell.h"
|
||||||
#include "SocialMgr.h"
|
#include "SocialMgr.h"
|
||||||
#include "AchievementMgr.h"
|
#include "AchievementMgr.h"
|
||||||
|
#include "Mail.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9601"
|
#define REVISION_NR "9602"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue