diff options
author | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-11-12 08:55:36 +0000 |
---|---|---|
committer | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-11-12 08:55:36 +0000 |
commit | 2f6e6453f6296a6335cf6fccbfe0567584ebdbde (patch) | |
tree | c1239f5528ea9254381e78aae0f5d520283151f8 /src | |
parent | 164c37ba01a9a727a2134ec606f875d6aa770413 (diff) | |
download | hercules-2f6e6453f6296a6335cf6fccbfe0567584ebdbde.tar.gz hercules-2f6e6453f6296a6335cf6fccbfe0567584ebdbde.tar.bz2 hercules-2f6e6453f6296a6335cf6fccbfe0567584ebdbde.tar.xz hercules-2f6e6453f6296a6335cf6fccbfe0567584ebdbde.zip |
- Important fix to Mail System allowing (by a low change) items duple.
- Added picklog to mail.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11721 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/char_sql/int_mail.c | 36 | ||||
-rw-r--r-- | src/char_sql/inter.c | 4 | ||||
-rw-r--r-- | src/common/mmo.h | 1 | ||||
-rw-r--r-- | src/map/clif.c | 4 | ||||
-rw-r--r-- | src/map/intif.c | 64 | ||||
-rw-r--r-- | src/map/mail.c | 45 | ||||
-rw-r--r-- | src/map/mail.h | 4 |
7 files changed, 71 insertions, 87 deletions
diff --git a/src/char_sql/int_mail.c b/src/char_sql/int_mail.c index e3c47583c..1a49f787f 100644 --- a/src/char_sql/int_mail.c +++ b/src/char_sql/int_mail.c @@ -384,11 +384,13 @@ static void mapif_parse_Mail_return(int fd) *------------------------------------------*/ static void mapif_Mail_send(int fd, struct mail_message* msg) { - WFIFOHEAD(fd,10); + int len = sizeof(struct mail_message) + 4; + + WFIFOHEAD(fd,len); WFIFOW(fd,0) = 0x384d; - WFIFOL(fd,2) = msg->send_id; - WFIFOL(fd,6) = msg->id; - WFIFOSET(fd,10); + WFIFOW(fd,2) = len; + memcpy(WFIFOP(fd,4), msg, sizeof(struct mail_message)); + WFIFOSET(fd,len); } static void mapif_parse_Mail_send(int fd) @@ -419,37 +421,14 @@ static void mapif_parse_Mail_send(int fd) } } Sql_FreeResult(sql_handle); + msg.status = MAIL_NEW; if( msg.dest_id > 0 ) - { - msg.status = MAIL_UNVERIFIED; msg.id = mail_savemessage(&msg); - } - else - msg.id = 0; mapif_Mail_send(fd, &msg); } -static void mapif_parse_Mail_confirmation(int fd) -{ - int mail_id = RFIFOL(fd,2); - bool fail = RFIFOB(fd,6); - - if( fail ) - { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_INVALID, mail_id) ) - Sql_ShowDebug(sql_handle); - } - else - { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_NEW, mail_id) ) - Sql_ShowDebug(sql_handle); - else - mapif_Mail_new(mail_id); - } -} - /*========================================== * Packets From Map Server *------------------------------------------*/ @@ -463,7 +442,6 @@ int inter_mail_parse_frommap(int fd) case 0x304b: mapif_parse_Mail_delete(fd); break; case 0x304c: mapif_parse_Mail_return(fd); break; case 0x304d: mapif_parse_Mail_send(fd); break; - case 0x304e: mapif_parse_Mail_confirmation(fd); break; default: return 0; } diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index e595324b6..a472018b8 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -54,7 +54,7 @@ int inter_send_packet_length[] = { -1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, // 3810- 35,-1,11,15, 34,29, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, // 3820- 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, // 3830- - 9, 9,-1, 0, 0, 0, 0, 0, -1,74,-1,11, 11,10, 0, 0, // 3840- + 9, 9,-1, 0, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, // 3840- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3850- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3860- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3870- @@ -66,7 +66,7 @@ int inter_recv_packet_length[] = { 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- -1, 6,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1, // 3030- - 5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 7, 0, // 3040- + 5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- diff --git a/src/common/mmo.h b/src/common/mmo.h index 37dc03901..acccc7211 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -240,7 +240,6 @@ struct mmo_charstatus { }; enum mail_status { - MAIL_UNVERIFIED = -1, MAIL_NEW, MAIL_UNREAD, MAIL_READ, diff --git a/src/map/clif.c b/src/map/clif.c index c5cab5987..0c5ff0362 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11650,8 +11650,8 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) if (body_len > MAIL_BODY_LENGTH) body_len = MAIL_BODY_LENGTH; - if( !mail_getattach(sd, &msg) ) - { + if( !mail_setattachment(sd, &msg) ) + { // Invalid Append condition clif_Mail_send(sd->fd, 1); // fail mail_removeitem(sd,0); mail_removezeny(sd,0); diff --git a/src/map/intif.c b/src/map/intif.c index 089d776f6..3cced222f 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -34,7 +34,7 @@ static const int packet_len_table[]={ -1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 - 9, 9,-1,14, 0, 0, 0, 0, -1,74,-1,11, 11,10, 0, 0, //0x3840 + 9, 9,-1,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1560,19 +1560,9 @@ int intif_parse_Mail_getattach(int fd) return 1; } - if (zeny > 0) - { - sd->status.zeny += zeny; - clif_updatestatus(sd, SP_ZENY); - } - memcpy(&item, RFIFOP(fd,12), sizeof(struct item)); - if (item.nameid > 0 && item.amount > 0) - { - pc_additem(sd, &item, item.amount); - clif_Mail_getattachment(sd->fd, 0); - } + mail_getattachment(sd, zeny, &item); return 0; } /*------------------------------------------ @@ -1695,33 +1685,43 @@ int intif_Mail_send(int account_id, struct mail_message *msg) static void intif_parse_Mail_send(int fd) { - struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2)); - int mail_id = RFIFOL(fd,6); - bool fail = false; + struct mail_message msg; + struct map_session_data *sd; + bool fail; - if( mail_id == 0 ) - fail = true; - else + if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) { - fail = !mail_checkattach(sd); - - // Confirmation to CharServer - WFIFOHEAD(inter_fd,7); - WFIFOW(inter_fd,0) = 0x304e; - WFIFOL(inter_fd,2) = mail_id; - WFIFOB(inter_fd,6) = fail; - WFIFOSET(inter_fd,7); + if (battle_config.error_log) + ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); + return; } - nullpo_retv(sd); + memcpy(&msg, RFIFOP(fd,4), sizeof(struct mail_message)); + fail = (msg.id == 0); - if( fail ) - { // Return items and zeny to owner - mail_removeitem(sd, 0); - mail_removezeny(sd, 0); + if( (sd = map_charid2sd(msg.send_id)) ) + { + if( fail ) + { + pc_additem(sd, &msg.item, msg.item.amount); + if( msg.zeny > 0 ) + { + sd->status.zeny += msg.zeny; + clif_updatestatus(sd, SP_ZENY); + } + } + + clif_Mail_send(sd->fd, fail); } - clif_Mail_send(sd->fd, fail); + if( fail ) + return; + + if( (sd = map_charid2sd(msg.dest_id)) ) + { + sd->mail.inbox.changed = true; + clif_Mail_new(sd->fd, msg.id, msg.send_name, msg.title); + } } static void intif_parse_Mail_new(int fd) diff --git a/src/map/mail.c b/src/map/mail.c index e7cd6b2d6..9d2f4375e 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -9,6 +9,7 @@ #include "itemdb.h" #include "clif.h" #include "pc.h" +#include "log.h" #include <time.h> #include <string.h> @@ -26,7 +27,12 @@ int mail_removeitem(struct map_session_data *sd, short flag) if( sd->mail.amount ) { if (flag) + { // Item send + if(log_config.enable_logs&0x2000) + log_pick_pc(sd, "E", sd->mail.nameid, -sd->mail.amount, &sd->status.inventory[sd->mail.index]); + pc_delitem(sd, sd->mail.index, sd->mail.amount, 1); + } else clif_additem(sd, sd->mail.index, sd->mail.amount, 0); } @@ -72,7 +78,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) return 1; if( amount < 0 || amount > sd->status.inventory[idx].amount ) return 1; - if( !itemdb_isdropable(&sd->status.inventory[idx], pc_isGM(sd)) ) + if( !pc_candrop(sd, &sd->status.inventory[idx]) ) return 1; sd->mail.index = idx; @@ -83,12 +89,12 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) } } -bool mail_getattach(struct map_session_data *sd, struct mail_message *msg) +bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg) { int n; - nullpo_retr(0,sd); - nullpo_retr(0,msg); + nullpo_retr(false,sd); + nullpo_retr(false,msg); if( sd->mail.zeny < 0 || sd->mail.zeny > sd->status.zeny ) return false; @@ -110,29 +116,30 @@ bool mail_getattach(struct map_session_data *sd, struct mail_message *msg) msg->zeny = sd->mail.zeny; + // Removes the attachment from sender + mail_removeitem(sd,1); + mail_removezeny(sd,1); + return true; } -bool mail_checkattach(struct map_session_data *sd) +void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item) { - nullpo_retr(false,sd); - - if( sd->mail.zeny > 0 && sd->status.zeny < sd->status.zeny ) - return false; - - if( sd->mail.amount > 0 ) + if( zeny > 0 ) { - if( sd->status.inventory[sd->mail.index].nameid != sd->mail.nameid ) - return false; - - if( sd->status.inventory[sd->mail.index].amount < sd->mail.amount ) - return false; + sd->status.zeny += zeny; + clif_updatestatus(sd, SP_ZENY); } - mail_removeitem(sd,1); - mail_removezeny(sd,1); + if( item->nameid > 0 && item->amount > 0 ) + { + pc_additem(sd, item, item->amount); - return true; + if(log_config.enable_logs&0x2000) + log_pick_pc(sd, "E", item->nameid, item->amount, item); + + clif_Mail_getattachment(sd->fd, 0); + } } int mail_openmail(struct map_session_data *sd) diff --git a/src/map/mail.h b/src/map/mail.h index 1228f5772..1079fc560 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -11,8 +11,8 @@ time_t mail_calctimes(void); int mail_removeitem(struct map_session_data *sd, short flag); int mail_removezeny(struct map_session_data *sd, short flag); unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount); -bool mail_getattach(struct map_session_data *sd, struct mail_message *msg); -bool mail_checkattach(struct map_session_data *sd); +bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg); +void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item); int mail_openmail(struct map_session_data *sd); #endif /* _MAIL_H_ */ |