mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[8749] Rename quest_mail_loot_template to mail_loot_template.
Store loot in mail_loot_template indexed by mail template ids. Provide new SendMail functions for send mail base at mail template.
This commit is contained in:
parent
aa4524852e
commit
3c53dded97
14 changed files with 128 additions and 116 deletions
|
|
@ -899,3 +899,60 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station
|
|||
}
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
void WorldSession::SendMailTo(Player* receiver, Object* sender, uint8 stationery, uint32 receiver_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay, uint16 mailTemplateId)
|
||||
{
|
||||
MailMessageType mailType;
|
||||
uint32 senderGuidOrEntry;
|
||||
switch(sender->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
mailType = MAIL_CREATURE;
|
||||
senderGuidOrEntry = sender->GetEntry();
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
mailType = MAIL_GAMEOBJECT;
|
||||
senderGuidOrEntry = sender->GetEntry();
|
||||
break;
|
||||
case TYPEID_ITEM:
|
||||
mailType = MAIL_ITEM;
|
||||
senderGuidOrEntry = sender->GetEntry();
|
||||
break;
|
||||
case TYPEID_PLAYER:
|
||||
mailType = MAIL_NORMAL;
|
||||
senderGuidOrEntry = sender->GetGUIDLow();
|
||||
break;
|
||||
default:
|
||||
mailType = MAIL_NORMAL;
|
||||
senderGuidOrEntry = receiver_guidlow;
|
||||
sLog.outError( "WorldSession::SendMailTo - Mail have unexpected sender typeid (%u), sent from receiver to self", sender->GetTypeId());
|
||||
break;
|
||||
}
|
||||
|
||||
SendMailTo(receiver, mailType, stationery, senderGuidOrEntry, receiver_guidlow, subject, itemTextId, mi, money, COD, checked,deliver_delay,mailTemplateId);
|
||||
}
|
||||
|
||||
void WorldSession::SendMailTemplateTo(Player* receiver, Object* sender, uint8 stationery, uint16 mailTemplateId, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay)
|
||||
{
|
||||
Loot mailLoot;
|
||||
|
||||
mailLoot.FillLoot(mailTemplateId, LootTemplates_Mail, receiver,true);
|
||||
|
||||
// fill mail
|
||||
MailItemsInfo mi; // item list preparing
|
||||
|
||||
uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver);
|
||||
for(uint32 i = 0; mi.size() < MAX_MAIL_ITEMS && i < max_slot; ++i)
|
||||
{
|
||||
if (LootItem* lootitem = mailLoot.LootItemInSlot(i,receiver))
|
||||
{
|
||||
if (Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,receiver))
|
||||
{
|
||||
item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
|
||||
mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WorldSession::SendMailTo(receiver, sender, stationery, receiver->GetGUIDLow(), "", 0, &mi, money, COD, checked,deliver_delay,mailTemplateId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue