summaryrefslogtreecommitdiff
path: root/src/map/quest.c
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2018-10-03 11:30:02 +0100
committerAsheraf <acheraf1998@gmail.com>2018-10-03 12:00:13 +0100
commit0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d (patch)
tree96a840c231dadd04e94c4bfe857b4bc77ccdc485 /src/map/quest.c
parent852c13305f67948531bd0277eb1922dbd02b1f26 (diff)
downloadhercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.tar.gz
hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.tar.bz2
hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.tar.xz
hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.zip
Add new type for mercenary class to setquestinfo()
Diffstat (limited to 'src/map/quest.c')
-rw-r--r--src/map/quest.c27
1 files changed, 27 insertions, 0 deletions
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;
}
@@ -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;
}