diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 4 | ||||
-rw-r--r-- | src/map/clif.c | 30 | ||||
-rw-r--r-- | src/map/intif.c | 4 | ||||
-rw-r--r-- | src/map/mail.c | 21 | ||||
-rw-r--r-- | src/map/mail.h | 22 | ||||
-rw-r--r-- | src/map/script.c | 2 |
6 files changed, 51 insertions, 32 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6cda0ad84..b6a9e42ee 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3729,7 +3729,7 @@ ACMD(reloadscript) for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pl_sd->npc_id || pl_sd->npc_shopid) { if (pl_sd->state.using_fake_npc) { - clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); + clif->clearunit_single(pl_sd->npc_id, CLR_OUTSIGHT, pl_sd->fd); pl_sd->state.using_fake_npc = 0; } if (pl_sd->state.menu_or_input) @@ -6624,7 +6624,7 @@ ACMD(misceffect) { ACMD(mail) { nullpo_ret(sd); - mail_openmail(sd); + mail->openmail(sd); return true; } diff --git a/src/map/clif.c b/src/map/clif.c index 23501d370..e8de09d70 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8560,7 +8560,7 @@ void clif_refresh(struct map_session_data *sd) // unlike vending, resuming buyingstore crashes the client. buyingstore->close(sd); - mail_clear(sd); + mail->clear(sd); if( disguised(&sd->bl) ) {/* refresh-da */ short disguise = sd->disguise; @@ -9601,7 +9601,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) } } - mail_clear(sd); + mail->clear(sd); clif->maptypeproperty2(&sd->bl,SELF); @@ -14471,8 +14471,8 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd) else clif->mail_refreshinbox(sd); - mail_removeitem(sd, 0); - mail_removezeny(sd, 0); + mail->removeitem(sd, 0); + mail->removezeny(sd, 0); } @@ -14546,7 +14546,7 @@ void clif_parse_Mail_read(int fd, struct map_session_data *sd) if( mail_id <= 0 ) return; - if( mail_invalid_operation(sd) ) + if( mail->invalid_operation(sd) ) return; clif->mail_read(sd, RFIFOL(fd,2)); @@ -14565,7 +14565,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) return; if( mail_id <= 0 ) return; - if( mail_invalid_operation(sd) ) + if( mail->invalid_operation(sd) ) return; ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); @@ -14626,7 +14626,7 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd) return; if( mail_id <= 0 ) return; - if( mail_invalid_operation(sd) ) + if( mail->invalid_operation(sd) ) return; ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); @@ -14652,7 +14652,7 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd) if( mail_id <= 0 ) return; - if( mail_invalid_operation(sd) ) + if( mail->invalid_operation(sd) ) return; ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); @@ -14676,7 +14676,7 @@ void clif_parse_Mail_setattach(int fd, struct map_session_data *sd) if (idx < 0 || amount < 0) return; - flag = mail_setitem(sd, idx, amount); + flag = mail->setitem(sd, idx, amount); clif->mail_setattachment(fd,idx,flag); } @@ -14692,9 +14692,9 @@ void clif_parse_Mail_winopen(int fd, struct map_session_data *sd) int flag = RFIFOW(fd,2); if (flag == 0 || flag == 1) - mail_removeitem(sd, 0); + mail->removeitem(sd, 0); if (flag == 0 || flag == 2) - mail_removezeny(sd, 0); + mail->removezeny(sd, 0); } @@ -14726,10 +14726,10 @@ 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_setattachment(sd, &msg) ) { // Invalid Append condition + if( !mail->setattachment(sd, &msg) ) { // Invalid Append condition clif->mail_send(sd->fd, true); // fail - mail_removeitem(sd,0); - mail_removezeny(sd,0); + mail->removeitem(sd,0); + mail->removezeny(sd,0); return; } @@ -14751,7 +14751,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) msg.timestamp = time(NULL); if( !intif_Mail_send(sd->status.account_id, &msg) ) - mail_deliveryfail(sd, &msg); + mail->deliveryfail(sd, &msg); sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection } diff --git a/src/map/intif.c b/src/map/intif.c index 3cdf93487..f3931e79e 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1582,7 +1582,7 @@ int intif_parse_Mail_getattach(int fd) memcpy(&item, RFIFOP(fd,12), sizeof(struct item)); - mail_getattachment(sd, zeny, &item); + mail->getattachment(sd, zeny, &item); return 0; } /*------------------------------------------ @@ -1718,7 +1718,7 @@ static void intif_parse_Mail_send(int fd) if( sd != NULL ) { if( fail ) - mail_deliveryfail(sd, &msg); + mail->deliveryfail(sd, &msg); else { clif->mail_send(sd->fd, false); diff --git a/src/map/mail.c b/src/map/mail.c index 299fb5117..24af018ad 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -72,7 +72,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) { return 0; } else { // Item Transfer idx -= 2; - mail_removeitem(sd, 0); + mail->removeitem(sd, 0); if( idx < 0 || idx >= MAX_INVENTORY ) return 1; @@ -121,8 +121,8 @@ bool mail_setattachment(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); + mail->removeitem(sd,1); + mail->removezeny(sd,1); return true; } @@ -183,3 +183,18 @@ bool mail_invalid_operation(struct map_session_data *sd) return false; } + +void mail_defaults(void) +{ + mail = &mail_s; + + mail->clear = mail_clear; + mail->removeitem = mail_removeitem; + mail->removezeny = mail_removezeny; + mail->setitem = mail_setitem; + mail->setattachment = mail_setattachment; + mail->getattachment = mail_getattachment; + mail->openmail = mail_openmail; + mail->deliveryfail = mail_deliveryfail; + mail->invalid_operation = mail_invalid_operation; +}
\ No newline at end of file diff --git a/src/map/mail.h b/src/map/mail.h index cab582e55..5e5883aa6 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -6,14 +6,18 @@ #include "../common/mmo.h" -void mail_clear(struct map_session_data *sd); -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_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); -void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg); -bool mail_invalid_operation(struct map_session_data *sd); +struct mail_interface { + void (*clear) (struct map_session_data *sd); + int (*removeitem) (struct map_session_data *sd, short flag); + int (*removezeny) (struct map_session_data *sd, short flag); + unsigned char (*setitem) (struct map_session_data *sd, int idx, int amount); + bool (*setattachment) (struct map_session_data *sd, struct mail_message *msg); + void (*getattachment) (struct map_session_data* sd, int zeny, struct item* item); + int (*openmail) (struct map_session_data *sd); + void (*deliveryfail) (struct map_session_data *sd, struct mail_message *msg); + bool (*invalid_operation) (struct map_session_data *sd); +} mail_s; + +struct mail_interface *mail; #endif /* _MAIL_H_ */ diff --git a/src/map/script.c b/src/map/script.c index 2b2628aa3..cccf5a7d2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15274,7 +15274,7 @@ BUILDIN(openmail) if( sd == NULL ) return true; - mail_openmail(sd); + mail->openmail(sd); return true; } |