diff options
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/char.c | 5 | ||||
-rw-r--r-- | src/char/int_rodex.c | 62 | ||||
-rw-r--r-- | src/char/inter.c | 3 | ||||
-rw-r--r-- | src/char/mapif.c | 2 | ||||
-rw-r--r-- | src/char/mapif.h | 2 | ||||
-rw-r--r-- | src/char/pincode.c | 17 |
6 files changed, 61 insertions, 30 deletions
diff --git a/src/char/char.c b/src/char/char.c index aef35f216..0069e7f1d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3328,7 +3328,12 @@ void char_char_name_ack(int fd, int char_id) WFIFOHEAD(fd,30); WFIFOW(fd,0) = 0x2b09; WFIFOL(fd,2) = char_id; +#if !defined(PACKETVER_ZERO) && (PACKETVER >= 20180307 || (defined(PACKETVER_RE) && PACKETVER >= 20180221)) + if (chr->loadName(char_id, WFIFOP(fd,6)) == 0) + WFIFOL(fd, 6) = 0; +#else chr->loadName(char_id, WFIFOP(fd,6)); +#endif WFIFOSET(fd,30); } 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/inter.c b/src/char/inter.c index baa000d82..b095a046d 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -527,12 +527,15 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc inter->msg_to_fd(map_fd, u_fd, u_aid, "-- Account %d --", account_id); inter->msg_to_fd(map_fd, u_fd, u_aid, "User: %s | GM Group: %d | State: %d", userid, group_id, state); +// enable this if you really know what you doing. +#if 0 if (*user_pass != '\0') { /* password is only received if your gm level is greater than the one you're searching for */ if (pin_code && *pin_code != '\0') inter->msg_to_fd(map_fd, u_fd, u_aid, "Password: %s (PIN:%s)", user_pass, pin_code); else inter->msg_to_fd(map_fd, u_fd, u_aid, "Password: %s", user_pass ); } +#endif inter->msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate); inter->msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip->getcountry(sockt->str2ip(last_ip))); 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/char/pincode.c b/src/char/pincode.c index fc1a4c037..bca1b4394 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -68,6 +68,8 @@ void pincode_check(int fd, struct char_session_data* sd) { char pin[5] = "\0\0\0\0"; nullpo_retv(sd); + if (strlen(sd->pincode) != 4) + return; safestrncpy(pin, RFIFOP(fd, 6), sizeof(pin)); pincode->decrypt(sd->pincode_seed, pin); if( pincode->compare( fd, sd, pin ) ){ @@ -87,7 +89,9 @@ int pincode_compare(int fd, struct char_session_data* sd, char* pin) { } else { pincode->sendstate( fd, sd, PINCODE_WRONG ); if( pincode->maxtry && ++sd->pincode_try >= pincode->maxtry ){ - pincode->error( sd->account_id ); + pincode->error(sd->account_id); + chr->authfail_fd(fd, 0); + chr->disconnect_player(sd->account_id); } return 0; } @@ -97,6 +101,8 @@ void pincode_change(int fd, struct char_session_data* sd) { char oldpin[5] = "\0\0\0\0", newpin[5] = "\0\0\0\0"; nullpo_retv(sd); + if (strlen(sd->pincode) != 4) + return; safestrncpy(oldpin, RFIFOP(fd,6), sizeof(oldpin)); pincode->decrypt(sd->pincode_seed,oldpin); if( !pincode->compare( fd, sd, oldpin ) ) @@ -113,6 +119,8 @@ void pincode_setnew(int fd, struct char_session_data* sd) { char newpin[5] = "\0\0\0\0"; nullpo_retv(sd); + if (strlen(sd->pincode) == 4) + return; safestrncpy(newpin, RFIFOP(fd,6), sizeof(newpin)); pincode->decrypt(sd->pincode_seed,newpin); pincode->update( sd->account_id, newpin ); @@ -172,8 +180,11 @@ void pincode_decrypt(unsigned int userSeed, char* pin) { } } - for( i = 0; i < 4; i++ ){ - pin[i] = tab[pin[i] - '0']; + for (i = 0; i < 4; i++ ) { + if (pin[i] < '0' || pin[i] > '9') + pin[i] = '0'; + else + pin[i] = tab[pin[i] - '0']; } sprintf(pin, "%d%d%d%d", pin[0], pin[1], pin[2], pin[3]); |