From 581f8c7393757ea70c4aaa64f6e20b57f74a32ae Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 30 Oct 2017 01:55:16 +0100 Subject: Use the skill DB accessors where possible/appropriate This includes some renamed local variables, in order to minimize the cases of unsafe variable reuse. Signed-off-by: Haru --- src/map/pc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 0636ebafa..f622b3d42 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1622,18 +1622,25 @@ int pc_calc_skilltree(struct map_session_data *sd) if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->dbs->db[i].nameid >= DC_HUMMING && skill->dbs->db[i].nameid <= DC_SERVICEFORYOU ) { //Enable Bard/Dancer spirit linked skills. - if( sd->status.sex ) - { //Link dancer skills to bard. - // i can be < 8? - if( sd->status.skill[i-8].lv < 10 ) + if (sd->status.sex) { + // Link dancer skills to bard. + if (i < 8) { + Assert_report(i >= 8); + continue; + } + if (sd->status.skill[i-8].lv < 10) continue; sd->status.skill[i].id = skill->dbs->db[i].nameid; sd->status.skill[i].lv = sd->status.skill[i-8].lv; // Set the level to the same as the linking skill sd->status.skill[i].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill - } else { //Link bard skills to dancer. - if( sd->status.skill[i].lv < 10 ) + } else { + // Link bard skills to dancer. + if (i < 8) { + Assert_report(i >= 8); + continue; + } + if (sd->status.skill[i].lv < 10) continue; - // i can be < 8? sd->status.skill[i-8].id = skill->dbs->db[i-8].nameid; sd->status.skill[i-8].lv = sd->status.skill[i].lv; // Set the level to the same as the linking skill sd->status.skill[i-8].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill @@ -4143,7 +4150,7 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4 *------------------------------------------*/ int pc_skill(struct map_session_data *sd, int id, int level, int flag) { - uint16 index = 0; + int index = 0; nullpo_ret(sd); if (!(index = skill->get_index(id))) { @@ -5869,7 +5876,7 @@ int pc_memo(struct map_session_data* sd, int pos) { * Return player sd skill_lv learned for given skill *------------------------------------------*/ int pc_checkskill(struct map_session_data *sd,uint16 skill_id) { - uint16 index = 0; + int index = 0; if(sd == NULL) return 0; if( skill_id >= GD_SKILLBASE && skill_id < GD_MAX ) { struct guild *g; @@ -7229,7 +7236,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) * Skill point allocation *------------------------------------------*/ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { - uint16 index = 0; + int index = 0; nullpo_ret(sd); if( skill_id >= GD_SKILLBASE && skill_id < GD_SKILLBASE+MAX_GUILDSKILL ) { -- cgit v1.2.3-70-g09d2