summaryrefslogtreecommitdiff
path: root/src/map/intif.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-01-10 15:25:13 +0100
committerGitHub <noreply@github.com>2018-01-10 15:25:13 +0100
commit544447b1fc71f65d09a90b82d67e31119d5e917b (patch)
tree360c1b7bb5be59762e242ea2b2320e0c456dcc2c /src/map/intif.c
parent8d10339b3deea907e09f5b99a3c1a8e3557f4442 (diff)
parent09163dc60143ae8427d25fb8e9863adba986bb72 (diff)
downloadhercules-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/map/intif.c')
-rw-r--r--src/map/intif.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index 60edc8d8b..be6b75d96 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -2438,7 +2438,8 @@ void intif_parse_RequestRodexOpenInbox(int fd)
#endif
int8 flag = RFIFOB(fd, 9);
int8 is_end = RFIFOB(fd, 10);
- int count = RFIFOL(fd, 11);
+ int is_first = RFIFOB(fd, 11);
+ int count = RFIFOL(fd, 12);
int i, j;
sd = map->charid2sd(RFIFOL(fd, 4));
@@ -2446,16 +2447,25 @@ void intif_parse_RequestRodexOpenInbox(int fd)
if (sd == NULL) // user is not online anymore
return;
- sd->rodex.total = count;
- if (RFIFOW(fd, 2) - 15 != sd->rodex.total * sizeof(struct rodex_message)) {
- ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 15, sd->rodex.total * sizeof(struct rodex_message));
+ if (is_first == false && sd->rodex.total == 0) {
+ ShowError("intif_parse_RodexInboxOpenReceived: mail list received in wrong order.\n");
return;
}
- if (flag == 0)
+ if (is_first)
+ sd->rodex.total = count;
+ else
+ sd->rodex.total += count;
+
+ if (RFIFOW(fd, 2) - 16 != count * sizeof(struct rodex_message)) {
+ ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 16, count * sizeof(struct rodex_message));
+ return;
+ }
+
+ if (flag == 0 && is_first)
VECTOR_CLEAR(sd->rodex.messages);
- for (i = 0, j = 15; i < count; ++i, j += sizeof(struct rodex_message)) {
+ for (i = 0, j = 16; i < count; ++i, j += sizeof(struct rodex_message)) {
struct rodex_message msg = { 0 };
VECTOR_ENSURE(sd->rodex.messages, 1, 1);
memcpy(&msg, RFIFOP(fd, j), sizeof(struct rodex_message));