diff options
-rw-r--r-- | src/map/intif.c | 5 | ||||
-rw-r--r-- | src/map/quest.c | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/map/intif.c b/src/map/intif.c index 8fdc8e3a3..3779eaa21 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1337,12 +1337,13 @@ void intif_parse_QuestLog(int fd) { if (!sd) // User not online anymore return; + sd->num_quests = sd->avail_quests = 0; + if (num_received == 0) { if (sd->quest_log) { aFree(sd->quest_log); sd->quest_log = NULL; } - sd->num_quests = sd->avail_quests = 0; } else { struct quest *received = (struct quest *)RFIFOP(fd, 8); int i, k = num_received; @@ -1357,7 +1358,7 @@ void intif_parse_QuestLog(int fd) { ShowError("intif_parse_QuestLog: quest %d not found in DB.\n", received[i].quest_id); continue; } - if (received->state != Q_COMPLETE) { + if (received[i].state != Q_COMPLETE) { // Insert at the beginning memcpy(&sd->quest_log[sd->avail_quests++], &received[i], sizeof(struct quest)); } else { diff --git a/src/map/quest.c b/src/map/quest.c index f2a6fae1f..bde276f9d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -460,9 +460,9 @@ int quest_reload_check_sub(struct map_session_data *sd, va_list ap) { } j++; } - sd->num_quests = 0; - ARR_FIND(sd->avail_quests, 0, j, sd->quest_log[j].state != Q_COMPLETE); - sd->avail_quests = j+1; + sd->num_quests = j; + ARR_FIND(0, sd->num_quests, i, sd->quest_log[i].state == Q_COMPLETE); + sd->avail_quests = i; return 1; } |