summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-03-11 15:38:44 +0100
committerGitHub <noreply@github.com>2018-03-11 15:38:44 +0100
commitf7ca209c044d4c08e932beac8580ddc2c2d7a924 (patch)
treeba45501645cde4e56a20ca0674232d58f132c189
parentc46b6d59644675c7c037238afb609f42230a9977 (diff)
parent442162e0baf6d085ffde26fb7fafd9877338f868 (diff)
downloadhercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.tar.gz
hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.tar.bz2
hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.tar.xz
hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.zip
Merge pull request #1987 from guilherme-gm/rodexfixes
Some rodex fixes
-rw-r--r--sql-files/main.sql4
-rw-r--r--sql-files/upgrades/2018-02-26--15-57.sql6
-rw-r--r--sql-files/upgrades/index.txt1
-rw-r--r--src/char/int_rodex.c62
-rw-r--r--src/char/mapif.c2
-rw-r--r--src/char/mapif.h2
-rw-r--r--src/common/mmo.h1
-rw-r--r--src/map/clif.c20
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/intif.c14
-rw-r--r--src/map/rodex.c27
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Defs.inc8
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.Hooks.inc12
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc12
14 files changed, 112 insertions, 61 deletions
diff --git a/sql-files/main.sql b/sql-files/main.sql
index 12607531b..5546c0271 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -889,6 +889,7 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1489588190); -- 2017-03-1
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1496588640); -- 2017-06-04--15-04.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1496588700); -- 2017-06-04--15-05.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1509835214); -- 2017-11-04--10-39.sql
+INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1519671456); -- 2018-02-26--15-57.sql
--
-- Table structure for table `storage`
--
@@ -959,12 +960,13 @@ CREATE TABLE IF NOT EXISTS `rodex_mail` (
`sender_id` INT(11) NOT NULL,
`receiver_name` VARCHAR(30) NOT NULL,
`receiver_id` INT(11) NOT NULL,
- `receiver_accountid` INT(11) NOT NULL,
+ `receiver_accountid` INT(11) NOT NULL,
`title` VARCHAR(50) NOT NULL,
`body` VARCHAR(510) NOT NULL,
`zeny` BIGINT(20) NOT NULL,
`type` TINYINT(8) UNSIGNED NOT NULL,
`is_read` TINYINT(8) NOT NULL,
+ `sender_read` TINYINT(2) NOT NULL,
`send_date` INT(11) NOT NULL,
`expire_date` INT(11) NOT NULL,
`weight` INT(11) NOT NULL,
diff --git a/sql-files/upgrades/2018-02-26--15-57.sql b/sql-files/upgrades/2018-02-26--15-57.sql
new file mode 100644
index 000000000..a2090bb3c
--- /dev/null
+++ b/sql-files/upgrades/2018-02-26--15-57.sql
@@ -0,0 +1,6 @@
+#1519671456
+
+ALTER TABLE `rodex_mail`
+ ADD COLUMN `sender_read` TINYINT(2) NOT NULL DEFAULT '0' AFTER `is_read`;
+
+INSERT INTO `sql_updates` (`timestamp`, `ignored`) VALUES (1519671456 , 'No');
diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt
index 2b1409aba..a2d0c5171 100644
--- a/sql-files/upgrades/index.txt
+++ b/sql-files/upgrades/index.txt
@@ -43,3 +43,4 @@
2017-06-04--15-04.sql
2017-06-04--15-05.sql
2017-11-04--10-39.sql
+2018-02-26--15-57.sql
diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c
index b7314e726..2001ddc43 100644
--- a/src/char/int_rodex.c
+++ b/src/char/int_rodex.c
@@ -55,7 +55,7 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64
case RODEX_OPENTYPE_MAIL:
if (SQL_ERROR == SQL->StmtPrepare(stmt,
"SELECT `mail_id`, `sender_name`, `sender_id`, `receiver_name`, `receiver_id`, `receiver_accountid`,"
- "`title`, `body`, `zeny`, `type`, `is_read`, `send_date`, `expire_date`, `weight`"
+ "`title`, `body`, `zeny`, `type`, `is_read`, `sender_read`, `send_date`, `expire_date`, `weight`"
"FROM `%s` WHERE `expire_date` > '%d' AND `receiver_id` = '%d' AND `mail_id` > '%"PRId64"'"
"ORDER BY `mail_id` ASC", rodex_db, (int)time(NULL), char_id, mail_id)
) {
@@ -68,7 +68,7 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64
case RODEX_OPENTYPE_ACCOUNT:
if (SQL_ERROR == SQL->StmtPrepare(stmt,
"SELECT `mail_id`, `sender_name`, `sender_id`, `receiver_name`, `receiver_id`, `receiver_accountid`,"
- "`title`, `body`, `zeny`, `type`, `is_read`, `send_date`, `expire_date`, `weight`"
+ "`title`, `body`, `zeny`, `type`, `is_read`, `sender_read`, `send_date`, `expire_date`, `weight`"
"FROM `%s` WHERE "
"`expire_date` > '%d' AND `receiver_accountid` = '%d' AND `mail_id` > '%"PRId64"'"
"ORDER BY `mail_id` ASC", rodex_db, (int)time(NULL), account_id, mail_id)
@@ -82,8 +82,8 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64
case RODEX_OPENTYPE_RETURN:
if (SQL_ERROR == SQL->StmtPrepare(stmt,
"SELECT `mail_id`, `sender_name`, `sender_id`, `receiver_name`, `receiver_id`, `receiver_accountid`,"
- "`title`, `body`, `zeny`, `type`, `is_read`, `send_date`, `expire_date`, `weight`"
- "FROM `%s` WHERE (`sender_id` = '%d' AND `expire_date` <= '%d' AND `send_date` + '%d' > '%d' AND `mail_id` > '%"PRId64"')"
+ "`title`, `body`, `zeny`, `type`, `is_read`, `sender_read`, `send_date`, `expire_date`, `weight`"
+ "FROM `%s` WHERE (`is_read` = 0 AND `sender_id` = '%d' AND `expire_date` <= '%d' AND `send_date` + '%d' > '%d' AND `mail_id` > '%"PRId64"')"
"ORDER BY `mail_id` ASC", rodex_db, char_id, (int)time(NULL), 2 * RODEX_EXPIRE, (int)time(NULL), mail_id)
) {
SqlStmt_ShowDebug(stmt);
@@ -95,9 +95,11 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64
case RODEX_OPENTYPE_UNSET:
if (SQL_ERROR == SQL->StmtPrepare(stmt,
"SELECT `mail_id`, `sender_name`, `sender_id`, `receiver_name`, `receiver_id`, `receiver_accountid`,"
- "`title`, `body`, `zeny`, `type`, `is_read`, `send_date`, `expire_date`, `weight`"
- "FROM `%s` WHERE `expire_date` > '%d' AND (`receiver_id` = '%d' or `receiver_accountid` = '%d') AND `mail_id` > '%"PRId64"'"
- "ORDER BY `mail_id` ASC", rodex_db, (int)time(NULL), char_id, account_id, mail_id)
+ "`title`, `body`, `zeny`, `type`, `is_read`, `sender_read`, `send_date`, `expire_date`, `weight`"
+ "FROM `%s` WHERE "
+ "((`expire_date` > '%d' AND (`receiver_id` = '%d' OR `receiver_accountid` = '%d'))"
+ "OR (`is_read` = 0 AND `sender_id` = '%d' AND `expire_date` <= '%d' AND `send_date` + '%d' > '%d'))"
+ "ORDER BY `mail_id` ASC", rodex_db, (int)time(NULL), char_id, account_id, char_id, (int)time(NULL), 2 * RODEX_EXPIRE, (int)time(NULL))
) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
@@ -118,9 +120,10 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT64, &msg.zeny, sizeof msg.zeny, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UINT8, &msg.type, sizeof msg.type, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_BOOL, &msg.is_read, sizeof msg.is_read, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_INT, &msg.send_date, sizeof msg.send_date, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_INT, &msg.expire_date, sizeof msg.expire_date, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_INT, &msg.weight, sizeof msg.weight, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_BOOL, &msg.sender_read, sizeof msg.sender_read, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_INT, &msg.send_date, sizeof msg.send_date, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_INT, &msg.expire_date, sizeof msg.expire_date, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_INT, &msg.weight, sizeof msg.weight, NULL, NULL)
) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
@@ -201,10 +204,12 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64
#if PACKETVER >= 20170419
if (opentype == RODEX_OPENTYPE_UNSET) {
- if (msg.receiver_id != 0)
- msg.opentype = RODEX_OPENTYPE_MAIL;
- else
+ if (msg.receiver_id == 0)
msg.opentype = RODEX_OPENTYPE_ACCOUNT;
+ else if (msg.expire_date < time(NULL))
+ msg.opentype = RODEX_OPENTYPE_RETURN;
+ else
+ msg.opentype = RODEX_OPENTYPE_MAIL;
} else {
msg.opentype = opentype;
}
@@ -243,8 +248,8 @@ static bool inter_rodex_hasnew(int char_id, int account_id)
if (SQL_ERROR == SQL->Query(inter->sql_handle,
"SELECT count(*) FROM `%s` WHERE ("
"(`expire_date` > '%d' AND (`receiver_id` = '%d' OR `receiver_accountid` = '%d')) OR"
- "(`sender_id` = '%d' AND `expire_date` <= '%d' AND `send_date` + '%d' > '%d')"
- ") AND (`is_read` = 0 OR (`type` > 0 AND `type` != 8))",
+ "(`sender_id` = '%d' AND `expire_date` <= '%d' AND `send_date` + '%d' > '%d' AND `is_read` = 0)" // is_read is required in this line because of the OR in next condition
+ ") AND ((`is_read` = 0 AND `sender_read` = 0) OR (`type` > 0 AND `type` != 8))",
rodex_db, (int)time(NULL), char_id, account_id,
char_id, (int)time(NULL), 2 * RODEX_EXPIRE, (int)time(NULL))
) {
@@ -309,10 +314,10 @@ int64 inter_rodex_savemessage(struct rodex_message* msg)
SQL->EscapeStringLen(inter->sql_handle, title, msg->title, strnlen(msg->title, RODEX_TITLE_LENGTH));
if (SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`sender_name`, `sender_id`, `receiver_name`, `receiver_id`, `receiver_accountid`, `title`, `body`,"
- "`zeny`, `type`, `is_read`, `send_date`, `expire_date`, `weight`) VALUES "
- "('%s', '%d', '%s', '%d', '%d', '%s', '%s', '%"PRId64"', '%d', '%d', '%d', '%d', '%d')",
+ "`zeny`, `type`, `is_read`, `sender_read`, `send_date`, `expire_date`, `weight`) VALUES "
+ "('%s', '%d', '%s', '%d', '%d', '%s', '%s', '%"PRId64"', '%d', '%d', '%d', '%d', '%d', '%d')",
rodex_db, sender_name, msg->sender_id, receiver_name, msg->receiver_id, msg->receiver_accountid,
- title, body, msg->zeny, msg->type, msg->is_read == true ? 1 : 0, msg->send_date, msg->expire_date, msg->weight)) {
+ title, body, msg->zeny, msg->type, msg->is_read == true ? 1 : 0, msg->sender_read == true ? 1 : 0, msg->send_date, msg->expire_date, msg->weight)) {
Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -344,22 +349,23 @@ int64 inter_rodex_savemessage(struct rodex_message* msg)
/*==========================================
* Inbox Request
*------------------------------------------*/
-void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails)
+void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails)
{
- int per_packet = (UINT16_MAX - 16) / sizeof(struct rodex_message);
+ int per_packet = (UINT16_MAX - 24) / sizeof(struct rodex_message);
int sent = 0;
bool is_first = true;
nullpo_retv(mails);
Assert_retv(char_id > 0);
Assert_retv(count >= 0);
+ Assert_retv(mail_id >= 0);
do {
- int i = 16, j, size, limit;
+ int i = 24, j, size, limit;
int to_send = count - sent;
bool is_last = true;
if (to_send <= per_packet) {
- size = to_send * sizeof(struct rodex_message) + 16;
+ size = to_send * sizeof(struct rodex_message) + 24;
limit = to_send;
is_last = true;
} else {
@@ -367,7 +373,7 @@ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int co
if (limit != to_send) {
is_last = false;
}
- size = limit * sizeof(struct rodex_message) + 16;
+ size = limit * sizeof(struct rodex_message) + 24;
}
WFIFOHEAD(fd, size);
@@ -379,6 +385,7 @@ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int co
WFIFOB(fd, 10) = is_last;
WFIFOB(fd, 11) = is_first;
WFIFOL(fd, 12) = limit;
+ WFIFOQ(fd, 16) = mail_id;
for (j = 0; j < limit; ++j, ++sent, i += sizeof(struct rodex_message)) {
memcpy(WFIFOP(fd, i), &VECTOR_INDEX(*mails, sent), sizeof(struct rodex_message));
}
@@ -403,7 +410,7 @@ void mapif_parse_rodex_requestinbox(int fd)
count = inter_rodex->fromsql(char_id, account_id, opentype, 0, &mails);
else
count = inter_rodex->fromsql(char_id, account_id, opentype, mail_id, &mails);
- mapif->rodex_sendinbox(fd, char_id, opentype, flag, count, &mails);
+ mapif->rodex_sendinbox(fd, char_id, opentype, flag, count, mail_id, &mails);
VECTOR_CLEAR(mails);
}
@@ -443,7 +450,7 @@ void mapif_parse_rodex_updatemail(int fd)
int8 flag = RFIFOB(fd, 10);
Assert_retv(mail_id > 0);
- Assert_retv(flag >= 0 && flag <= 3);
+ Assert_retv(flag >= 0 && flag <= 4);
switch (flag) {
case 0: // Read
@@ -469,6 +476,11 @@ void mapif_parse_rodex_updatemail(int fd)
if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_item_db, mail_id))
Sql_ShowDebug(inter->sql_handle);
break;
+
+ case 4: // Sender Read
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `sender_read` = 1 WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id))
+ Sql_ShowDebug(inter->sql_handle);
+ break;
}
}
diff --git a/src/char/mapif.c b/src/char/mapif.c
index 241edc925..f80e38fe7 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -185,7 +185,7 @@ void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_
int mapif_parse_quest_load(int fd);
/* RoDEX */
int mapif_parse_rodex_requestinbox(int fd);
-void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails);
+void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails);
int mapif_parse_rodex_checkhasnew(int fd);
void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new);
int mapif_parse_rodex_updatemail(int fd);
diff --git a/src/char/mapif.h b/src/char/mapif.h
index f03f1ad9a..7fc79f661 100644
--- a/src/char/mapif.h
+++ b/src/char/mapif.h
@@ -177,7 +177,7 @@ struct mapif_interface {
void (*send_quests) (int fd, int char_id, struct quest *tmp_questlog, int num_quests);
int (*parse_quest_load) (int fd);
int(*parse_rodex_requestinbox) (int fd);
- void(*rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails);
+ void(*rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails);
int(*parse_rodex_checkhasnew) (int fd);
void(*rodex_sendhasnew) (int fd, int char_id, bool has_new);
int(*parse_rodex_updatemail) (int fd);
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 04daedca0..f9cbc57de 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -904,6 +904,7 @@ struct rodex_message {
uint8 type;
int8 opentype;
bool is_read;
+ bool sender_read;
bool is_deleted;
int send_date;
int expire_date;
diff --git a/src/map/clif.c b/src/map/clif.c
index d2dc12377..546247c3c 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -19831,7 +19831,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
continue;
inner->MailID = msg->id;
- inner->Isread = msg->is_read == true ? 1 : 0;
+ inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0;
inner->type = msg->type;
#if PACKETVER >= 20170419
inner->openType = msg->opentype;
@@ -19863,7 +19863,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
#endif
}
-void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
+void clif_rodex_send_mails_all(int fd, struct map_session_data *sd, int64 mail_id)
{
#if PACKETVER >= 20170419
struct PACKET_ZC_MAIL_LIST *packet;
@@ -19871,18 +19871,24 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
int16 size = sizeof(*packet);
int packetMailCount = 0;
int mailListCount = 0;
- int mailsSize = VECTOR_LENGTH(sd->rodex.messages);
- int i;
+ int mailsSize, i;
+ int j = -1;
nullpo_retv(sd);
+ mailsSize = VECTOR_LENGTH(sd->rodex.messages);
+
+ if (mail_id > 0)
+ ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), j, (VECTOR_INDEX(sd->rodex.messages, j)).id == mail_id);
+
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) {
+ mailsSize -= (j + 1);
+ while (i > j) {
struct rodex_message *msg = &VECTOR_INDEX(sd->rodex.messages, i);
--i;
@@ -19890,7 +19896,7 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
continue;
inner->MailID = msg->id;
- inner->Isread = msg->is_read == true ? 1 : 0;
+ inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0;
inner->type = msg->type;
inner->openType = msg->opentype;
inner->expireDateTime = msg->expire_date - (int)time(NULL);
@@ -19957,7 +19963,7 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
continue;
inner->MailID = msg->id;
- inner->Isread = msg->is_read == true ? 1 : 0;
+ inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0;
inner->type = msg->type;
#if PACKETVER >= 20170419
inner->openType = msg->opentype;
diff --git a/src/map/clif.h b/src/map/clif.h
index 0711546df..acf79c373 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -1389,7 +1389,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 (*rodex_send_mails_all) (int fd, struct map_session_data *sd, int64 mail_id);
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 0e5cd3db2..f656a0df9 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -2516,6 +2516,9 @@ void intif_parse_RequestRodexOpenInbox(int fd)
int8 is_end = RFIFOB(fd, 10);
int is_first = RFIFOB(fd, 11);
int count = RFIFOL(fd, 12);
+#if PACKETVER >= 20170419
+ int64 mail_id = RFIFOQ(fd, 16);
+#endif
int i, j;
sd = map->charid2sd(RFIFOL(fd, 4));
@@ -2533,15 +2536,15 @@ void intif_parse_RequestRodexOpenInbox(int fd)
else
sd->rodex.total += count;
- if (RFIFOW(fd, 2) - 16 != count * sizeof(struct rodex_message)) {
- ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 16, count * sizeof(struct rodex_message));
+ if (RFIFOW(fd, 2) - 24 != count * sizeof(struct rodex_message)) {
+ ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 24, count * sizeof(struct rodex_message));
return;
}
if (flag == 0 && is_first)
VECTOR_CLEAR(sd->rodex.messages);
- for (i = 0, j = 16; i < count; ++i, j += sizeof(struct rodex_message)) {
+ for (i = 0, j = 24; i < count; ++i, j += sizeof(struct rodex_message)) {
struct rodex_message msg = { 0 };
VECTOR_ENSURE(sd->rodex.messages, 1, 1);
memcpy(&msg, RFIFOP(fd, j), sizeof(struct rodex_message));
@@ -2550,7 +2553,7 @@ void intif_parse_RequestRodexOpenInbox(int fd)
if (is_end == true) {
#if PACKETVER >= 20170419
- clif->rodex_send_mails_all(sd->fd, sd);
+ clif->rodex_send_mails_all(sd->fd, sd, mail_id);
#else
if (flag == 0)
clif->rodex_send_maillist(sd->fd, sd, opentype, VECTOR_LENGTH(sd->rodex.messages) - 1);
@@ -2599,10 +2602,11 @@ void intif_parse_RodexNotifications(int fd)
/// Updates a mail
/// flag:
-/// 0 - user Read
+/// 0 - receiver Read
/// 1 - user got Zeny
/// 2 - user got Items
/// 3 - delete
+/// 4 - sender Read (returned mail)
int intif_rodex_updatemail(int64 mail_id, int8 flag)
{
if (intif->CheckForCharServer())
diff --git a/src/map/rodex.c b/src/map/rodex.c
index d5a6064cf..8626f76e1 100644
--- a/src/map/rodex.c
+++ b/src/map/rodex.c
@@ -364,15 +364,24 @@ struct rodex_message *rodex_get_mail(struct map_session_data *sd, int64 mail_id)
{
int i;
struct rodex_message *msg;
+ int char_id;
nullpo_retr(NULL, sd);
- ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), i, VECTOR_INDEX(sd->rodex.messages, i).id == mail_id && VECTOR_INDEX(sd->rodex.messages, i).is_deleted != true);
+ ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), i, VECTOR_INDEX(sd->rodex.messages, i).id == mail_id);
if (i == VECTOR_LENGTH(sd->rodex.messages))
return NULL;
msg = &VECTOR_INDEX(sd->rodex.messages, i);
+ char_id = sd->status.char_id;
+
+ if ((msg->is_deleted == true)
+ || (msg->expire_date < time(NULL) && ((msg->receiver_accountid > 0) || (msg->receiver_id == char_id && msg->sender_id != char_id)))
+ || ((msg->send_date + 2 * RODEX_EXPIRE) < time(NULL))
+ )
+ return NULL;
+
return msg;
}
@@ -388,9 +397,16 @@ void rodex_read_mail(struct map_session_data *sd, int64 mail_id)
msg = rodex->get_mail(sd, mail_id);
nullpo_retv(msg);
- if (msg->is_read == false) {
- intif->rodex_updatemail(msg->id, 0);
- msg->is_read = true;
+ if (msg->opentype == RODEX_OPENTYPE_RETURN) {
+ if (msg->sender_read == false) {
+ intif->rodex_updatemail(msg->id, 4);
+ msg->sender_read = true;
+ }
+ } else {
+ if (msg->is_read == false) {
+ intif->rodex_updatemail(msg->id, 0);
+ msg->is_read = true;
+ }
}
clif->rodex_read_mail(sd, msg->opentype, msg);
@@ -440,6 +456,7 @@ void rodex_get_zeny(struct map_session_data *sd, int8 opentype, int64 mail_id)
return;
}
+ msg->type &= ~MAIL_TYPE_ZENY;
msg->zeny = 0;
intif->rodex_updatemail(mail_id, 1);
@@ -523,6 +540,8 @@ void rodex_get_items(struct map_session_data *sd, int8 opentype, int64 mail_id)
}
}
+ msg->type &= ~MAIL_TYPE_ITEM;
+ msg->items_count = 0;
intif->rodex_updatemail(mail_id, 2);
clif->rodex_request_items(sd, opentype, mail_id, RODEX_GET_ITEMS_SUCCESS);
diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc
index 822faa0cd..bd17dc7fe 100644
--- a/src/plugins/HPMHooking/HPMHooking.Defs.inc
+++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc
@@ -2358,8 +2358,8 @@ typedef void (*HPMHOOK_pre_clif_rodex_send_maillist) (int *fd, struct map_sessio
typedef void (*HPMHOOK_post_clif_rodex_send_maillist) (int fd, struct map_session_data *sd, int8 open_type, int64 page_start);
typedef void (*HPMHOOK_pre_clif_rodex_send_refresh) (int *fd, struct map_session_data **sd, int8 *open_type, int *count);
typedef void (*HPMHOOK_post_clif_rodex_send_refresh) (int fd, struct map_session_data *sd, int8 open_type, int count);
-typedef void (*HPMHOOK_pre_clif_rodex_send_mails_all) (int *fd, struct map_session_data **sd);
-typedef void (*HPMHOOK_post_clif_rodex_send_mails_all) (int fd, struct map_session_data *sd);
+typedef void (*HPMHOOK_pre_clif_rodex_send_mails_all) (int *fd, struct map_session_data **sd, int64 *mail_id);
+typedef void (*HPMHOOK_post_clif_rodex_send_mails_all) (int fd, struct map_session_data *sd, int64 mail_id);
typedef void (*HPMHOOK_pre_clif_pRodexReadMail) (int *fd, struct map_session_data **sd);
typedef void (*HPMHOOK_post_clif_pRodexReadMail) (int fd, struct map_session_data *sd);
typedef void (*HPMHOOK_pre_clif_rodex_read_mail) (struct map_session_data **sd, int8 *opentype, struct rodex_message **msg);
@@ -4662,8 +4662,8 @@ typedef int (*HPMHOOK_pre_mapif_parse_quest_load) (int *fd);
typedef int (*HPMHOOK_post_mapif_parse_quest_load) (int retVal___, int fd);
typedef int (*HPMHOOK_pre_mapif_parse_rodex_requestinbox) (int *fd);
typedef int (*HPMHOOK_post_mapif_parse_rodex_requestinbox) (int retVal___, int fd);
-typedef void (*HPMHOOK_pre_mapif_rodex_sendinbox) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, struct rodex_maillist **mails);
-typedef void (*HPMHOOK_post_mapif_rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails);
+typedef void (*HPMHOOK_pre_mapif_rodex_sendinbox) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, int64 *mail_id, struct rodex_maillist **mails);
+typedef void (*HPMHOOK_post_mapif_rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails);
typedef int (*HPMHOOK_pre_mapif_parse_rodex_checkhasnew) (int *fd);
typedef int (*HPMHOOK_post_mapif_parse_rodex_checkhasnew) (int retVal___, int fd);
typedef void (*HPMHOOK_pre_mapif_rodex_sendhasnew) (int *fd, int *char_id, bool *has_new);
diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
index cfd6caee1..6ea10f78f 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
@@ -14647,14 +14647,14 @@ int HP_mapif_parse_rodex_requestinbox(int fd) {
}
return retVal___;
}
-void HP_mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails) {
+void HP_mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails) {
int hIndex = 0;
if (HPMHooks.count.HP_mapif_rodex_sendinbox_pre > 0) {
- void (*preHookFunc) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, struct rodex_maillist **mails);
+ void (*preHookFunc) (int *fd, int *char_id, int8 *opentype, int8 *flag, int *count, int64 *mail_id, struct rodex_maillist **mails);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_rodex_sendinbox_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_mapif_rodex_sendinbox_pre[hIndex].func;
- preHookFunc(&fd, &char_id, &opentype, &flag, &count, &mails);
+ preHookFunc(&fd, &char_id, &opentype, &flag, &count, &mail_id, &mails);
}
if (*HPMforce_return) {
*HPMforce_return = false;
@@ -14662,13 +14662,13 @@ void HP_mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int
}
}
{
- HPMHooks.source.mapif.rodex_sendinbox(fd, char_id, opentype, flag, count, mails);
+ HPMHooks.source.mapif.rodex_sendinbox(fd, char_id, opentype, flag, count, mail_id, mails);
}
if (HPMHooks.count.HP_mapif_rodex_sendinbox_post > 0) {
- void (*postHookFunc) (int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails);
+ void (*postHookFunc) (int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails);
for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_rodex_sendinbox_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_mapif_rodex_sendinbox_post[hIndex].func;
- postHookFunc(fd, char_id, opentype, flag, count, mails);
+ postHookFunc(fd, char_id, opentype, flag, count, mail_id, mails);
}
}
return;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index f42f8fc1c..2e20ab157 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -25420,14 +25420,14 @@ void HP_clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_t
}
return;
}
-void HP_clif_rodex_send_mails_all(int fd, struct map_session_data *sd) {
+void HP_clif_rodex_send_mails_all(int fd, struct map_session_data *sd, int64 mail_id) {
int hIndex = 0;
if (HPMHooks.count.HP_clif_rodex_send_mails_all_pre > 0) {
- void (*preHookFunc) (int *fd, struct map_session_data **sd);
+ void (*preHookFunc) (int *fd, struct map_session_data **sd, int64 *mail_id);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_rodex_send_mails_all_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_clif_rodex_send_mails_all_pre[hIndex].func;
- preHookFunc(&fd, &sd);
+ preHookFunc(&fd, &sd, &mail_id);
}
if (*HPMforce_return) {
*HPMforce_return = false;
@@ -25435,13 +25435,13 @@ void HP_clif_rodex_send_mails_all(int fd, struct map_session_data *sd) {
}
}
{
- HPMHooks.source.clif.rodex_send_mails_all(fd, sd);
+ HPMHooks.source.clif.rodex_send_mails_all(fd, sd, mail_id);
}
if (HPMHooks.count.HP_clif_rodex_send_mails_all_post > 0) {
- void (*postHookFunc) (int fd, struct map_session_data *sd);
+ void (*postHookFunc) (int fd, struct map_session_data *sd, int64 mail_id);
for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_rodex_send_mails_all_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_clif_rodex_send_mails_all_post[hIndex].func;
- postHookFunc(fd, sd);
+ postHookFunc(fd, sd, mail_id);
}
}
return;