summaryrefslogtreecommitdiff
path: root/src/map/quest.c
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2019-04-21 17:07:47 +0100
committerAsheraf <acheraf1998@gmail.com>2019-05-06 19:59:30 +0000
commitabe4b83a81c437d404aadea723165d98c33d462d (patch)
treee6b5eaeda12876358d6a00636d20bc311502f8ad /src/map/quest.c
parent403939af8bdb08e33f9b0a6613fe2e5e00bbea04 (diff)
downloadhercules-abe4b83a81c437d404aadea723165d98c33d462d.tar.gz
hercules-abe4b83a81c437d404aadea723165d98c33d462d.tar.bz2
hercules-abe4b83a81c437d404aadea723165d98c33d462d.tar.xz
hercules-abe4b83a81c437d404aadea723165d98c33d462d.zip
Move questinfo data from map to npc_data
this will fix the issue where having multiple `questinfo()` blocks wont work properly
Diffstat (limited to 'src/map/quest.c')
-rw-r--r--src/map/quest.c42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/map/quest.c b/src/map/quest.c
index 7a216095e..9540b411d 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -672,21 +672,22 @@ static int quest_questinfo_validate_icon(int icon)
*/
static void quest_questinfo_refresh(struct map_session_data *sd)
{
- int i;
-
nullpo_retv(sd);
- for (i = 0; i < VECTOR_LENGTH(map->list[sd->bl.m].qi_data); i++) {
- struct questinfo *qi = &VECTOR_INDEX(map->list[sd->bl.m].qi_data, i);
- // Remove the bubbles if one of the conditions is no longer valid.
- if (quest->questinfo_validate(sd, qi) == false) {
+ for (int i = 0; i < VECTOR_LENGTH(map->list[sd->bl.m].qi_list); i++) {
+ struct npc_data *nd = &VECTOR_INDEX(map->list[sd->bl.m].qi_list, i);
+
+ int j;
+ ARR_FIND(0, VECTOR_LENGTH(nd->qi_data), j, quest->questinfo_validate(sd, &VECTOR_INDEX(nd->qi_data, j)) == true);
+ if (j != VECTOR_LENGTH(nd->qi_data)) {
+ struct questinfo *qi = &VECTOR_INDEX(nd->qi_data, j);
+ clif->quest_show_event(sd, &nd->bl, qi->icon, qi->color);
+ } else {
#if PACKETVER >= 20120410
- clif->quest_show_event(sd, &qi->nd->bl, 9999, 0);
+ clif->quest_show_event(sd, &nd->bl, 9999, 0);
#else
- clif->quest_show_event(sd, &qi->nd->bl, 0, 0);
+ clif->quest_show_event(sd, &nd->bl, 0, 0);
#endif
- } else {
- clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
}
}
}
@@ -927,26 +928,6 @@ static bool quest_questinfo_validate_mercenary_class(struct map_session_data *sd
}
/**
- * Clears the questinfo data vector
- *
- * @param m mapindex.
- *
- */
-static void quest_questinfo_vector_clear(int m)
-{
- int i;
-
- Assert_retv(m >= 0 && m < map->count);
-
- for (i = 0; i < VECTOR_LENGTH(map->list[m].qi_data); i++) {
- struct questinfo *qi_data = &VECTOR_INDEX(map->list[m].qi_data, i);
- VECTOR_CLEAR(qi_data->items);
- VECTOR_CLEAR(qi_data->quest_requirement);
- }
- VECTOR_CLEAR(map->list[m].qi_data);
-}
-
-/**
* Initializes the quest interface.
*
* @param minimal Run in minimal mode (skips most of the loading)
@@ -1020,5 +1001,4 @@ void quest_defaults(void)
quest->questinfo_validate_homunculus_type = quest_questinfo_validate_homunculus_type;
quest->questinfo_validate_quests = quest_questinfo_validate_quests;
quest->questinfo_validate_mercenary_class = quest_questinfo_validate_mercenary_class;
- quest->questinfo_vector_clear = quest_questinfo_vector_clear;
}