summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-10-12 19:33:10 +0300
committerAndrei Karas <akaras@inbox.ru>2017-10-21 04:21:52 +0300
commit1962fe593393d260c5f170c5fe6932e130e495bf (patch)
tree476783454adee1cac9b6c3ad03f2df487e4ee401 /src/map
parent6791b26d7865c38129abd80f8e8a6a62872238f4 (diff)
downloadhercules-1962fe593393d260c5f170c5fe6932e130e495bf.tar.gz
hercules-1962fe593393d260c5f170c5fe6932e130e495bf.tar.bz2
hercules-1962fe593393d260c5f170c5fe6932e130e495bf.tar.xz
hercules-1962fe593393d260c5f170c5fe6932e130e495bf.zip
Add rodex 2017 packets.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c95
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/intif.c6
-rw-r--r--src/map/packets.h4
-rw-r--r--src/map/packets_struct.h23
-rw-r--r--src/map/rodex.c11
-rw-r--r--src/map/rodex.h2
7 files changed, 131 insertions, 11 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index a17210cf4..088c92ea8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -19470,8 +19470,9 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
packet = WFIFOP(fd, 0);
packet->PacketType = ((page_start == (VECTOR_LENGTH(sd->rodex.messages) - 1)) ? rodexmailList : rodexnextpage);
+#if PACKETVER < 20170419
packet->opentype = open_type;
-
+#endif
inner = WFIFOP(fd, size);
while (page_start >= 0 && count < RODEX_MAIL_PER_PAGE) {
@@ -19484,7 +19485,11 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
inner->MailID = msg->id;
inner->Isread = msg->is_read == true ? 1 : 0;
inner->type = msg->type;
+#if PACKETVER >= 20170419
+ inner->openType = msg->opentype;
+#else
inner->regDateTime = (int)time(NULL) - msg->send_date;
+#endif
inner->expireDateTime = msg->expire_date - (int)time(NULL);
if (open_type == RODEX_OPENTYPE_RETURN) {
inner->expireDateTime += RODEX_EXPIRE;
@@ -19502,12 +19507,80 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
}
packet->PacketLength = size;
+#if PACKETVER < 20170419
packet->cnt = count;
+#endif
packet->IsEnd = page_start > 0 ? 0 : 1;
WFIFOSET(fd, size);
#endif
}
+void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
+{
+#if PACKETVER >= 20170419
+ struct PACKET_ZC_MAIL_LIST *packet;
+ struct maillistinfo *inner;
+ int16 size = sizeof(*packet);
+ int packetMailCount = 0;
+ int mailListCount = 0;
+ int mailsSize = VECTOR_LENGTH(sd->rodex.messages);
+ int i;
+
+ nullpo_retv(sd);
+
+ WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
+ packet = WFIFOP(fd, 0);
+ packet->PacketType = rodexmailList;
+ inner = WFIFOP(fd, size);
+
+ i = mailsSize - 1;
+ while (i >= 0) {
+ struct rodex_message *msg = &VECTOR_INDEX(sd->rodex.messages, i);
+ --i;
+
+ if (msg->is_deleted)
+ continue;
+
+ inner->MailID = msg->id;
+ inner->Isread = msg->is_read == true ? 1 : 0;
+ inner->type = msg->type;
+ inner->openType = msg->opentype;
+ inner->expireDateTime = msg->expire_date - (int)time(NULL);
+ if (msg->opentype == RODEX_OPENTYPE_RETURN) {
+ inner->expireDateTime += RODEX_EXPIRE;
+ }
+ inner->Titlelength = (int16)strlen(msg->title) + 1;
+ if (msg->opentype != RODEX_OPENTYPE_RETURN) {
+ strncpy(inner->SenderName, msg->sender_name, sizeof(msg->sender_name));
+ } else {
+ strncpy(inner->SenderName, msg->receiver_name, sizeof(msg->receiver_name));
+ }
+ strncpy(inner->title, msg->title, inner->Titlelength);
+ size += sizeof(*inner) + inner->Titlelength;
+ inner = WFIFOP(fd, size);
+ packetMailCount ++;
+ mailListCount ++;
+ if (packetMailCount == RODEX_MAIL_PER_PAGE) {
+ packet->PacketLength = size;
+ packet->IsEnd = mailListCount > mailsSize ? 1 : 0;
+ WFIFOSET(fd, size);
+ WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
+ packet = WFIFOP(fd, 0);
+ packet->PacketType = rodexmailList;
+ size = sizeof(*packet);
+ inner = WFIFOP(fd, size);
+ packetMailCount = 0;
+ }
+ }
+
+ if (packetMailCount > 0 || mailListCount == 0) {
+ packet->PacketLength = size;
+ packet->IsEnd = 1;
+ WFIFOSET(fd, size);
+ }
+#endif
+}
+
void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type, int count)
{
#if PACKETVER >= 20131218
@@ -19521,8 +19594,9 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
packet = WFIFOP(fd, 0);
packet->PacketType = rodexmailList;
+#if PACKETVER < 20170419
packet->opentype = open_type;
-
+#endif
inner = WFIFOP(fd, size);
i = VECTOR_LENGTH(sd->rodex.messages) - 1;
@@ -19537,7 +19611,11 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
inner->MailID = msg->id;
inner->Isread = msg->is_read == true ? 1 : 0;
inner->type = msg->type;
+#if PACKETVER >= 20170419
+ inner->openType = msg->opentype;
+#else
inner->regDateTime = (int)time(NULL) - msg->send_date;
+#endif
inner->expireDateTime = msg->expire_date - (int)time(NULL);
if (open_type == RODEX_OPENTYPE_RETURN) {
inner->expireDateTime += RODEX_EXPIRE;
@@ -19555,7 +19633,9 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
}
packet->PacketLength = size;
+#if PACKETVER < 20170419
packet->cnt = count;
+#endif
packet->IsEnd = 1;
WFIFOSET(fd, size);
#endif
@@ -19730,14 +19810,22 @@ void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *sd) __at
void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *sd)
{
const struct PACKET_CZ_REQ_REFRESH_MAIL_LIST *packet = RFIFOP(fd, 0);
+#if PACKETVER >= 20170419
+ rodex->refresh(sd, RODEX_OPENTYPE_UNSET, packet->Upper_MailID);
+#else
rodex->refresh(sd, packet->opentype, packet->Upper_MailID);
+#endif
}
void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd)
{
const struct PACKET_CZ_REQ_OPEN_MAIL *packet = RFIFOP(fd, 0);
- rodex->open(sd, packet->opentype);
+#if PACKETVER >= 20170419
+ rodex->open(sd, RODEX_OPENTYPE_UNSET, packet->Upper_MailID);
+#else
+ rodex->open(sd, packet->opentype, packet->Upper_MailID);
+#endif
rodex->clean(sd, 1);
}
@@ -20822,4 +20910,5 @@ void clif_defaults(void) {
clif->pRodexRequestItems = clif_parse_rodex_request_items;
clif->rodex_request_items = clif_rodex_request_items;
clif->rodex_icon = clif_rodex_icon;
+ clif->rodex_send_mails_all = clif_rodex_send_mails_all;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index be7bdd2d6..851c823ea 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -1378,6 +1378,7 @@ struct clif_interface {
void (*rodex_send_mail_result) (int fd, struct map_session_data *sd, int8 result);
void (*rodex_send_maillist) (int fd, struct map_session_data *sd, int8 open_type, int64 page_start);
void (*rodex_send_refresh) (int fd, struct map_session_data *sd, int8 open_type, int count);
+ void (*rodex_send_mails_all) (int fd, struct map_session_data *sd);
void (*pRodexReadMail) (int fd, struct map_session_data *sd);
void (*rodex_read_mail) (struct map_session_data *sd, int8 opentype, struct rodex_message *msg);
void (*pRodexNextMaillist) (int fd, struct map_session_data *sd);
diff --git a/src/map/intif.c b/src/map/intif.c
index 1458fc710..60edc8d8b 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -2433,7 +2433,9 @@ int intif_rodex_requestinbox(int char_id, int account_id, int8 flag, int8 openty
void intif_parse_RequestRodexOpenInbox(int fd)
{
struct map_session_data *sd;
+#if PACKETVER < 20170419
int8 opentype = RFIFOB(fd, 8);
+#endif
int8 flag = RFIFOB(fd, 9);
int8 is_end = RFIFOB(fd, 10);
int count = RFIFOL(fd, 11);
@@ -2461,10 +2463,14 @@ void intif_parse_RequestRodexOpenInbox(int fd)
}
if (is_end == true) {
+#if PACKETVER >= 20170419
+ clif->rodex_send_mails_all(sd->fd, sd);
+#else
if (flag == 0)
clif->rodex_send_maillist(sd->fd, sd, opentype, VECTOR_LENGTH(sd->rodex.messages) - 1);
else
clif->rodex_send_refresh(sd->fd, sd, opentype, count);
+#endif
}
}
diff --git a/src/map/packets.h b/src/map/packets.h
index 358b1ff25..e9d895440 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -9476,8 +9476,8 @@ packet(0x96e,-1,clif->ackmergeitems);
// 2017-02-28aRagexeRE
#if PACKETVER >= 20170228
// new packets
- packet(0x0ac0,26);
- packet(0x0ac1,26);
+ packet(0x0ac0,26,clif->pRodexOpenMailbox); // CZ_OPEN_RODEXBOX
+ packet(0x0ac1,26,clif->pRodexRefreshMaillist); // CZ_REQ_REFRESH_RODEX
packet(0x0ac2,-1);
packet(0x0ac3,2);
packet(0x0ac4,-1);
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index 207c345da..03b555e2b 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -318,10 +318,12 @@ enum packet_headers {
rodexadditem = 0x0A05,
rodexremoveitem = 0x0A07,
rodexopenwrite = 0x0A12,
-#if PACKETVER < 20160600
+#if PACKETVER < 20160601
rodexmailList = 0x09F0,
-#else // PACKETVER >= 20160600
+#elif PACKETVER < 20170419
rodexmailList = 0x0A7D,
+#else // PACKETVER >= 20170419
+ rodexmailList = 0x0Ac2,
#endif
#if PACKETVER < 20160316
rodexcheckplayer = 0x0A14,
@@ -1369,11 +1371,16 @@ struct PACKET_ZC_NOTIFY_UNREADMAIL {
} __attribute__((packed));
struct maillistinfo {
+#if PACKETVER >= 20170419
+ uint8 openType;
+#endif
int64 MailID;
int8 Isread;
uint8 type;
char SenderName[24];
+#if PACKETVER < 20170419
int32 regDateTime;
+#endif
int32 expireDateTime;
int16 Titlelength;
char title[];
@@ -1382,8 +1389,10 @@ struct maillistinfo {
struct PACKET_ZC_MAIL_LIST {
int16 PacketType;
int16 PacketLength;
+#if PACKETVER < 20170419
int8 opentype;
int8 cnt;
+#endif
int8 IsEnd;
} __attribute__((packed));
@@ -1395,8 +1404,13 @@ struct PACKET_CZ_REQ_NEXT_MAIL_LIST {
struct PACKET_CZ_REQ_OPEN_MAIL {
int16 PacketType;
+#if PACKETVER >= 20170419
+ int64 Upper_MailID;
+ int8 unknown[16];
+#else
int8 opentype;
int64 Upper_MailID;
+#endif
} __attribute__((packed));
struct PACKET_CZ_REQ_READ_MAIL {
@@ -1429,8 +1443,13 @@ struct PACKET_ZC_ACK_DELETE_MAIL {
struct PACKET_CZ_REQ_REFRESH_MAIL_LIST {
int16 PacketType;
+#if PACKETVER >= 20170419
+ int64 Upper_MailID;
+ int8 unknown[16];
+#else
int8 opentype;
int64 Upper_MailID;
+#endif
} __attribute__((packed));
struct PACKET_CZ_REQ_ZENY_FROM_MAIL {
diff --git a/src/map/rodex.c b/src/map/rodex.c
index 63d7242db..dcecb6b8f 100644
--- a/src/map/rodex.c
+++ b/src/map/rodex.c
@@ -547,13 +547,18 @@ void rodex_clean(struct map_session_data *sd, int8 flag)
/// User request to open rodex, load mails from char-server
/// @param sd : Who's requesting
/// @param open_type : Box Type (see RODEX_OPENTYPE)
-void rodex_open(struct map_session_data *sd, int8 open_type)
+void rodex_open(struct map_session_data *sd, int8 open_type, int64 first_mail_id)
{
+#if PACKETVER >= 20170419
+ const int type = 1;
+#else
+ const int type = 0;
+#endif
nullpo_retv(sd);
if (open_type == RODEX_OPENTYPE_ACCOUNT && battle_config.feature_rodex_use_accountmail == false)
open_type = RODEX_OPENTYPE_MAIL;
- intif->rodex_requestinbox(sd->status.char_id, sd->status.account_id, 0, open_type, 0);
+ intif->rodex_requestinbox(sd->status.char_id, sd->status.account_id, type, open_type, first_mail_id);
}
/// User request to read next page of mails
@@ -568,7 +573,7 @@ void rodex_next_page(struct map_session_data *sd, int8 open_type, int64 last_mai
if (open_type == RODEX_OPENTYPE_ACCOUNT && battle_config.feature_rodex_use_accountmail == false) {
// Should not happen
open_type = RODEX_OPENTYPE_MAIL;
- rodex->open(sd, open_type);
+ rodex->open(sd, open_type, 0);
return;
}
diff --git a/src/map/rodex.h b/src/map/rodex.h
index 18ecd91d6..ddf7cb32b 100644
--- a/src/map/rodex.h
+++ b/src/map/rodex.h
@@ -60,7 +60,7 @@ struct rodex_interface {
void (*final) (void);
bool (*isenabled) (void);
- void (*open) (struct map_session_data *sd, int8 open_type);
+ void (*open) (struct map_session_data *sd, int8 open_type, int64 first_mail_id);
void (*next_page) (struct map_session_data *sd, int8 open_type, int64 last_mail_id);
void (*refresh) (struct map_session_data *sd, int8 open_type, int64 first_mail_id);
void (*add_item) (struct map_session_data *sd, int16 idx, int16 amount);