mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
Cleanup.
This commit is contained in:
parent
9a18da03a6
commit
027ea38d54
2 changed files with 91 additions and 91 deletions
|
|
@ -46,13 +46,13 @@ void MailItem::deleteItem( bool inDB )
|
|||
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", item->GetGUIDLow());
|
||||
|
||||
delete item;
|
||||
item=NULL;
|
||||
item = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+1+1+1+4+4+1+4+4+8+1);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+1+1+1+4+4+1+4+4+8+1);
|
||||
|
||||
uint64 mailbox, unk3;
|
||||
std::string receiver, subject, body;
|
||||
|
|
@ -137,7 +137,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
return;
|
||||
}
|
||||
|
||||
uint32 cost = items_count ? 30 * items_count : 30; // price hardcoded in client
|
||||
uint32 cost = items_count ? 30 * items_count : 30; // price hardcoded in client
|
||||
|
||||
uint32 reqmoney = cost + money;
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
Player *receive = objmgr.GetPlayer(rc);
|
||||
|
||||
uint32 rc_team = 0;
|
||||
uint8 mails_count = 0; //do not allow to send to one player more than 100 mails
|
||||
uint8 mails_count = 0; // do not allow to send to one player more than 100 mails
|
||||
|
||||
if(receive)
|
||||
{
|
||||
|
|
@ -168,13 +168,15 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
//do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
|
||||
if (mails_count > 100)
|
||||
{
|
||||
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);
|
||||
return;
|
||||
}
|
||||
// test the receiver's Faction...
|
||||
|
||||
// check the receiver's Faction...
|
||||
if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && GetSecurity() == SEC_PLAYER)
|
||||
{
|
||||
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
|
||||
|
|
@ -265,7 +267,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
|
||||
pl->MoveItemFromInventory(mailItem.item->GetBagSlot(), mailItem.item->GetSlot(), true);
|
||||
CharacterDatabase.BeginTransaction();
|
||||
mailItem.item->DeleteFromInventoryDB(); //deletes item from character's inventory
|
||||
mailItem.item->DeleteFromInventoryDB(); // deletes item from character's inventory
|
||||
mailItem.item->SaveToDB(); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
|
||||
// owner in data will set at mail receive and item extracting
|
||||
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", GUID_LOPART(rc), mailItem.item->GetGUIDLow());
|
||||
|
|
@ -297,7 +299,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
//called when mail is read
|
||||
void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
uint64 mailbox;
|
||||
uint32 mailId;
|
||||
|
|
@ -314,7 +316,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
|
|||
if (pl->unReadMails)
|
||||
--pl->unReadMails;
|
||||
m->checked = m->checked | MAIL_CHECK_MASK_READ;
|
||||
// m->expire_time = time(NULL) + (30 * DAY); // Expire time do not change at reading mail
|
||||
// m->expire_time = time(NULL) + (30 * DAY); // Expire time do not change at reading mail
|
||||
pl->m_mailsUpdated = true;
|
||||
m->state = MAIL_STATE_CHANGED;
|
||||
}
|
||||
|
|
@ -323,7 +325,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
|
|||
//called when client deletes mail
|
||||
void WorldSession::HandleMailDelete(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
uint64 mailbox;
|
||||
uint32 mailId;
|
||||
|
|
@ -343,7 +345,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
uint64 mailbox;
|
||||
uint32 mailId;
|
||||
|
|
@ -389,7 +391,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
|
|||
|
||||
SendReturnToSender(MAIL_NORMAL, GetAccountId(), m->receiver, m->sender, m->subject, m->itemTextId, &mi, m->money, m->mailTemplateId);
|
||||
|
||||
delete m; //we can deallocate old mail
|
||||
delete m; // we can deallocate old mail
|
||||
pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK);
|
||||
}
|
||||
|
||||
|
|
@ -426,7 +428,7 @@ void WorldSession::SendReturnToSender(uint8 messageType, uint32 sender_acc, uint
|
|||
for(MailItemMap::iterator mailItemIter = mi->begin(); mailItemIter != mi->end(); ++mailItemIter)
|
||||
{
|
||||
MailItem& mailItem = mailItemIter->second;
|
||||
mailItem.item->SaveToDB(); // item not in inventory and can be save standalone
|
||||
mailItem.item->SaveToDB(); // item not in inventory and can be save standalone
|
||||
// owner in data will set at mail receive and item extracting
|
||||
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", receiver_guid, mailItem.item->GetGUIDLow());
|
||||
}
|
||||
|
|
@ -437,13 +439,13 @@ void WorldSession::SendReturnToSender(uint8 messageType, uint32 sender_acc, uint
|
|||
uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
|
||||
|
||||
// will delete item or place to receiver mail list
|
||||
WorldSession::SendMailTo(receiver, MAIL_NORMAL, MAIL_STATIONERY_NORMAL, sender_guid, receiver_guid, subject, itemTextId, mi, money, 0, MAIL_CHECK_MASK_RETURNED,deliver_delay,mailTemplateId);
|
||||
WorldSession::SendMailTo(receiver, MAIL_NORMAL, MAIL_STATIONERY_NORMAL, sender_guid, receiver_guid, subject, itemTextId, mi, money, 0, MAIL_CHECK_MASK_RETURNED, deliver_delay, mailTemplateId);
|
||||
}
|
||||
|
||||
//called when player takes item attached in mail
|
||||
void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4+4);
|
||||
|
||||
uint64 mailbox;
|
||||
uint32 mailId;
|
||||
|
|
@ -480,7 +482,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
|||
m->RemoveItem(itemId);
|
||||
m->removedItems.push_back(itemId);
|
||||
|
||||
if (m->COD > 0) //if there is COD, take COD money from player and send them to sender by mail
|
||||
if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail
|
||||
{
|
||||
uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER);
|
||||
Player *receive = objmgr.GetPlayer(sender_guid);
|
||||
|
|
@ -500,11 +502,11 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
|||
// can be calculated early
|
||||
sender_accId = objmgr.GetPlayerAccountIdByGUID(sender_guid);
|
||||
|
||||
if(!objmgr.GetPlayerNameByGUID(sender_guid,sender_name))
|
||||
if(!objmgr.GetPlayerNameByGUID(sender_guid, sender_name))
|
||||
sender_name = objmgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
||||
}
|
||||
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
|
||||
GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId);
|
||||
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
|
||||
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
|
||||
}
|
||||
else if(!receive)
|
||||
sender_accId = objmgr.GetPlayerAccountIdByGUID(sender_guid);
|
||||
|
|
@ -523,7 +525,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
|||
pl->RemoveMItem(it->GetGUIDLow());
|
||||
|
||||
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
|
||||
pl->MoveItemToInventory(dest,it,true);
|
||||
pl->MoveItemToInventory(dest, it, true);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
|
|
@ -538,7 +540,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
uint64 mailbox;
|
||||
uint32 mailId;
|
||||
|
|
@ -582,11 +584,9 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
|
|||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
|
||||
return;
|
||||
|
||||
Player* pl = _player;
|
||||
|
||||
//load players mails, and mailed items
|
||||
if(!pl->m_mailsLoaded)
|
||||
pl ->_LoadMail();
|
||||
// load players mails, and mailed items
|
||||
if(!_player->m_mailsLoaded)
|
||||
_player->_LoadMail();
|
||||
|
||||
// client can't work with packets > max int16 value
|
||||
const uint32 maxPacketSize = 32767;
|
||||
|
|
@ -599,7 +599,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
|
|||
data << uint8(0); // mail's count
|
||||
time_t cur_time = time(NULL);
|
||||
|
||||
for(PlayerMails::iterator itr = pl->GetmailBegin(); itr != pl->GetmailEnd(); ++itr)
|
||||
for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
|
||||
{
|
||||
// skip deleted or not delivered (deliver delay not expired) mails
|
||||
if ((*itr)->state == MAIL_STATE_DELETED || cur_time < (*itr)->deliver_time)
|
||||
|
|
@ -656,7 +656,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
|
|||
|
||||
for(uint8 i = 0; i < item_count; ++i)
|
||||
{
|
||||
Item *item = pl->GetMItem((*itr)->items[i].item_guid);
|
||||
Item *item = _player->GetMItem((*itr)->items[i].item_guid);
|
||||
// item index (0-6?)
|
||||
data << uint8(i);
|
||||
// item guid low?
|
||||
|
|
@ -703,11 +703,11 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
|
|||
///this function is called when client needs mail message body, or when player clicks on item which has ITEM_FIELD_ITEM_TEXT_ID > 0
|
||||
void WorldSession::HandleItemTextQuery(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,4+4+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 4+4+4);
|
||||
|
||||
uint32 itemTextId;
|
||||
uint32 mailId; //this value can be item id in bag, but it is also mail id
|
||||
uint32 unk; //maybe something like state - 0x70000000
|
||||
uint32 mailId; // this value can be item id in bag, but it is also mail id
|
||||
uint32 unk; // maybe something like state - 0x70000000
|
||||
|
||||
recv_data >> itemTextId >> mailId >> unk;
|
||||
|
||||
|
|
@ -724,7 +724,7 @@ void WorldSession::HandleItemTextQuery(WorldPacket & recv_data )
|
|||
//used when player copies mail body to his inventory
|
||||
void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
uint64 mailbox;
|
||||
uint32 mailId;
|
||||
|
|
@ -750,7 +750,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
|
|||
return;
|
||||
}
|
||||
|
||||
bodyItem->SetUInt32Value( ITEM_FIELD_ITEM_TEXT_ID , m->itemTextId );
|
||||
bodyItem->SetUInt32Value( ITEM_FIELD_ITEM_TEXT_ID, m->itemTextId );
|
||||
bodyItem->SetUInt32Value( ITEM_FIELD_CREATOR, m->sender);
|
||||
|
||||
sLog.outDetail("HandleMailCreateTextItem mailid=%u",mailId);
|
||||
|
|
@ -784,12 +784,12 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ )
|
|||
|
||||
if( _player->unReadMails > 0 )
|
||||
{
|
||||
data << (uint32) 0; // float
|
||||
data << (uint32) 0; // count
|
||||
data << uint32(0); // float
|
||||
data << uint32(0); // count
|
||||
|
||||
uint32 count = 0;
|
||||
time_t now = time(NULL);
|
||||
for(PlayerMails::iterator itr = _player->GetmailBegin(); itr != _player->GetmailEnd(); ++itr)
|
||||
for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
|
||||
{
|
||||
Mail *m = (*itr);
|
||||
// must be not checked yet
|
||||
|
|
@ -800,22 +800,23 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ )
|
|||
if(now < m->deliver_time)
|
||||
continue;
|
||||
|
||||
data << (uint64) m->sender; // sender guid
|
||||
data << uint64(m->sender); // sender guid
|
||||
|
||||
switch(m->messageType)
|
||||
{
|
||||
case MAIL_AUCTION:
|
||||
data << (uint32) 2;
|
||||
data << (uint32) 2;
|
||||
data << (uint32) m->stationery;
|
||||
data << uint32(2);
|
||||
data << uint32(2);
|
||||
data << uint32(m->stationery);
|
||||
break;
|
||||
default:
|
||||
data << (uint32) 0;
|
||||
data << (uint32) 0;
|
||||
data << (uint32) m->stationery;
|
||||
data << uint32(0);
|
||||
data << uint32(0);
|
||||
data << uint32(m->stationery);
|
||||
break;
|
||||
}
|
||||
data << (uint32) 0xC6000000; // float unk, time or something
|
||||
|
||||
data << uint32(0xC6000000); // float unk, time or something
|
||||
|
||||
++count;
|
||||
if(count == 2) // do not display more than 2 mails
|
||||
|
|
@ -825,8 +826,8 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ )
|
|||
}
|
||||
else
|
||||
{
|
||||
data << (uint32) 0xC7A8C000;
|
||||
data << (uint32) 0x00000000;
|
||||
data << uint32(0xC7A8C000);
|
||||
data << uint32(0x00000000);
|
||||
}
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
|
@ -837,12 +838,12 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station
|
|||
|
||||
time_t deliver_time = time(NULL) + deliver_delay;
|
||||
|
||||
//expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
|
||||
// expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
|
||||
uint32 expire_delay;
|
||||
if(messageType == MAIL_AUCTION && !mi && !money) // auction mail without any items and money
|
||||
expire_delay = HOUR;
|
||||
else
|
||||
expire_delay = (COD > 0) ? 3*DAY : 30*DAY;
|
||||
expire_delay = (COD > 0) ? 3 * DAY : 30 * DAY;
|
||||
|
||||
time_t expire_time = deliver_time + expire_delay;
|
||||
|
||||
|
|
@ -858,7 +859,7 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station
|
|||
|
||||
if ( receiver->IsMailsLoaded() )
|
||||
{
|
||||
Mail * m = new Mail;
|
||||
Mail *m = new Mail;
|
||||
m->messageID = mailId;
|
||||
m->messageType = messageType;
|
||||
m->stationery = stationery;
|
||||
|
|
@ -878,7 +879,7 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station
|
|||
m->checked = checked;
|
||||
m->state = MAIL_STATE_UNCHANGED;
|
||||
|
||||
receiver->AddMail(m); //to insert new mail to beginning of maillist
|
||||
receiver->AddMail(m); // to insert new mail to beginning of maillist
|
||||
|
||||
if(mi)
|
||||
{
|
||||
|
|
@ -907,7 +908,7 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station
|
|||
for(MailItemMap::const_iterator mailItemIter = mi->begin(); mailItemIter != mi->end(); ++mailItemIter)
|
||||
{
|
||||
MailItem const& mailItem = mailItemIter->second;
|
||||
CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", mailId, mailItem.item_guidlow, mailItem.item_template,receiver_guidlow);
|
||||
CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", mailId, mailItem.item_guidlow, mailItem.item_template, receiver_guidlow);
|
||||
}
|
||||
}
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue