From 31400d054ec5744e43deb4a6928f496d92f01c34 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 18 Apr 2018 22:05:08 +0300 Subject: Move job related code from pc_resetskill into separate function. --- src/map/pc.c | 40 ++++++++++++++++++++++++++-------------- src/map/pc.h | 1 + 2 files changed, 27 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/map/pc.c b/src/map/pc.c index 09040e816..f4f2b5044 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -7639,7 +7639,6 @@ int pc_resetskill(struct map_session_data* sd, int flag) } for (i = 1; i < MAX_SKILL_DB; i++) { - uint16 skill_id = 0; int lv = sd->status.skill[i].lv; if (lv < 1) continue; @@ -7648,19 +7647,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) if( inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL) ) //Avoid reseting wedding/linker skills. continue; - skill_id = skill->dbs->db[i].nameid; - - // Don't reset trick dead if not a novice/baby - if (skill_id == NV_TRICKDEAD && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) { - sd->status.skill[i].lv = 0; - sd->status.skill[i].flag = 0; - continue; - } - - // do not reset basic skill - if (skill_id == NV_BASIC && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) - continue; - if (skill_id == SU_BASIC_SKILL && (sd->job & MAPID_BASEMASK) != MAPID_SUMMONER) + if (pc->resetskill_job(sd, i)) continue; if( sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED ) @@ -7715,6 +7702,30 @@ int pc_resetskill(struct map_session_data* sd, int flag) return skill_point; } +bool pc_resetskill_job(struct map_session_data* sd, int index) +{ + uint16 skill_id; + + nullpo_retr(false, sd); + Assert_retr(false, index >= 0 && index < MAX_SKILL_DB); + + skill_id = skill->dbs->db[index].nameid; + + // Don't reset trick dead if not a novice/baby + if (skill_id == NV_TRICKDEAD && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) { + sd->status.skill[index].lv = 0; + sd->status.skill[index].flag = 0; + return true; + } + + // do not reset basic skill + if (skill_id == NV_BASIC && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) + return true; + if (skill_id == SU_BASIC_SKILL && (sd->job & MAPID_BASEMASK) != MAPID_SUMMONER) + return true; + return false; +} + /*========================================== * /resetfeel [Komurka] *------------------------------------------*/ @@ -12334,6 +12345,7 @@ void pc_defaults(void) { pc->resetlvl = pc_resetlvl; pc->resetstate = pc_resetstate; pc->resetskill = pc_resetskill; + pc->resetskill_job = pc_resetskill_job; pc->resetfeel = pc_resetfeel; pc->resethate = pc_resethate; pc->equipitem = pc_equipitem; diff --git a/src/map/pc.h b/src/map/pc.h index dca640614..77bc795d6 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -971,6 +971,7 @@ END_ZEROED_BLOCK; /* End */ int (*resetlvl) (struct map_session_data *sd,int type); int (*resetstate) (struct map_session_data *sd); int (*resetskill) (struct map_session_data *sd, int flag); + bool (*resetskill_job) (struct map_session_data *sd, int index); int (*resetfeel) (struct map_session_data *sd); int (*resethate) (struct map_session_data *sd); int (*equipitem) (struct map_session_data *sd,int n,int req_pos); -- cgit v1.2.3-70-g09d2