diff options
author | Andrei Karas <akaras@inbox.ru> | 2019-04-12 00:48:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2019-04-15 21:27:39 +0300 |
commit | 563ddcf6da8b1c0b4bedb3417d8950e20b7c5a0d (patch) | |
tree | 5fdd2a59d67b6b0a85eb3a37d5835214a077fc3e /src/char/int_rodex.c | |
parent | 5b502a267b6546ade4adb116d11354f0bf929cbf (diff) | |
download | hercules-563ddcf6da8b1c0b4bedb3417d8950e20b7c5a0d.tar.gz hercules-563ddcf6da8b1c0b4bedb3417d8950e20b7c5a0d.tar.bz2 hercules-563ddcf6da8b1c0b4bedb3417d8950e20b7c5a0d.tar.xz hercules-563ddcf6da8b1c0b4bedb3417d8950e20b7c5a0d.zip |
Improve get zeny from rodex
Diffstat (limited to 'src/char/int_rodex.c')
-rw-r--r-- | src/char/int_rodex.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c index a21629344..d8a46be69 100644 --- a/src/char/int_rodex.c +++ b/src/char/int_rodex.c @@ -346,6 +346,30 @@ static int64 inter_rodex_savemessage(struct rodex_message *msg) return msg->id; } +static int64 inter_rodex_getzeny(int64 mail_id) +{ + Assert_retr(-1, mail_id > 0); + + if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `zeny`, `type` FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) { + Sql_ShowDebug(inter->sql_handle); + } else { + if (SQL_SUCCESS == SQL->NextRow(inter->sql_handle)) { + char *data; + SQL->GetData(inter->sql_handle, 0, &data, NULL); + int64 zeny = atoi(data); + SQL->GetData(inter->sql_handle, 1, &data, NULL); + uint8 type = atoi(data); + SQL->FreeResult(inter->sql_handle); + if ((type & MAIL_TYPE_ZENY) == 0) + return -1; + return zeny; + } + } + SQL->FreeResult(inter->sql_handle); + + return -1; +} + /*========================================== * Update/Delete mail *------------------------------------------*/ @@ -364,10 +388,15 @@ static bool inter_rodex_updatemail(int fd, int account_id, int char_id, int64 ma 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)) + { + const int64 zeny = inter_rodex->getzeny(mail_id); + 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; + } + mapif->rodex_getzenyack(fd, char_id, mail_id, opentype, zeny); 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); @@ -432,4 +461,5 @@ void inter_rodex_defaults(void) inter_rodex->hasnew = inter_rodex_hasnew; inter_rodex->checkname = inter_rodex_checkname; inter_rodex->updatemail = inter_rodex_updatemail; + inter_rodex->getzeny = inter_rodex_getzeny; } |