From 0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d Mon Sep 17 00:00:00 2001 From: Asheraf Date: Wed, 3 Oct 2018 11:30:02 +0100 Subject: Add new type for mercenary class to setquestinfo() --- src/map/quest.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/map/quest.c') diff --git a/src/map/quest.c b/src/map/quest.c index 02bf7638b..f10d6847f 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; } @@ -900,6 +903,29 @@ static bool quest_questinfo_validate_quests(struct map_session_data *sd, struct return true; } +/** + * 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 * @@ -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; } -- cgit v1.2.3-70-g09d2