diff options
Diffstat (limited to 'src/char/int_rodex.c')
-rw-r--r-- | src/char/int_rodex.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c index 1fa76e4db..994e8110e 100644 --- a/src/char/int_rodex.c +++ b/src/char/int_rodex.c @@ -92,6 +92,19 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64 return -1; } break; + + 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) + ) { + SqlStmt_ShowDebug(stmt); + SQL->StmtFree(stmt); + return -1; + } + break; } if (SQL_ERROR == SQL->StmtExecute(stmt) @@ -173,7 +186,18 @@ static int inter_rodex_fromsql(int char_id, int account_id, int8 opentype, int64 msg.type &= ~MAIL_TYPE_ZENY; } +#if PACKETVER >= 20170419 + if (opentype == RODEX_OPENTYPE_UNSET) { + if (msg.receiver_id != 0) + msg.opentype = RODEX_OPENTYPE_MAIL; + else + msg.opentype = RODEX_OPENTYPE_ACCOUNT; + } else { + msg.opentype = opentype; + } +#else msg.opentype = opentype; +#endif #if PACKETVER < 20160601 // NPC Message Type isn't supported in old clients msg.type &= ~MAIL_TYPE_NPC; @@ -200,8 +224,8 @@ static bool inter_rodex_hasnew(int char_id, int account_id) { int count = 0; char *data; - - if (SQL_ERROR == SQL->Query(inter->sql_handle, + + 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')" @@ -212,7 +236,7 @@ static bool inter_rodex_hasnew(int char_id, int account_id) Sql_ShowDebug(inter->sql_handle); return -1; } - + if (SQL_SUCCESS != SQL->NextRow(inter->sql_handle)) return false; @@ -407,12 +431,12 @@ void mapif_parse_rodex_updatemail(int fd) if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `is_read` = 1 WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; - + case 1: // Get Zeny if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `zeny` = 0, `type` = `type` & (~2) WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; - + case 2: // Get Items 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); @@ -436,7 +460,7 @@ void mapif_rodex_send(int fd, int sender_id, int receiver_id, int receiver_accou { Assert_retv(sender_id >= 0); Assert_retv(receiver_id + receiver_accountid > 0); - + WFIFOHEAD(fd,15); WFIFOW(fd,0) = 0x3897; WFIFOL(fd,2) = sender_id; |