Added support for RODEX 2017 (#2290)

This commit is contained in:
Lemongrass3110 2017-07-27 21:52:43 +02:00 committed by GitHub
parent 3a55613537
commit 02135c4e2e
2 changed files with 67 additions and 10 deletions

View File

@ -14993,6 +14993,8 @@ void clif_Mail_window(int fd, int flag)
/// { <mail id>.Q <read>.B <type>.B <sender>.24B <received>.L <expires>.L <title length>.W <title>.?B }*
/// 0a7d <packet len>.W <type>.B <amount>.B <last page>.B (ZC_ACK_MAIL_LIST2)
/// { <mail id>.Q <read>.B <type>.B <sender>.24B <received>.L <expires>.L <title length>.W <title>.?B }*
/// 0ac2 <packet len>.W <unknown>.B (ZC_ACK_MAIL_LIST3)
/// { <type>.B <mail id>.Q <read>.B <type>.B <sender>.24B <expires>.L <title length>.W <title>.?B }*
void clif_Mail_refreshinbox(struct map_session_data *sd,enum mail_inbox_type type,int64 mailID){
#if PACKETVER < 20150513
int fd = sd->fd;
@ -15033,7 +15035,9 @@ void clif_Mail_refreshinbox(struct map_session_data *sd,enum mail_inbox_type typ
int i, j, k, offset, titleLength;
uint8 mailType, amount, remaining;
uint32 now = (uint32)time(NULL);
#if PACKETVER >= 20160601
#if PACKETVER >= 20170419
int cmd = 0xac2;
#elif PACKETVER >= 20160601
int cmd = 0xa7d;
#else
int cmd = 0x9f0;
@ -15043,6 +15047,10 @@ void clif_Mail_refreshinbox(struct map_session_data *sd,enum mail_inbox_type typ
mail_refresh_remaining_amount(sd);
}
#if PACKETVER >= 20170419
// Always send all
i = md->amount;
#else
// If a starting mail id was sent
if( mailID != 0 ){
ARR_FIND( 0, md->amount, i, md->msg[i].id == mailID );
@ -15063,44 +15071,65 @@ void clif_Mail_refreshinbox(struct map_session_data *sd,enum mail_inbox_type typ
}else{
i = md->amount;
}
#endif
// Count the remaining mails from the starting mail or the beginning
// Only count mails of the target type and those that should not have been deleted already
// Only count mails of the target type(before 2017-04-19) and those that should not have been deleted already
for( j = i, remaining = 0; j >= 0; j-- ){
msg = &md->msg[j];
if (msg->id < 1)
continue;
#if PACKETVER < 20170419
if (msg->type != type)
continue;
#endif
if (msg->scheduled_deletion > 0 && msg->scheduled_deletion <= now)
continue;
remaining++;
}
#if PACKETVER >= 20170419
// Always send all
amount = remaining;
#else
if( remaining > MAIL_PAGE_SIZE ){
amount = MAIL_PAGE_SIZE;
}else{
amount = remaining;
}
#endif
WFIFOHEAD(fd, 7 + ((44 + MAIL_TITLE_LENGTH) * amount));
WFIFOW(fd, 0) = cmd;
#if PACKETVER >= 20170419
WFIFOB(fd, 4) = 1; // Unknown
offset = 5;
#else
WFIFOB(fd, 4) = type;
WFIFOB(fd, 5) = amount;
WFIFOB(fd, 6) = ( remaining < MAIL_PAGE_SIZE ); // last page
offset = 7;
#endif
for( offset = 7, amount = 0; i >= 0; i-- ){
for( amount = 0; i >= 0; i-- ){
msg = &md->msg[i];
if (msg->id < 1)
continue;
#if PACKETVER < 20170419
if (msg->type != type)
continue;
#endif
if (msg->scheduled_deletion > 0 && msg->scheduled_deletion <= now)
continue;
#if PACKETVER >= 20170419
WFIFOB(fd, offset) = msg->type;
offset += 1;
#endif
WFIFOQ(fd, offset + 0) = (uint64)msg->id;
WFIFOB(fd, offset + 8) = (msg->status != MAIL_UNREAD);
@ -15123,22 +15152,25 @@ void clif_Mail_refreshinbox(struct map_session_data *sd,enum mail_inbox_type typ
WFIFOB(fd, offset + 9) = mailType;
safestrncpy(WFIFOCP(fd, offset + 10), msg->send_name, NAME_LENGTH);
#if PACKETVER < 20170419
// How much time has passed since you received the mail
WFIFOL(fd, offset + 34 ) = now - (uint32)msg->timestamp;
offset += 4;
#endif
// If automatic return/deletion of mails is enabled, notify the client when it will kick in
if( msg->scheduled_deletion > 0 ){
WFIFOL(fd, offset + 38) = (uint32)msg->scheduled_deletion - now;
WFIFOL(fd, offset + 34) = (uint32)msg->scheduled_deletion - now;
}else{
// Fake the scheduled deletion to one year in the future
// Sadly the client always displays the scheduled deletion after 24 hours no matter how high this value gets [Lemongrass]
WFIFOL(fd, offset + 38) = 365 * 24 * 60 * 60;
WFIFOL(fd, offset + 34) = 365 * 24 * 60 * 60;
}
WFIFOW(fd, offset + 42) = titleLength = (int16)(strlen(msg->title) + 1);
safestrncpy(WFIFOCP(fd, offset + 44), msg->title, titleLength);
WFIFOW(fd, offset + 38) = titleLength = (int16)(strlen(msg->title) + 1);
safestrncpy(WFIFOCP(fd, offset + 40), msg->title, titleLength);
offset += 44 + titleLength;
offset += 40 + titleLength;
}
WFIFOW(fd, 2) = (int16)offset;
WFIFOSET(fd, offset);
@ -15150,6 +15182,8 @@ void clif_Mail_refreshinbox(struct map_session_data *sd,enum mail_inbox_type typ
/// 09e8 <mail tab>.B <mail id>.Q (CZ_OPEN_MAILBOX)
/// 09ee <mail tab>.B <mail id>.Q (CZ_REQ_NEXT_MAIL_LIST)
/// 09ef <mail tab>.B <mail id>.Q (CZ_REQ_REFRESH_MAIL_LIST)
/// 0ac0 <mail id>.Q <unknown>.16B (CZ_OPEN_MAILBOX2)
/// 0ac1 <mail id>.Q <unknown>.16B (CZ_REQ_REFRESH_MAIL_LIST2)
void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd){
#if PACKETVER < 20150513
struct mail_data* md = &sd->mail.inbox;
@ -15162,8 +15196,25 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd){
mail_removeitem(sd, 0, sd->mail.item[0].index, sd->mail.item[0].amount);
mail_removezeny(sd, false);
#else
int cmd = RFIFOW(fd, 0);
#if PACKETVER < 20170419
uint8 openType = RFIFOB(fd, 2);
uint64 mailId = RFIFOQ(fd, 3);
#else
uint8 openType;
uint64 mailId = RFIFOQ(fd, 2);
int i;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mailId);
if( i == MAIL_MAX_INBOX ){
openType = MAIL_INBOX_NORMAL;
mailId = 0;
}else{
openType = sd->mail.inbox.msg[i].type;
mailId = 0;
}
#endif
switch( openType ){
case MAIL_INBOX_NORMAL:
@ -15175,13 +15226,13 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd){
return;
}
if( sd->mail.changed || RFIFOW(fd,0) == 0x9ef ){
if( sd->mail.changed || ( cmd == 0x9ef || cmd == 0xac1 ) ){
intif_Mail_requestinbox(sd->status.char_id, 1, openType);
return;
}
// If it is not a next page request
if( RFIFOW(fd,0) != 0x9ee ){
if( cmd != 0x9ee ){
mailId = 0;
}

View File

@ -2323,6 +2323,12 @@
packet(0x0AA5,-1);
#endif
// 2017-04-19bRagexeRE
#if PACKETVER >= 20170419
parseable_packet(0x0AC0,26,clif_parse_Mail_refreshinbox,2,10);
parseable_packet(0x0AC1,26,clif_parse_Mail_refreshinbox,2,10);
#endif
// 2017-05-02dRagexeRE
#if PACKETVER >= 20170502
packet(0x0A43,85);