summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-12-03 04:45:12 +0100
committerHaru <haru@dotalux.com>2016-12-03 15:38:57 +0100
commita222f21b459eb6abc0862695526c1d15361a99e0 (patch)
tree52e1732a43ebd4dedca7aa2a9ccaf76add58f0c2 /src/map/pc.c
parent8a9e589446058b33972aff2c054f8c300b3fd1b7 (diff)
downloadhercules-a222f21b459eb6abc0862695526c1d15361a99e0.tar.gz
hercules-a222f21b459eb6abc0862695526c1d15361a99e0.tar.bz2
hercules-a222f21b459eb6abc0862695526c1d15361a99e0.tar.xz
hercules-a222f21b459eb6abc0862695526c1d15361a99e0.zip
Add function to retrieve the appropriate fame list type for a job mapid
This commit adds the function `pc->famelist_type()` to retrieve the appropriate fame list for a given job (common operation). When the given job ID doesn't have an appropriate fame list, the newly introduced value RANKTYPE_UNKNOWN is returned. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 894880608..8d6910ce4 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -470,6 +470,26 @@ int pc_fame_rank(int char_id, int ranktype)
return 0;
}
+/**
+ * Returns the appropriate fame list type for the given job.
+ *
+ * @param job_mapid The job (in MapID format)
+ * @return the appropriate fame list type (@see enum fame_list_type).
+ * @retval RANKTYPE_UNKNOWN if no appropriate type exists.
+ */
+int pc_famelist_type(uint16 job_mapid) {
+ switch (job_mapid & MAPID_UPPERMASK) {
+ case MAPID_BLACKSMITH:
+ return RANKTYPE_BLACKSMITH;
+ case MAPID_ALCHEMIST:
+ return RANKTYPE_ALCHEMIST;
+ case MAPID_TAEKWON:
+ return RANKTYPE_TAEKWON;
+ default:
+ return RANKTYPE_UNKNOWN;
+ }
+}
+
int pc_setrestartvalue(struct map_session_data *sd,int type) {
struct status_data *st, *bst;
nullpo_ret(sd);
@@ -8624,12 +8644,11 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper)
}
sd->status.class = class;
- if ((sd->job & MAPID_UPPERMASK) == MAPID_BLACKSMITH)
- fame_flag = pc->fame_rank(sd->status.char_id, RANKTYPE_BLACKSMITH);
- else if ((sd->job & MAPID_UPPERMASK) == MAPID_ALCHEMIST)
- fame_flag = pc->fame_rank(sd->status.char_id, RANKTYPE_ALCHEMIST);
- else if ((sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON)
- fame_flag = pc->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON);
+ {
+ int fame_list_type = pc->famelist_type(sd->job);
+ if (fame_list_type != RANKTYPE_UNKNOWN)
+ fame_flag = pc->fame_rank(sd->status.char_id, fame_list_type);
+ }
sd->job = (uint16)job;
sd->status.job_level=1;
sd->status.job_exp=0;
@@ -8715,7 +8734,7 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper)
pc->equiplookall(sd);
//if you were previously famous, not anymore.
- if (fame_flag) {
+ if (fame_flag != 0) {
chrif->save(sd,0);
chrif->buildfamelist();
} else if (sd->status.fame > 0) {
@@ -12131,6 +12150,7 @@ void pc_defaults(void) {
pc->delspiritball = pc_delspiritball;
pc->addfame = pc_addfame;
pc->fame_rank = pc_fame_rank;
+ pc->famelist_type = pc_famelist_type;
pc->set_hate_mob = pc_set_hate_mob;
pc->getmaxspiritball = pc_getmaxspiritball;