summaryrefslogtreecommitdiff
path: root/src/map/quest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/quest.c')
-rw-r--r--src/map/quest.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/map/quest.c b/src/map/quest.c
index 02bf7638b..38ac88eea 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -30,6 +30,7 @@
#include "map/itemdb.h"
#include "map/log.h"
#include "map/map.h"
+#include "map/mercenary.h"
#include "map/mob.h"
#include "map/npc.h"
#include "map/party.h"
@@ -584,7 +585,7 @@ static int quest_read_db(void)
count++;
}
libconfig->destroy(&quest_db_conf);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filepath);
return count;
}
@@ -671,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);
}
}
}
@@ -719,6 +721,8 @@ static bool quest_questinfo_validate(struct map_session_data *sd, struct questin
return false;
if (VECTOR_LENGTH(qi->quest_requirement) > 0 && quest->questinfo_validate_quests(sd, qi) == false)
return false;
+ if (qi->mercenary_class != 0 && quest->questinfo_validate_mercenary_class(sd, qi) == false)
+ return false;
return true;
}
@@ -811,7 +815,7 @@ static bool quest_questinfo_validate_items(struct map_session_data *sd, struct q
for (int i = 0; i < VECTOR_LENGTH(qi->items); i++) {
struct questinfo_itemreq *item = &VECTOR_INDEX(qi->items, i);
int count = 0;
- for (int j = 0; j < MAX_INVENTORY; j++) {
+ for (int j = 0; j < sd->status.inventorySize; j++) {
if (sd->status.inventory[j].nameid == item->nameid)
count += sd->status.inventory[j].amount;
}
@@ -901,23 +905,26 @@ static bool quest_questinfo_validate_quests(struct map_session_data *sd, struct
}
/**
- * Clears the questinfo data vector
+ * Validate mercenary class required for the questinfo
*
- * @param m mapindex.
+ * @param sd session data.
+ * @param qi questinfo data.
*
+ * @retval true if player have a mercenary with the given class.
+ * @retval false if player does NOT have a mercenary with the given class.
*/
-static void quest_questinfo_vector_clear(int m)
+static bool quest_questinfo_validate_mercenary_class(struct map_session_data *sd, struct questinfo *qi)
{
- int i;
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+
+ if (sd->md == NULL)
+ return false;
- Assert_retv(m >= 0 && m < map->count);
+ if (sd->md->mercenary.class_ != qi->mercenary_class)
+ return false;
- 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);
+ return true;
}
/**
@@ -993,5 +1000,5 @@ void quest_defaults(void)
quest->questinfo_validate_homunculus_level = quest_questinfo_validate_homunculus_level;
quest->questinfo_validate_homunculus_type = quest_questinfo_validate_homunculus_type;
quest->questinfo_validate_quests = quest_questinfo_validate_quests;
- quest->questinfo_vector_clear = quest_questinfo_vector_clear;
+ quest->questinfo_validate_mercenary_class = quest_questinfo_validate_mercenary_class;
}