Minor optimizations to MSG_QUERY_NEXT_MAIL_TIME handler. Author: hunuza

* Do not search for more unread mails when already found 2.
    * Do not call time(NULL) every iteration.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-07-10 08:38:35 +08:00
parent 65eb52de11
commit bf6102e7ed
+27 -25
View File
@@ -772,38 +772,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);
} }