summaryrefslogtreecommitdiff
path: root/src/map/status.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-12-02 16:00:08 +0100
committerHaru <haru@dotalux.com>2016-12-03 15:38:56 +0100
commit76801cdf48a979728034cb81b81c989f7f655f5a (patch)
tree0c7ab7e9170515c982399df7eda3bd2577521a06 /src/map/status.c
parentcfa4ae95efca5557d085c56815259f47e6f380fb (diff)
downloadhercules-76801cdf48a979728034cb81b81c989f7f655f5a.tar.gz
hercules-76801cdf48a979728034cb81b81c989f7f655f5a.tar.bz2
hercules-76801cdf48a979728034cb81b81c989f7f655f5a.tar.xz
hercules-76801cdf48a979728034cb81b81c989f7f655f5a.zip
Clarify some Job Class vs MapID confusion (2/2)
This commit ensures that `sd->job` and related variables only contain MapIDs (i.e. the serverside optimized values, where High Novice is MAPID_NOVICE | JOBL_UPPER) and are never checked against the client-based Job Class values. As a rule of thumb, from now on, when a variable is named `job` or `jobid`, it is intended to contain a MapID and not a Job Class ID. The type of such variable shall be an unsigned `uint16` or `uint32`. To ensure that related third party code is also verified when this commit is merged, the variable `struct map_session_data::class_ (i.e. `sd->class_`) is renamed to `job`. Some issues in related lines are also fixed, including: - The atcommand `@mount` would not check properly that the requesting character is a 2nd class Swordsman type. - `pc->addfame()` would silently accept invalid MapIDs, sending unknown values to the client (more on this in a subsequent commit). - `pc->famerank()` would not use the passed job as a bitmask, causing the caller to have to mask it beforehand (more on this in a subsequent commit). - The Soul Linker check in TK_JUMPKICK wasn't future-proof (no harm caused currently). - Gunslingers would be able to be targeted by Spiritual Bestowment (`MO_KITRANSLATION`) and Spiritual Sphere Absorption (`MO_ABSORBSPIRITS`) due to a faulty check introduced when the Rebellion class was implemented (causing unintended interaction with Coins). Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/status.c')
-rw-r--r--src/map/status.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/map/status.c b/src/map/status.c
index 6f8c7a9e8..fe412dce7 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2272,11 +2272,11 @@ unsigned int status_get_base_maxsp(const struct map_session_data *sd, const stru
val = pc->class2idx(sd->status.class);
val = status->dbs->SP_table[val][sd->status.base_level];
- if ( sd->class_&JOBL_UPPER )
+ if ((sd->job & JOBL_UPPER) != 0)
val += val * 25 / 100;
- else if ( sd->class_&JOBL_BABY )
+ else if ((sd->job & JOBL_BABY) != 0)
val = val * 70 / 100;
- if ( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
+ if ((sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON))
val *= 3; //Triple max SP for top ranking Taekwons over level 90.
val += val * st->int_ / 100;
@@ -2293,17 +2293,17 @@ unsigned int status_get_base_maxhp(const struct map_session_data *sd, const stru
val = pc->class2idx(sd->status.class);
val = status->dbs->HP_table[val][sd->status.base_level];
- if ( (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99 )
+ if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99)
val += 2000; //Supernovice lvl99 hp bonus.
- if ( (sd->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E && sd->status.base_level >= 150 )
+ if ((sd->job & MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E && sd->status.base_level >= 150)
val += 2000; //Extented Supernovice lvl150 hp bonus.
- if ( sd->class_&JOBL_UPPER )
+ if ((sd->job & JOBL_UPPER) != 0)
val += val * 25 / 100; //Trans classes get a 25% hp bonus
- else if ( sd->class_&JOBL_BABY )
+ else if ((sd->job & JOBL_BABY) != 0)
val = val * 70 / 100; //Baby classes get a 30% hp penalty
- if ( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
+ if ((sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON))
val *= 3; //Triple max HP for top ranking Taekwons over level 90.
val += val * st->vit / 100; // +1% per each point of VIT
@@ -2404,9 +2404,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
//Give them all modes except these (useful for clones)
bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK);
- bstatus->size = (sd->class_&JOBL_BABY || (sd->class_&MAPID_BASEMASK) == MAPID_SUMMONER)?SZ_SMALL:SZ_MEDIUM;
+ bstatus->size = ((sd->job & JOBL_BABY) != 0 || (sd->job & MAPID_BASEMASK) == MAPID_SUMMONER)?SZ_SMALL:SZ_MEDIUM;
if (battle_config.character_size && (pc_isridingpeco(sd) || pc_isridingdragon(sd))) { //[Lupus]
- if (sd->class_&JOBL_BABY) {
+ if ((sd->job & JOBL_BABY) != 0) {
if (battle_config.character_size&SZ_BIG)
bstatus->size++;
} else {
@@ -2416,7 +2416,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
}
bstatus->aspd_rate = 1000;
bstatus->ele_lv = 1;
- bstatus->race = ((sd->class_&MAPID_BASEMASK) == MAPID_SUMMONER)?RC_BRUTE:RC_PLAYER;
+ bstatus->race = ((sd->job & MAPID_BASEMASK) == MAPID_SUMMONER)?RC_BRUTE:RC_PLAYER;
// Autobonus
pc->delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true);
@@ -2701,7 +2701,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
}
// If a Super Novice has never died and is at least joblv 70, he gets all stats +10
- if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->die_counter == 0 && sd->status.job_level >= 70) {
+ if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->die_counter == 0 && sd->status.job_level >= 70) {
bstatus->str += 10;
bstatus->agi += 10;
bstatus->vit += 10;
@@ -2820,7 +2820,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
bstatus->hp = bstatus->max_hp;
bstatus->sp = bstatus->max_sp;
} else {
- if((sd->class_&MAPID_BASEMASK) == MAPID_NOVICE && !(sd->class_&JOBL_2)
+ if ((sd->job & MAPID_BASEMASK) == MAPID_NOVICE && (sd->job & JOBL_2) == 0
&& battle_config.restart_hp_rate < 50)
bstatus->hp = bstatus->max_hp>>1;
else
@@ -2911,7 +2911,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
// Absolute modifiers from passive skills
if((skill_lv=pc->checkskill(sd,TF_MISS))>0)
- bstatus->flee += skill_lv*(sd->class_&JOBL_2 && (sd->class_&MAPID_BASEMASK) == MAPID_THIEF? 4 : 3);
+ bstatus->flee += skill_lv*((sd->job & JOBL_2) != 0 && (sd->job & MAPID_BASEMASK) == MAPID_THIEF? 4 : 3);
if((skill_lv=pc->checkskill(sd,MO_DODGE))>0)
bstatus->flee += (skill_lv*3)>>1;
if (pc->checkskill(sd, SU_POWEROFLIFE) > 0)
@@ -2958,7 +2958,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
// Basic ASPD value
i = status->base_amotion_pc(sd,bstatus);
- bstatus->amotion = cap_value(i,((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd),2000);
+ bstatus->amotion = cap_value(i,((sd->job & JOBL_THIRD) != 0 ? battle_config.max_third_aspd : battle_config.max_aspd),2000);
// Relative modifiers from passive skills
#ifndef RENEWAL_ASPD
@@ -3562,7 +3562,7 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
|| sc->data[SC_OBLIVIONCURSE] != NULL
|| sc->data[SC_MAXIMIZEPOWER] != NULL
|| sc->data[SC_REBOUND] != NULL
- || (bl->type == BL_PC && (BL_UCAST(BL_PC, bl)->class_&MAPID_UPPERMASK) == MAPID_MONK
+ || (bl->type == BL_PC && (BL_UCAST(BL_PC, bl)->job & MAPID_UPPERMASK) == MAPID_MONK
&& (sc->data[SC_EXTREMITYFIST] != NULL
|| (sc->data[SC_EXPLOSIONSPIRITS] != NULL
&& (sc->data[SC_SOULLINK] == NULL || sc->data[SC_SOULLINK]->val2 != SL_MONK)
@@ -4008,7 +4008,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
#endif
amotion = status->calc_fix_aspd(bl, sc, amotion);
if (sd != NULL) {
- st->amotion = cap_value(amotion, ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd), 2000);
+ st->amotion = cap_value(amotion, ((sd->job & JOBL_THIRD) != 0 ? battle_config.max_third_aspd : battle_config.max_aspd), 2000);
} else {
st->amotion = cap_value(amotion, battle_config.max_aspd, 2000);
}
@@ -5801,7 +5801,7 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc
val = max( val, 2 * sc->data[SC_WINDWALK]->val1 );
if( sc->data[SC_CARTBOOST] )
val = max( val, 20 );
- if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN && pc->checkskill(sd,TF_MISS) > 0 )
+ if (sd != NULL && (sd->job & MAPID_UPPERMASK) == MAPID_ASSASSIN && pc->checkskill(sd,TF_MISS) > 0)
val = max( val, 1 * pc->checkskill(sd,TF_MISS) );
if( sc->data[SC_CLOAKING] && (sc->data[SC_CLOAKING]->val4&1) == 1 )
val = max( val, sc->data[SC_CLOAKING]->val1 >= 10 ? 25 : 3 * sc->data[SC_CLOAKING]->val1 - 3 );
@@ -8401,7 +8401,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
#endif
break;
case SC_NJ_SUITON:
- if (!val2 || (sd && (sd->class_&MAPID_BASEMASK) == MAPID_NINJA)) {
+ if (val2 == 0 || (sd != NULL && (sd->job & MAPID_BASEMASK) == MAPID_NINJA)) {
//No penalties.
val2 = 0; //Agi penalty
val3 = 0; //Walk speed penalty
@@ -9830,7 +9830,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_ARCLOUSEDASH:
val2 = 15 + 5 * val1; // AGI
val3 = 25; // Move speed increase
- if (sd && (sd->class_&MAPID_BASEMASK) == MAPID_SUMMONER)
+ if (sd != NULL && (sd->job & MAPID_BASEMASK) == MAPID_SUMMONER)
val4 = 10; // Ranged ATK increase
break;
case SC_TUNAPARTY:
@@ -12800,7 +12800,7 @@ int status_natural_heal(struct block_list* bl, va_list args)
if ((rate = pc->checkskill(sd,TK_SPTIME)))
sc_start(bl,bl,status->skill2sc(TK_SPTIME),
100,rate,skill->get_time(TK_SPTIME, rate));
- if ((sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR
+ if ((sd->job & MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR
&&rnd()%10000 < battle_config.sg_angel_skill_ratio
) {
//Angel of the Sun/Moon/Star