diff options
Diffstat (limited to 'src/map/quest.c')
-rw-r--r-- | src/map/quest.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/map/quest.c b/src/map/quest.c index 02bf7638b..7a216095e 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" @@ -719,6 +720,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 +814,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,6 +904,29 @@ static bool quest_questinfo_validate_quests(struct map_session_data *sd, struct } /** + * Validate mercenary class required for the questinfo + * + * @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 bool quest_questinfo_validate_mercenary_class(struct map_session_data *sd, struct questinfo *qi) +{ + nullpo_retr(false, sd); + nullpo_retr(false, qi); + + if (sd->md == NULL) + return false; + + if (sd->md->mercenary.class_ != qi->mercenary_class) + return false; + + return true; +} + +/** * Clears the questinfo data vector * * @param m mapindex. @@ -993,5 +1019,6 @@ 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_validate_mercenary_class = quest_questinfo_validate_mercenary_class; quest->questinfo_vector_clear = quest_questinfo_vector_clear; } |