diff options
-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 | ||||
-rw-r--r-- | src/map/intif.c | 17 | ||||
-rw-r--r-- | src/map/intif.h | 1 | ||||
-rw-r--r-- | src/map/rodex.c | 28 | ||||
-rw-r--r-- | src/map/rodex.h | 1 |
8 files changed, 83 insertions, 12 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); diff --git a/src/map/intif.c b/src/map/intif.c index e565c71e6..da85c96a2 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -2860,6 +2860,19 @@ static void intif_parse_RodexCheckName(int fd) clif->rodex_checkname_result(sd, target_char_id, target_class, target_level, name); } +static void intif_parse_GetZenyAck(int fd) +{ + int char_id = RFIFOL(fd, 2); + int64 zeny = RFIFOL(fd, 6); + int64 mail_id = RFIFOQ(fd, 14); + uint8 opentype = RFIFOB(fd, 22); + struct map_session_data *sd = map->charid2sd(char_id); + + if (sd == NULL) // User is not online anymore + return; + rodex->getZenyAck(sd, mail_id, opentype, zeny); +} + //----------------------------------------------------------------- // Communication from the inter server // Return a 0 (false) if there were any errors. @@ -2977,6 +2990,7 @@ static int intif_parse(int fd) case 0x3896: intif->pRodexHasNew(fd); break; case 0x3897: intif->pRodexSendMail(fd); break; case 0x3898: intif->pRodexCheckName(fd); break; + case 0x3899: intif->pGetZenyAck(fd); break; // Clan System case 0x3858: intif->pRecvClanMemberAction(fd); break; @@ -3006,7 +3020,7 @@ void intif_defaults(void) -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] 14,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 - -1,-1, 7, 3, 0,-1, 7, 15,18 + NAME_LENGTH, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] / RoDEX [KirieZ] + -1,-1, 7, 3, 0,-1, 7, 15,18 + NAME_LENGTH, 23, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] / RoDEX [KirieZ] }; intif = &intif_s; @@ -3176,6 +3190,7 @@ void intif_defaults(void) intif->pRodexHasNew = intif_parse_RodexNotifications; intif->pRodexSendMail = intif_parse_RodexSendMail; intif->pRodexCheckName = intif_parse_RodexCheckName; + intif->pGetZenyAck = intif_parse_GetZenyAck; /* Clan System */ intif->pRecvClanMemberAction = intif_parse_RecvClanMemberAction; /* Achievement System */ diff --git a/src/map/intif.h b/src/map/intif.h index ee00baa41..cf857a79c 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -138,6 +138,7 @@ struct intif_interface { int(*rodex_updatemail) (struct map_session_data *sd, int64 mail_id, uint8 opentype, int8 flag); int(*rodex_sendmail) (struct rodex_message *msg); int(*rodex_checkname) (struct map_session_data *sd, const char *name); + void (*pGetZenyAck) (int fd); /* Clan System */ int (*clan_kickoffline) (int clan_id, int kick_interval); int (*clan_membercount) (int clan_id, int kick_interval); diff --git a/src/map/rodex.c b/src/map/rodex.c index 0d3bbf978..2b8ac7757 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -435,16 +435,32 @@ static void rodex_delete_mail(struct map_session_data *sd, int64 mail_id) clif->rodex_delete_mail(sd, msg->opentype, msg->id); } +/// give requested zeny from message to player +static void rodex_getZenyAck(struct map_session_data *sd, int64 mail_id, int8 opentype, int64 zeny) +{ + nullpo_retv(sd); + if (zeny <= 0) { + clif->rodex_request_zeny(sd, opentype, mail_id, RODEX_GET_ZENY_FATAL_ERROR); + return; + } + + if (pc->getzeny(sd, (int)zeny, LOG_TYPE_MAIL, NULL) != 0) { + clif->rodex_request_zeny(sd, opentype, mail_id, RODEX_GET_ZENY_FATAL_ERROR); + return; + } + + clif->rodex_request_zeny(sd, opentype, mail_id, RODEX_GET_ZENY_SUCCESS); +} + /// Gets attached zeny /// @param sd : Who's getting /// @param mail_id : Mail ID that we're getting zeny from static void rodex_get_zeny(struct map_session_data *sd, int8 opentype, int64 mail_id) { - struct rodex_message *msg; nullpo_retv(sd); - msg = rodex->get_mail(sd, mail_id); + struct rodex_message *msg = rodex->get_mail(sd, mail_id); if (msg == NULL) { clif->rodex_request_zeny(sd, opentype, mail_id, RODEX_GET_ZENY_FATAL_ERROR); @@ -456,16 +472,9 @@ static void rodex_get_zeny(struct map_session_data *sd, int8 opentype, int64 mai return; } - if (pc->getzeny(sd, (int)msg->zeny, LOG_TYPE_MAIL, NULL) != 0) { - clif->rodex_request_zeny(sd, opentype, mail_id, RODEX_GET_ZENY_FATAL_ERROR); - return; - } - msg->type &= ~MAIL_TYPE_ZENY; msg->zeny = 0; intif->rodex_updatemail(sd, mail_id, opentype, 1); - - clif->rodex_request_zeny(sd, opentype, mail_id, RODEX_GET_ZENY_SUCCESS); } /// Gets attached item @@ -668,4 +677,5 @@ void rodex_defaults(void) rodex->get_zeny = rodex_get_zeny; rodex->get_items = rodex_get_items; rodex->clean = rodex_clean; + rodex->getZenyAck = rodex_getZenyAck; } diff --git a/src/map/rodex.h b/src/map/rodex.h index 56cc3a9d1..385c77e25 100644 --- a/src/map/rodex.h +++ b/src/map/rodex.h @@ -74,6 +74,7 @@ struct rodex_interface { void (*get_items) (struct map_session_data *sd, int8 opentype, int64 mail_id); void (*delete_mail) (struct map_session_data *sd, int64 mail_id); void (*clean) (struct map_session_data *sd, int8 flag); + void (*getZenyAck) (struct map_session_data *sd, int64 mail_id, int8 opentype, int64 zeny); }; #ifdef HERCULES_CORE |