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 | |
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')
-rw-r--r-- | src/char/int_rodex.c | 34 | ||||
-rw-r--r-- | src/char/int_rodex.h | 1 | ||||
-rw-r--r-- | src/char/mapif.c | 12 | ||||
-rw-r--r-- | src/char/mapif.h | 1 |
4 files changed, 46 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; } diff --git a/src/char/int_rodex.h b/src/char/int_rodex.h index f081d96c6..cedf0b1a8 100644 --- a/src/char/int_rodex.h +++ b/src/char/int_rodex.h @@ -37,6 +37,7 @@ struct inter_rodex_interface { bool (*checkname) (const char *name, int *target_char_id, int *target_class, int *target_level); int64 (*savemessage) (struct rodex_message* msg); bool (*updatemail) (int fd, int account_id, int char_id, int64 mail_id, uint8 opentype, int8 flag); + int64 (*getzeny) (int64 mail_id); }; #ifdef HERCULES_CORE diff --git a/src/char/mapif.c b/src/char/mapif.c index 7e8f253bc..59c9e88fa 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -2464,6 +2464,17 @@ static void mapif_achievement_save(int char_id, struct char_achievements *p) inter_achievement->tosql(char_id, cp, p); } +static void mapif_rodex_getzenyack(int fd, int char_id, int64 mail_id, uint8 opentype, int64 zeny) +{ + WFIFOHEAD(fd, 23); + WFIFOW(fd, 0) = 0x3899; + WFIFOL(fd, 2) = char_id; + WFIFOQ(fd, 6) = zeny; + WFIFOQ(fd, 14) = mail_id; + WFIFOB(fd, 22) = opentype; + WFIFOSET(fd, 23); +} + void mapif_defaults(void) { mapif = &mapif_s; @@ -2608,6 +2619,7 @@ void mapif_defaults(void) mapif->rodex_send = mapif_rodex_send; mapif->parse_rodex_checkname = mapif_parse_rodex_checkname; mapif->rodex_checkname = mapif_rodex_checkname; + mapif->rodex_getzenyack = mapif_rodex_getzenyack; mapif->load_guild_storage = mapif_load_guild_storage; mapif->save_guild_storage_ack = mapif_save_guild_storage_ack; mapif->parse_LoadGuildStorage = mapif_parse_LoadGuildStorage; diff --git a/src/char/mapif.h b/src/char/mapif.h index f57748ac6..78edc0c74 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -168,6 +168,7 @@ struct mapif_interface { void (*rodex_send) (int fd, int sender_id, int receiver_id, int receiver_accountid, bool result); void (*parse_rodex_checkname) (int fd); void (*rodex_checkname) (int fd, int reqchar_id, int target_char_id, int target_class, int target_level, char *name); + void (*rodex_getzenyack) (int fd, int char_id, int64 mail_id, uint8 opentype, int64 zeny); int (*load_guild_storage) (int fd, int account_id, int guild_id, char flag); int (*save_guild_storage_ack) (int fd, int account_id, int guild_id, int fail); int (*parse_LoadGuildStorage) (int fd); |