summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c13
-rw-r--r--src/map/mail.c4
2 files changed, 11 insertions, 6 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 7dc99a493..c020d5760 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11453,8 +11453,8 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
WFIFOW(fd,0) = 0x242;
WFIFOW(fd,2) = len;
WFIFOL(fd,4) = msg->id;
- memcpy(WFIFOP(fd, 8), msg->title, MAIL_TITLE_LENGTH);
- memcpy(WFIFOP(fd,48), msg->send_name, NAME_LENGTH);
+ safestrncpy((char*)WFIFOP(fd,8), msg->title, MAIL_TITLE_LENGTH + 1);
+ safestrncpy((char*)WFIFOP(fd,48), msg->send_name, NAME_LENGTH + 1);
WFIFOL(fd,72) = 0;
WFIFOL(fd,76) = msg->zeny;
@@ -11475,7 +11475,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
memset(WFIFOP(fd,80), 0x00, 19);
WFIFOB(fd,99) = (unsigned char)msg_len;
- safestrncpy((char*)WFIFOP(fd,100), msg->body, msg_len);
+ safestrncpy((char*)WFIFOP(fd,100), msg->body, msg_len + 1);
WFIFOSET(fd,len);
if (msg->status == MAIL_UNREAD) {
@@ -11577,7 +11577,9 @@ void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
return;
flag = mail_setitem(sd, idx, amount);
- clif_Mail_attachment(fd,flag);
+
+ if (idx > 0)
+ clif_Mail_attachment(fd,flag);
}
/*------------------------------------------
@@ -11633,6 +11635,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
return;
}
+ msg.id = 0; // id will be assigned by charserver
msg.send_id = sd->status.char_id;
msg.dest_id = 0; // will attempt to resolve name
safestrncpy(msg.send_name, sd->status.name, NAME_LENGTH);
@@ -11640,7 +11643,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
safestrncpy(msg.title, (char*)RFIFOP(fd,28), MAIL_TITLE_LENGTH);
if (body_len)
- safestrncpy(msg.body, (char*)RFIFOP(fd,69), body_len+1);
+ safestrncpy(msg.body, (char*)RFIFOP(fd,69), body_len + 1);
else
memset(msg.body, 0x00, MAIL_BODY_LENGTH);
diff --git a/src/map/mail.c b/src/map/mail.c
index c95d6fbfa..e1c006a0a 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -55,7 +55,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount)
if (idx == 0)
{ // Zeny Transfer
if (amount < 0)
- return 2; //FIXME: totally wrong value
+ return 0;
if (amount > sd->status.zeny)
amount = sd->status.zeny;
@@ -105,6 +105,8 @@ bool mail_getattach(struct map_session_data *sd, struct mail_message *msg)
memcpy(&msg->item, &sd->status.inventory[n], sizeof(struct item));
msg->item.amount = sd->mail.amount;
}
+ else
+ memset(&msg->item, 0x00, sizeof(struct item));
msg->zeny = sd->mail.zeny;