mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
Minor optimizations to MSG_QUERY_NEXT_MAIL_TIME handler.
* Do not search for more unread mails when already found 2. * Do not call time(NULL) every iteration. Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
84e46d76e3
commit
a295979484
1 changed files with 27 additions and 25 deletions
|
|
@ -762,38 +762,40 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ )
|
||||||
{
|
{
|
||||||
data << (uint32) 0; // float
|
data << (uint32) 0; // float
|
||||||
data << (uint32) 0; // count
|
data << (uint32) 0; // count
|
||||||
|
|
||||||
uint32 count = 0;
|
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);
|
Mail *m = (*itr);
|
||||||
// not checked yet, already must be delivered
|
// must be not checked yet
|
||||||
if((m->checked & MAIL_CHECK_MASK_READ)==0 && (m->deliver_time <= time(NULL)))
|
if(m->checked & MAIL_CHECK_MASK_RED)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// and already delivered
|
||||||
|
if(now < m->deliver_time)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
data << (uint64) m->sender; // sender guid
|
||||||
|
|
||||||
|
switch(m->messageType)
|
||||||
{
|
{
|
||||||
++count;
|
case MAIL_AUCTION:
|
||||||
|
data << (uint32) 2;
|
||||||
if(count > 2)
|
data << (uint32) 2;
|
||||||
{
|
data << (uint32) m->stationery;
|
||||||
count = 2;
|
break;
|
||||||
|
default:
|
||||||
|
data << (uint32) 0;
|
||||||
|
data << (uint32) 0;
|
||||||
|
data << (uint32) m->stationery;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
data << (uint64) m->sender; // sender guid
|
|
||||||
|
|
||||||
switch(m->messageType)
|
|
||||||
{
|
|
||||||
case MAIL_AUCTION:
|
|
||||||
data << (uint32) 2;
|
|
||||||
data << (uint32) 2;
|
|
||||||
data << (uint32) m->stationery;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
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
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
data.put<uint32>(4, count);
|
data.put<uint32>(4, count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue