Restore some commits from trinitycore2 3.1.3

--HG--
branch : trunk
This commit is contained in:
n0n4m3 committed 2009-12-17 13:07:38 +01:00
1 parent 8b95981ed0
commit 89656d5749
12 files changed
+149 -156

No files matched your search

+36 -72
View File
@@ -2572,6 +2572,9 @@ void Player::GiveLevel(uint8 level)
if (Pet* pet = GetPet())
pet->SynchronizeLevelWithOwner();
if (MailLevelReward const* mailReward = objmgr.GetMailLevelReward(level,getRaceMask()))
MailDraft(mailReward->mailTemplateId).SendMailTo(this,MailSender(MAIL_CREATURE,mailReward->senderEntry));
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
}
@@ -4152,27 +4155,38 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
// remove signs from petitions (also remove petitions if owner);
RemovePetitionsAndSigns(playerguid, 10);
// return back all mails with COD and Item 0 1 2 3 4 5 6
QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,mailTemplateId,sender,subject,itemTextId,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid);
// return back all mails with COD and Item 0 1 2 3 4 5 6 7
QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,itemTextId,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid);
if(resultMail)
{
do
{
Field *fields = resultMail->Fetch();
uint32 mail_id = fields[0].GetUInt32();
uint16 mailTemplateId= fields[1].GetUInt16();
uint32 sender = fields[2].GetUInt32();
std::string subject = fields[3].GetCppString();
uint32 itemTextId = fields[4].GetUInt32();
uint32 money = fields[5].GetUInt32();
bool has_items = fields[6].GetBool();
uint16 mailType = fields[1].GetUInt16();
uint16 mailTemplateId= fields[2].GetUInt16();
uint32 sender = fields[3].GetUInt32();
std::string subject = fields[4].GetCppString();
uint32 itemTextId = fields[5].GetUInt32();
uint32 money = fields[6].GetUInt32();
bool has_items = fields[7].GetBool();
//we can return mail now
//so firstly delete the old one
CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mail_id);
MailItemsInfo mi;
// mail not from player
if (mailType != MAIL_NORMAL)
{
if(has_items)
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mail_id);
continue;
}
MailDraft draft(subject, itemTextId);
if (mailTemplateId)
draft = MailDraft(mailTemplateId,false); // itesm already included
if(has_items)
{
// data needs to be at first place for Item::LoadFromDB
@@ -4201,7 +4215,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
continue;
}
mi.AddItem(item_guidlow, item_template, pItem);
draft.AddItem(pItem);
}
while (resultItems->NextRow());
@@ -4213,7 +4227,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
uint32 pl_account = objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
WorldSession::SendReturnToSender(MAIL_NORMAL, pl_account, guid, sender, subject, itemTextId, &mi, money, mailTemplateId);
draft.AddMoney(money).SendReturnToSender(pl_account, guid, sender);
}
while (resultMail->NextRow());
@@ -7897,7 +7911,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
sLog.outDebug(" if(lootid)");
loot->clear();
loot->FillLoot(lootid, LootTemplates_Gameobject, this, false, go->GetLootMode());
loot->FillLoot(lootid, LootTemplates_Gameobject, this, false, false, go->GetLootMode());
}
if (loot_type == LOOT_FISHING)
@@ -8026,7 +8040,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
loot->clear();
if (uint32 lootid = creature->GetCreatureInfo()->lootid)
loot->FillLoot(lootid, LootTemplates_Creature, recipient, false, creature->GetLootMode());
loot->FillLoot(lootid, LootTemplates_Creature, recipient, false, false, creature->GetLootMode());
loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold,creature->GetCreatureInfo()->maxgold);
@@ -13379,56 +13393,8 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
}
// Send reward mail
if (pQuest->GetRewMailTemplateId())
{
MailMessageType mailType;
uint32 senderGuidOrEntry;
switch(questGiver->GetTypeId())
{
case TYPEID_UNIT:
mailType = MAIL_CREATURE;
senderGuidOrEntry = questGiver->GetEntry();
break;
case TYPEID_GAMEOBJECT:
mailType = MAIL_GAMEOBJECT;
senderGuidOrEntry = questGiver->GetEntry();
break;
case TYPEID_ITEM:
mailType = MAIL_ITEM;
senderGuidOrEntry = questGiver->GetEntry();
break;
case TYPEID_PLAYER:
mailType = MAIL_NORMAL;
senderGuidOrEntry = questGiver->GetGUIDLow();
break;
default:
mailType = MAIL_NORMAL;
senderGuidOrEntry = GetGUIDLow();
break;
}
Loot questMailLoot;
questMailLoot.FillLoot(pQuest->GetQuestId(), LootTemplates_QuestMail, this,true);
// fill mail
MailItemsInfo mi; // item list preparing
uint32 max_slot = questMailLoot.GetMaxSlotInLootFor(this);
for (uint32 i = 0; mi.size() < MAX_MAIL_ITEMS && i < max_slot; ++i)
{
if (LootItem* lootitem = questMailLoot.LootItemInSlot(i,this))
{
if (Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this))
{
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(this, mailType, MAIL_STATIONERY_NORMAL, senderGuidOrEntry, GetGUIDLow(), "", 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE,pQuest->GetRewMailDelaySecs(),pQuest->GetRewMailTemplateId());
}
if (uint32 mail_template_id = pQuest->GetRewMailTemplateId())
MailDraft(mail_template_id).SendMailTo(this, questGiver, MAIL_CHECK_MASK_NONE, pQuest->GetRewMailDelaySecs());
if (pQuest->IsDaily())
{
@@ -15728,20 +15694,20 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
// send by mail problematic items
while (!problematicItems.empty())
{
std::string subject = GetSession()->GetMangosString(LANG_NOT_EQUIPPED_ITEM);
// fill mail
MailItemsInfo mi; // item list preparing
MailDraft draft(subject);
for (uint8 i = 0; !problematicItems.empty() && i < MAX_MAIL_ITEMS; ++i)
{
Item* item = problematicItems.front();
problematicItems.pop_front();
mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
draft.AddItem(item);
}
std::string subject = GetSession()->GetTrinityString(LANG_NOT_EQUIPPED_ITEM);
WorldSession::SendMailTo(this, MAIL_NORMAL, MAIL_STATIONERY_GM, GetGUIDLow(), GetGUIDLow(), subject, 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
draft.SendMailTo(this, MailSender(this, MAIL_STATIONERY_GM));
}
}
//if(isAlive())
@@ -20172,8 +20138,6 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/)
}
else
{
MailItemsInfo mi;
mi.AddItem(offItem->GetGUIDLow(), offItem->GetEntry(), offItem);
MoveItemFromInventory(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true);
CharacterDatabase.BeginTransaction();
offItem->DeleteFromInventoryDB(); // deletes item from character's inventory
@@ -20181,7 +20145,7 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/)
CharacterDatabase.CommitTransaction();
std::string subject = GetSession()->GetMangosString(LANG_NOT_EQUIPPED_ITEM);
WorldSession::SendMailTo(this, MAIL_NORMAL, MAIL_STATIONERY_GM, GetGUIDLow(), GetGUIDLow(), subject, 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
MailDraft(subject).AddItem(offItem).SendMailTo(this, MailSender(this, MAIL_STATIONERY_GM));
}
}