diff options
author | Haru <haru@dotalux.com> | 2018-01-10 15:25:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-10 15:25:13 +0100 |
commit | 544447b1fc71f65d09a90b82d67e31119d5e917b (patch) | |
tree | 360c1b7bb5be59762e242ea2b2320e0c456dcc2c /src/char/int_rodex.c | |
parent | 8d10339b3deea907e09f5b99a3c1a8e3557f4442 (diff) | |
parent | 09163dc60143ae8427d25fb8e9863adba986bb72 (diff) | |
download | hercules-544447b1fc71f65d09a90b82d67e31119d5e917b.tar.gz hercules-544447b1fc71f65d09a90b82d67e31119d5e917b.tar.bz2 hercules-544447b1fc71f65d09a90b82d67e31119d5e917b.tar.xz hercules-544447b1fc71f65d09a90b82d67e31119d5e917b.zip |
Merge pull request #1945 from guilherme-gm/rodex-load-fix
Fixed rodex loading mails when it requires multiple packets.
Diffstat (limited to 'src/char/int_rodex.c')
-rw-r--r-- | src/char/int_rodex.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c index f5d036991..b7314e726 100644 --- a/src/char/int_rodex.c +++ b/src/char/int_rodex.c @@ -346,27 +346,28 @@ int64 inter_rodex_savemessage(struct rodex_message* msg) *------------------------------------------*/ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails) { - int per_packet = (UINT16_MAX - 15) / sizeof(struct rodex_message); + int per_packet = (UINT16_MAX - 16) / sizeof(struct rodex_message); int sent = 0; + bool is_first = true; nullpo_retv(mails); Assert_retv(char_id > 0); Assert_retv(count >= 0); do { - int i = 15, j, size, limit; + int i = 16, j, size, limit; + int to_send = count - sent; bool is_last = true; - if (count <= per_packet) { - size = count * sizeof(struct rodex_message) + 15; - limit = count; + if (to_send <= per_packet) { + size = to_send * sizeof(struct rodex_message) + 16; + limit = to_send; is_last = true; } else { - int to_send = count - sent; limit = min(to_send, per_packet); if (limit != to_send) { is_last = false; } - size = limit * sizeof(struct rodex_message) + 15; + size = limit * sizeof(struct rodex_message) + 16; } WFIFOHEAD(fd, size); @@ -376,11 +377,14 @@ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int co WFIFOB(fd, 8) = opentype; WFIFOB(fd, 9) = flag; WFIFOB(fd, 10) = is_last; - WFIFOL(fd, 11) = count; + WFIFOB(fd, 11) = is_first; + WFIFOL(fd, 12) = limit; for (j = 0; j < limit; ++j, ++sent, i += sizeof(struct rodex_message)) { memcpy(WFIFOP(fd, i), &VECTOR_INDEX(*mails, sent), sizeof(struct rodex_message)); } WFIFOSET(fd, size); + + is_first = false; } while (sent < count); } |