void BattleGround::SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count) { uint32 bmEntry = GetBattlemasterEntry(); if (!bmEntry) return; ItemPrototype const* markProto = ObjectMgr::GetItemPrototype(mark); if (!markProto) return; if (Item* markItem = Item::CreateItem(mark, count, plr)) { // save new item before send markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex(); // subject: item name std::string subject = markProto->Name1; sObjectMgr.GetItemLocaleStrings(markProto->ItemId, loc_idx, &subject); // text std::string textFormat = plr->GetSession()->GetMangosString(LANG_BG_MARK_BY_MAIL); char textBuf[300]; snprintf(textBuf, 300, textFormat.c_str(), GetName(), GetName()); MailDraft(subject, textBuf) .AddItem(markItem) .SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry)); } }
void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) { uint32 bmEntry = GetBattlemasterEntry(); if(!bmEntry) return; ItemPrototype const* markProto = objmgr.GetItemPrototype(mark); if(!markProto) return; if(Item* markItem = Item::CreateItem(mark,count,plr)) { // save new item before send markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted // item MailItemsInfo mi; mi.AddItem(markItem->GetGUIDLow(), markItem->GetEntry(), markItem); // subject: item name std::string subject = markProto->Name1; int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex(); if ( loc_idx >= 0 ) if(ItemLocale const *il = objmgr.GetItemLocale(markProto->ItemId)) if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) subject = il->Name[loc_idx]; // text std::string textFormat = plr->GetSession()->GetMangosString(LANG_BG_MARK_BY_MAIL); char textBuf[300]; snprintf(textBuf,300,textFormat.c_str(),GetName(),GetName()); uint32 itemTextId = objmgr.CreateItemText( textBuf ); WorldSession::SendMailTo(plr, MAIL_CREATURE, MAIL_STATIONERY_NORMAL, bmEntry, plr->GetGUIDLow(), subject, itemTextId , &mi, 0, 0, MAIL_CHECK_MASK_NONE); } }