From cfa4ae95efca5557d085c56815259f47e6f380fb Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 30 Nov 2016 02:58:47 +0100 Subject: Clarify some Job Class vs MapID confusion (1/2) This commit ensures that `sd->status.class` and related variables only contain Job Classes (i.e. the client-compatible values, where High Novice 4001) and are never checked against the bitmask-based MapID values. As a rule of thumb, from now on, when a variable is named `class`, it is intended to contain a Job Class ID and not a MapID. The type of such variable shall be a signed `int16` or `int`. To ensure that related third party code is also verified when this commit is merged, the variable `struct mmo_charstatus::class_ (i.e. `sd->status.class_`) is renamed to `class`. Some issues in related lines are also fixed, including: - A wrong check in the char server would prevent the correct detection of babies in code related to the family exp sharing. - Baby Arch Bishops would not be affected by Eucharistica. - A wrong check would cause the `questinfo()` script command not to display its information for most classes (except 1-1 classes). - Map IDs and Job Classes were mixed up in `itemdb_jobid2mapid()` and `itemdb_jobmask2mapid()` for 1-1 classes (causing currently no harm, since they just happen to coincide). - The Baby Sura class would not cause parties to be marked as containing a monk type character (for SLS Team Up purposes). - Baby Geneticists would bypass the cart check when trying to equip ammunitions. - Baby Mechanics would bypass the Mado Gear check when trying to equip ammunitions. - Transcendent Shadow Chasers would lose the Stalkers' ability to clone transcendent skills. Signed-off-by: Haru --- src/map/status.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/map/status.c') diff --git a/src/map/status.c b/src/map/status.c index 729b10f52..6f8c7a9e8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2269,7 +2269,7 @@ unsigned int status_get_base_maxsp(const struct map_session_data *sd, const stru nullpo_ret(sd); nullpo_ret(st); - val = pc->class2idx(sd->status.class_); + val = pc->class2idx(sd->status.class); val = status->dbs->SP_table[val][sd->status.base_level]; if ( sd->class_&JOBL_UPPER ) @@ -2290,7 +2290,7 @@ unsigned int status_get_base_maxhp(const struct map_session_data *sd, const stru nullpo_ret(sd); nullpo_ret(st); - val = pc->class2idx(sd->status.class_); + 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 ) @@ -2342,7 +2342,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) pc->calc_skilltree(sd); // SkillTree calculation - sd->max_weight = status->dbs->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300; + sd->max_weight = status->dbs->max_weight_base[pc->class2idx(sd->status.class)]+sd->status.str*300; if(opt&SCO_FIRST) { //Load Hp/SP from char-received data. @@ -2686,7 +2686,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) // ----- STATS CALCULATION ----- // Job bonuses - index = pc->class2idx(sd->status.class_); + index = pc->class2idx(sd->status.class); for (i = 0; i < sd->status.job_level && i < MAX_LEVEL; i++) { if(!status->dbs->job_bonus[index][i]) continue; @@ -4287,11 +4287,11 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) nullpo_ret(sd); nullpo_ret(st); - amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1]; + amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1]; if ( sd->status.weapon > MAX_SINGLE_WEAPON_TYPE) - amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] / 4; + amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2] / 4; if ( sd->status.shield ) - amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][MAX_SINGLE_WEAPON_TYPE]; + amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][MAX_SINGLE_WEAPON_TYPE]; switch ( sd->status.weapon ) { case W_BOW: case W_MUSICAL: @@ -4315,8 +4315,8 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) #else // base weapon delay amotion = (sd->status.weapon < MAX_SINGLE_WEAPON_TYPE) - ? (status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon - : (status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 7 / 10; // dual-wield + ? (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->status.weapon]) // single weapon + : (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1] + status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2]) * 7 / 10; // dual-wield // percentual delay reduction from stats amotion -= amotion * (4 * st->agi + st->dex) / 1000; @@ -6430,7 +6430,7 @@ int status_get_class(const struct block_list *bl) { nullpo_ret(bl); switch (bl->type) { - case BL_PC: return BL_UCCAST(BL_PC, bl)->status.class_; + case BL_PC: return BL_UCCAST(BL_PC, bl)->status.class; case BL_MOB: return BL_UCCAST(BL_MOB, bl)->vd->class_; //Class used on all code should be the view class of the mob. case BL_PET: return BL_UCCAST(BL_PET, bl)->pet.class_; case BL_HOM: return BL_UCCAST(BL_HOM, bl)->homunculus.class_; @@ -13070,15 +13070,15 @@ void status_read_job_db(void) /* [malufett/Hercules] */ return; while ( (jdb = libconfig->setting_get_elem(job_db_conf.root, i++)) ) { - int class_, idx; + int class, idx; const char *name = config_setting_name(jdb); - if ( (class_ = pc->check_job_name(name)) == -1 ) { + if ((class = pc->check_job_name(name)) == -1) { ShowWarning("pc_read_job_db: '%s' unknown job name!\n", name); continue; } - idx = pc->class2idx(class_); + idx = pc->class2idx(class); status->read_job_db_sub(idx, name, jdb); } ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename); @@ -13087,17 +13087,16 @@ void status_read_job_db(void) /* [malufett/Hercules] */ bool status_readdb_job2(char* fields[], int columns, int current) { - int idx, class_, i; + int idx, class, i; nullpo_retr(false, fields); - class_ = atoi(fields[0]); + class = atoi(fields[0]); - if(!pc->db_checkid(class_)) - { - ShowWarning("status_readdb_job2: Invalid job class %d specified.\n", class_); + if (!pc->db_checkid(class)) { + ShowWarning("status_readdb_job2: Invalid job class %d specified.\n", class); return false; } - idx = pc->class2idx(class_); + idx = pc->class2idx(class); for(i = 1; i < columns; i++) { -- cgit v1.2.3-70-g09d2 From 76801cdf48a979728034cb81b81c989f7f655f5a Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 2 Dec 2016 16:00:08 +0100 Subject: 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 --- src/map/atcommand.c | 8 +- src/map/battle.c | 12 +-- src/map/battleground.c | 2 +- src/map/chrif.c | 18 ++-- src/map/clif.c | 6 +- src/map/party.c | 7 +- src/map/pc.c | 279 +++++++++++++++++++++++++++---------------------- src/map/pc.h | 18 ++-- src/map/script.c | 12 +-- src/map/skill.c | 62 ++++++----- src/map/status.c | 42 ++++---- 11 files changed, 251 insertions(+), 215 deletions(-) (limited to 'src/map/status.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0da3b7729..bd4fa7204 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3975,7 +3975,7 @@ ACMD(mount_peco) return false; } - if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { + if ((sd->job & MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { if (!pc->checkskill(sd,RK_DRAGONTRAINING)) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(RK_DRAGONTRAINING)); // You need %s to mount! clif->message(fd, atcmd_output); @@ -3990,7 +3990,7 @@ ACMD(mount_peco) } return true; } - if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) { + if ((sd->job & MAPID_THIRDMASK) == MAPID_RANGER) { if (!pc->checkskill(sd,RA_WUGRIDER)) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(RA_WUGRIDER)); // You need %s to mount! clif->message(fd, atcmd_output); @@ -4005,7 +4005,7 @@ ACMD(mount_peco) } return true; } - if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) { + if ((sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) { if (!pc_ismadogear(sd)) { clif->message(sd->fd,msg_fd(fd,1123)); // You have mounted your Mado Gear. pc->setmadogear(sd, true); @@ -4015,7 +4015,7 @@ ACMD(mount_peco) } return true; } - if (sd->class_&MAPID_SWORDMAN && sd->class_&JOBL_2) { + if ((sd->job & MAPID_BASEMASK) == MAPID_SWORDMAN && (sd->job & JOBL_2) != 0) { if (!pc_isridingpeco(sd)) { // if actually no peco if (!pc->checkskill(sd, KN_RIDING)) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(KN_RIDING)); // You need %s to mount! diff --git a/src/map/battle.c b/src/map/battle.c index 812d588aa..bb20b94ff 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -892,7 +892,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, damage += damage * ratio / 100; } - if ((sd->class_ & MAPID_THIRDMASK) == MAPID_ARCH_BISHOP) { + if ((sd->job & MAPID_THIRDMASK) == MAPID_ARCH_BISHOP) { if((skill2_lv = pc->checkskill(sd,AB_EUCHARISTICA)) > 0 && (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) ) damage += damage * skill2_lv / 100; @@ -3760,7 +3760,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list //Constant/misc additions from skills if (skill_id == WZ_FIREPILLAR) MATK_ADD(100+50*skill_lv); - if (sd != NULL && (sd->class_ & MAPID_THIRDMASK) == MAPID_ARCH_BISHOP) { + if (sd != NULL && (sd->job & MAPID_THIRDMASK) == MAPID_ARCH_BISHOP) { int eucharistica_level = pc->checkskill(sd,AB_EUCHARISTICA); if (eucharistica_level > 0 && (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK)) MATK_ADDRATE(eucharistica_level); @@ -5566,13 +5566,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list //Dual-wield if (wd.damage) { temp = pc->checkskill(sd,AS_RIGHT) * 10; - if( (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO ) + if ((sd->job & MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) temp = pc->checkskill(sd,KO_RIGHT) * 10 + 20; ATK_RATER( 50 + temp ); } if (wd.damage2) { temp = pc->checkskill(sd,AS_LEFT) * 10; - if( (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO ) + if ((sd->job & MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) temp = pc->checkskill(sd,KO_LEFT) * 10 + 20; ATK_RATEL( 30 + temp ); } @@ -6842,8 +6842,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f const struct map_session_data *s_sd = BL_UCCAST(BL_PC, s_bl); const struct map_session_data *t_sd = BL_UCCAST(BL_PC, t_bl); if ( - (s_sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || - (t_sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || + (s_sd->job & MAPID_UPPERMASK) == MAPID_NOVICE || + (t_sd->job & MAPID_UPPERMASK) == MAPID_NOVICE || s_sd->status.base_level < battle_config.pk_min_level || t_sd->status.base_level < battle_config.pk_min_level || (battle_config.pk_level_range && abs(s_sd->status.base_level - t_sd->status.base_level) > battle_config.pk_level_range) diff --git a/src/map/battleground.c b/src/map/battleground.c index 4bb2b9b2e..cd7178951 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -822,7 +822,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->min_level ) return BGQA_FAIL_LEVEL_INCORRECT; - if ( !(sd->class_&JOBL_2) ) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */ + if ((sd->job & JOBL_2) == 0) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */ return BGQA_FAIL_CLASS_INVALID; tsec = (unsigned int)time(NULL); diff --git a/src/map/chrif.c b/src/map/chrif.c index 6e567a402..e298a7fbc 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1065,12 +1065,18 @@ int chrif_updatefamelist(struct map_session_data* sd) { nullpo_retr(0, sd); chrif_check(-1); - switch(sd->class_ & MAPID_UPPERMASK) { - case MAPID_BLACKSMITH: type = RANKTYPE_BLACKSMITH; break; - case MAPID_ALCHEMIST: type = RANKTYPE_ALCHEMIST; break; - case MAPID_TAEKWON: type = RANKTYPE_TAEKWON; break; - default: - return 0; + switch (sd->job & MAPID_UPPERMASK) { + case MAPID_BLACKSMITH: + type = RANKTYPE_BLACKSMITH; + break; + case MAPID_ALCHEMIST: + type = RANKTYPE_ALCHEMIST; + break; + case MAPID_TAEKWON: + type = RANKTYPE_TAEKWON; + break; + default: + return 0; } WFIFOHEAD(chrif->fd, 11); diff --git a/src/map/clif.c b/src/map/clif.c index f29a1357e..0b8f6c2ee 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13824,7 +13824,7 @@ void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) { if (sd->state.doridori) return; - switch (sd->class_&MAPID_UPPERMASK) { + switch (sd->job & MAPID_UPPERMASK) { case MAPID_SOUL_LINKER: case MAPID_STAR_GLADIATOR: case MAPID_TAEKWON: @@ -13852,7 +13852,7 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) /* game client is currently broken on this (not sure the packetver range) */ /* it sends the request when the criteria doesn't match (and of course we let it fail) */ /* so restoring the old parse_globalmes method. */ - if( ( sd->class_&MAPID_UPPERMASK ) == MAPID_SUPER_NOVICE ) { + if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { unsigned int next = pc->nextbaseexp(sd); if( next == 0 ) next = pc->thisbaseexp(sd); if( next ) { @@ -14226,7 +14226,7 @@ void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) nullpo_retv(sd); fd = sd->fd; - upperMask = sd->class_&MAPID_UPPERMASK; + upperMask = sd->job & MAPID_UPPERMASK; WFIFOHEAD(fd, len); WFIFOW(fd, 0) = 0x97d; WFIFOW(fd, 2) = type; diff --git a/src/map/party.c b/src/map/party.c index 6489242fe..3bf9542c7 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -881,15 +881,14 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id continue; switch(skill_id) { case TK_COUNTER: //Increase Triple Attack rate of Monks. - if((p_sd->class_&MAPID_UPPERMASK) == MAPID_MONK - && pc->checkskill(p_sd,MO_TRIPLEATTACK)) { + if ((p_sd->job & MAPID_UPPERMASK) == MAPID_MONK && pc->checkskill(p_sd, MO_TRIPLEATTACK)) { sc_start4(&p_sd->bl,&p_sd->bl,SC_SKILLRATE_UP,100,MO_TRIPLEATTACK, 50+50*skill_lv, //+100/150/200% rate 0,0,skill->get_time(SG_FRIEND, 1)); } break; case MO_COMBOFINISH: //Increase Counter rate of Star Gladiators - if((p_sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR + if ((p_sd->job & MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && sd->sc.data[SC_COUNTERKICK_READY] && pc->checkskill(p_sd,SG_FRIEND)) { sc_start4(&p_sd->bl,&p_sd->bl,SC_SKILLRATE_UP,100,TK_COUNTER, @@ -1160,7 +1159,7 @@ int party_sub_count_chorus(struct block_list *bl, va_list ap) if (battle_config.idle_no_share && pc_isidle(sd)) return 0; - if ( (sd->class_&MAPID_THIRDMASK) != MAPID_MINSTRELWANDERER ) + if ((sd->job & MAPID_THIRDMASK) != MAPID_MINSTRELWANDERER) return 0; return 1; diff --git a/src/map/pc.c b/src/map/pc.c index 6f260f776..11bc511b1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -248,7 +248,7 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) memmove(sd->spirit_timer+i+1, sd->spirit_timer+i, (sd->spiritball-i)*sizeof(int)); sd->spirit_timer[i] = tid; sd->spiritball++; - if( (sd->class_&MAPID_THIRDMASK) == MAPID_ROYAL_GUARD ) + if ((sd->job & MAPID_THIRDMASK) == MAPID_ROYAL_GUARD) clif->millenniumshield(&sd->bl,sd->spiritball); else clif->spiritball(&sd->bl); @@ -287,7 +287,7 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type) } if(!type) { - if( (sd->class_&MAPID_THIRDMASK) == MAPID_ROYAL_GUARD ) + if ((sd->job & MAPID_THIRDMASK) == MAPID_ROYAL_GUARD) clif->millenniumshield(&sd->bl,sd->spiritball); else clif->spiritball(&sd->bl); @@ -395,39 +395,48 @@ void pc_addfame(struct map_session_data *sd,int count) sd->status.fame += count; if(sd->status.fame > MAX_FAME) sd->status.fame = MAX_FAME; - switch(sd->class_&MAPID_UPPERMASK){ - case MAPID_BLACKSMITH: ranktype = RANKTYPE_BLACKSMITH; break; - case MAPID_ALCHEMIST: ranktype = RANKTYPE_ALCHEMIST; break; - case MAPID_TAEKWON: ranktype = RANKTYPE_TAEKWON; break; + + switch (sd->job & MAPID_UPPERMASK) { + case MAPID_BLACKSMITH: + ranktype = RANKTYPE_BLACKSMITH; + break; + case MAPID_ALCHEMIST: + ranktype = RANKTYPE_ALCHEMIST; + break; + case MAPID_TAEKWON: + ranktype = RANKTYPE_TAEKWON; + break; } + Assert_retv(ranktype != -1); + clif->update_rankingpoint(sd, ranktype, count); chrif->updatefamelist(sd); } // Check whether a player ID is in the fame rankers' list of its job, returns his/her position if so, 0 else -unsigned char pc_famerank(int char_id, int job) +int pc_famerank(int char_id, uint32 job) { int i; - switch(job){ - case MAPID_BLACKSMITH: // Blacksmith - for(i = 0; i < MAX_FAME_LIST; i++){ - if(pc->smith_fame_list[i].id == char_id) - return i + 1; - } - break; - case MAPID_ALCHEMIST: // Alchemist - for(i = 0; i < MAX_FAME_LIST; i++){ - if(pc->chemist_fame_list[i].id == char_id) - return i + 1; - } - break; - case MAPID_TAEKWON: // Taekwon - for(i = 0; i < MAX_FAME_LIST; i++){ - if(pc->taekwon_fame_list[i].id == char_id) - return i + 1; - } - break; + switch (job & MAPID_UPPERMASK) { + case MAPID_BLACKSMITH: // Blacksmith + for (i = 0; i < MAX_FAME_LIST; i++) { + if (pc->smith_fame_list[i].id == char_id) + return i + 1; + } + break; + case MAPID_ALCHEMIST: // Alchemist + for (i = 0; i < MAX_FAME_LIST; i++) { + if (pc->chemist_fame_list[i].id == char_id) + return i + 1; + } + break; + case MAPID_TAEKWON: // Taekwon + for (i = 0; i < MAX_FAME_LIST; i++) { + if (pc->taekwon_fame_list[i].id == char_id) + return i + 1; + } + break; } return 0; @@ -712,8 +721,8 @@ int pc_equippoint(struct map_session_data *sd,int n) || sd->inventory_data[n]->look == W_1HAXE ) { if (pc->checkskill(sd,AS_LEFT) > 0 - || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN - || (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO + || (sd->job & MAPID_UPPERMASK) == MAPID_ASSASSIN + || (sd->job & MAPID_UPPERMASK) == MAPID_KAGEROUOBORO ) { //Kagerou and Oboro can dual wield daggers. [Rytech] if( ep == EQP_HAND_R ) @@ -973,11 +982,11 @@ int pc_isequip(struct map_session_data *sd,int n) return 0; if ( item->equip & EQP_AMMO ) { - if (sd->state.active && !pc_iscarton(sd) && (sd->class_ & MAPID_THIRDMASK) == MAPID_GENETIC) { // check if sc data is already loaded. + if (sd->state.active && !pc_iscarton(sd) && (sd->job & MAPID_THIRDMASK) == MAPID_GENETIC) { // check if sc data is already loaded. clif->msgtable(sd, MSG_ITEM_NEED_CART); return 0; } - if (!pc_ismadogear(sd) && (sd->class_ & MAPID_THIRDMASK) == MAPID_MECHANIC) { + if (!pc_ismadogear(sd) && (sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) { clif->msgtable(sd, MSG_ITEM_NEED_MADO); return 0; } @@ -1014,14 +1023,26 @@ int pc_isequip(struct map_session_data *sd,int n) } } //Not equipable by class. [Skotlex] - if (!(1ULL<<(sd->class_&MAPID_BASEMASK)&item->class_base[(sd->class_&JOBL_2_1)?1:((sd->class_&JOBL_2_2)?2:0)])) + if (((1ULL<<(sd->job & MAPID_BASEMASK)) & item->class_base[(sd->job & JOBL_2_1) != 0 ? 1 : ((sd->job & JOBL_2_2) != 0 ? 2 : 0)]) == 0) return 0; //Not usable by upper class. [Inkfish] while( 1 ) { - if( item->class_upper&ITEMUPPER_NORMAL && !(sd->class_&(JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) ) break; - if( item->class_upper&ITEMUPPER_UPPER && sd->class_&(JOBL_UPPER|JOBL_THIRD) ) break; - if( item->class_upper&ITEMUPPER_BABY && sd->class_&JOBL_BABY ) break; - if( item->class_upper&ITEMUPPER_THIRD && sd->class_&JOBL_THIRD ) break; + if ((item->class_upper & ITEMUPPER_NORMAL) != 0) { + if ((sd->job & (JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) == 0) + break; + } + if ((item->class_upper & ITEMUPPER_UPPER) != 0) { + if ((sd->job & (JOBL_UPPER|JOBL_THIRD)) != 0) + break; + } + if ((item->class_upper & ITEMUPPER_BABY) != 0) { + if ((sd->job & JOBL_BABY) != 0) + break; + } + if ((item->class_upper & ITEMUPPER_THIRD) != 0) { + if ((sd->job & JOBL_THIRD) != 0) + break; + } return 0; } @@ -1080,9 +1101,9 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if (job == -1) { ShowError("pc_authok: Invalid class %d for player %s (%d:%d). Class was changed to novice.\n", sd->status.class, sd->status.name, sd->status.account_id, sd->status.char_id); sd->status.class = JOB_NOVICE; - sd->class_ = MAPID_NOVICE; + sd->job = MAPID_NOVICE; } else { - sd->class_ = job; + sd->job = job; } } @@ -1341,7 +1362,7 @@ int pc_reg_received(struct map_session_data *sd) // Cooking Exp sd->cook_mastery = pc_readglobalreg(sd,script->add_str("COOK_MASTERY")); - if( (sd->class_&MAPID_BASEMASK) == MAPID_TAEKWON ) { + if ((sd->job & MAPID_BASEMASK) == MAPID_TAEKWON) { // Better check for class rather than skill to prevent "skill resets" from unsetting this sd->mission_mobid = pc_readglobalreg(sd,script->add_str("TK_MISSION_ID")); sd->mission_count = pc_readglobalreg(sd,script->add_str("TK_MISSION_COUNT")); @@ -1470,17 +1491,17 @@ int pc_calc_skillpoint(struct map_session_data* sd) { int pc_calc_skilltree(struct map_session_data *sd) { int i,id=0,flag; - int c=0; + int class = 0, classidx = 0; nullpo_ret(sd); i = pc->calc_skilltree_normalize_job(sd); - c = pc->mapid2jobid(i, sd->status.sex); - if( c == -1 ) - { //Unable to normalize job?? + class = pc->mapid2jobid(i, sd->status.sex); + if (class == -1) { + //Unable to normalize job?? ShowError("pc_calc_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id); return 1; } - c = pc->class2idx(c); + classidx = pc->class2idx(class); for( i = 0; i < MAX_SKILL; i++ ) { if( sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED ) //Don't touch these @@ -1489,10 +1510,10 @@ int pc_calc_skilltree(struct map_session_data *sd) if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT ) { switch( skill->dbs->db[i].nameid ) { case NV_TRICKDEAD: - if( (sd->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE ) { - sd->status.skill[i].id = 0; - sd->status.skill[i].lv = 0; - sd->status.skill[i].flag = 0; + if ((sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) { + sd->status.skill[i].id = 0; + sd->status.skill[i].lv = 0; + sd->status.skill[i].flag = 0; } break; } @@ -1562,16 +1583,16 @@ int pc_calc_skilltree(struct map_session_data *sd) do { flag = 0; - for (i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[c][i].id) > 0; i++) { - int idx = pc->skill_tree[c][i].idx; + for (i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[classidx][i].id) > 0; i++) { + int idx = pc->skill_tree[classidx][i].idx; bool satisfied = true; if (sd->status.skill[idx].id > 0) continue; //Skill already known. if (!battle_config.skillfree) { int j; - for (j = 0; j < VECTOR_LENGTH(pc->skill_tree[c][i].need); j++) { - struct skill_tree_requirement *req = &VECTOR_INDEX(pc->skill_tree[c][i].need, j); + for (j = 0; j < VECTOR_LENGTH(pc->skill_tree[classidx][i].need); j++) { + struct skill_tree_requirement *req = &VECTOR_INDEX(pc->skill_tree[classidx][i].need, j); int level; if (sd->status.skill[req->idx].id == 0 || sd->status.skill[req->idx].flag == SKILL_FLAG_TEMPORARY @@ -1586,8 +1607,8 @@ int pc_calc_skilltree(struct map_session_data *sd) break; } } - if (sd->status.job_level < (int)pc->skill_tree[c][i].joblv) { - int jobid = pc->mapid2jobid(sd->class_, sd->status.sex); // need to get its own skilltree + if (sd->status.job_level < (int)pc->skill_tree[classidx][i].joblv) { + int jobid = pc->mapid2jobid(sd->job, sd->status.sex); // need to get its own skilltree if (jobid > -1) { if (!pc->skill_tree[pc->class2idx(jobid)][i].inherited) satisfied = false; // job level requirement wasn't satisfied @@ -1618,16 +1639,15 @@ int pc_calc_skilltree(struct map_session_data *sd) } while(flag); // - if( c > 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) - { + if (classidx > 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc->famerank(sd->status.char_id, MAPID_TAEKWON)) { /* Taekwon Ranger Bonus Skill Tree ============================================ - Grant All Taekwon Tree, but only as Bonus Skills in case they drop from ranking. - (c > 0) to avoid grant Novice Skill Tree in case of Skill Reset (need more logic) - (sd->status.skill_point == 0) to wait until all skill points are asigned to avoid problems with Job Change quest. */ - for( i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[c][i].id) > 0; i++ ) { - int idx = pc->skill_tree[c][i].idx; + for (i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[classidx][i].id) > 0; i++) { + int idx = pc->skill_tree[classidx][i].idx; if( (skill->dbs->db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) ) continue; //Do not include Quest/Wedding skills. @@ -1691,7 +1711,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id) continue; if (sd->status.job_level < (int)pc->skill_tree[c][i].joblv) { - int jobid = pc->mapid2jobid(sd->class_, sd->status.sex); // need to get its own skilltree + int jobid = pc->mapid2jobid(sd->job, sd->status.sex); // need to get its own skilltree if (jobid > -1) { if (!pc->skill_tree[pc->class2idx(jobid)][i].inherited) continue; @@ -1738,12 +1758,12 @@ int pc_clean_skilltree(struct map_session_data *sd) int pc_calc_skilltree_normalize_job(struct map_session_data *sd) { int skill_point, novice_skills; - int c; + uint16 job; nullpo_ret(sd); - c = sd->class_; + job = sd->job; if (!battle_config.skillup_limit || pc_has_permission(sd, PC_PERM_ALL_SKILL)) - return c; + return job; skill_point = pc->calc_skillpoint(sd); @@ -1751,19 +1771,17 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) sd->sktree.second = sd->sktree.third = 0; - // limit 1st class and above to novice job levels - if(skill_point < novice_skills && (sd->class_&MAPID_BASEMASK) != MAPID_SUMMONER) { - c = MAPID_NOVICE; - } - // limit 2nd class and above to first class job levels (super novices are exempt) - else if ((sd->class_&JOBL_2) && (sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) - { + if (skill_point < novice_skills && (sd->job & MAPID_BASEMASK) != MAPID_SUMMONER) { + // limit 1st class and above to novice job levels + job = MAPID_NOVICE; + } else if ((sd->job & JOBL_2) != 0 && (sd->job & MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { + // limit 2nd class and above to first class job levels (super novices are exempt) // regenerate change_level_2nd if (sd->change_level_2nd == 0) { - if (sd->class_&JOBL_THIRD) { + if ((sd->job & JOBL_THIRD) != 0) { // if neither 2nd nor 3rd jobchange levels are known, we have to assume a default for 2nd if (sd->change_level_3rd == 0) { - sd->change_level_2nd = pc->max_level[pc->class2idx(pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1]; + sd->change_level_2nd = pc->max_level[pc->class2idx(pc->mapid2jobid(sd->job & MAPID_UPPERMASK, sd->status.sex))][1]; } else { sd->change_level_2nd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) @@ -1781,9 +1799,9 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) } if (skill_point < novice_skills + (sd->change_level_2nd - 1)) { - c &= MAPID_BASEMASK; + job &= MAPID_BASEMASK; sd->sktree.second = ( novice_skills + (sd->change_level_2nd - 1) ) - skill_point; - } else if(sd->class_&JOBL_THIRD) { // limit 3rd class to 2nd class/trans job levels + } else if ((sd->job & JOBL_THIRD) != 0) { // limit 3rd class to 2nd class/trans job levels // regenerate change_level_3rd if (sd->change_level_3rd == 0) { sd->change_level_3rd = 1 + skill_point + sd->status.skill_point @@ -1794,16 +1812,16 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) } if (skill_point < novice_skills + (sd->change_level_2nd - 1) + (sd->change_level_3rd - 1)) { - c &= MAPID_UPPERMASK; + job &= MAPID_UPPERMASK; sd->sktree.third = (novice_skills + (sd->change_level_2nd - 1) + (sd->change_level_3rd - 1)) - skill_point; } } } // restore non-limiting flags - c |= sd->class_&(JOBL_UPPER|JOBL_BABY); + job |= sd->job & (JOBL_UPPER|JOBL_BABY); - return c; + return job; } /*========================================== @@ -4857,12 +4875,12 @@ int pc_isUseitem(struct map_session_data *sd,int n) /** * Only Rune Knights may use runes **/ - if( itemdb_is_rune(nameid) && (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT ) + if (itemdb_is_rune(nameid) && (sd->job & MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT) return 0; /** * Only GCross may use poisons **/ - else if( itemdb_is_poison(nameid) && (sd->class_&MAPID_THIRDMASK) != MAPID_GUILLOTINE_CROSS ) + else if (itemdb_is_poison(nameid) && (sd->job & MAPID_THIRDMASK) != MAPID_GUILLOTINE_CROSS) return 0; if( item->package || item->group ) { @@ -4891,31 +4909,47 @@ int pc_isUseitem(struct map_session_data *sd,int n) } //Not equipable by class. [Skotlex] - if (!( - (1ULL<<(sd->class_&MAPID_BASEMASK)) & - (item->class_base[(sd->class_&JOBL_2_1) ? 1 : ((sd->class_&JOBL_2_2) ? 2 : 0)]) - )) + if (((1ULL << (sd->job & MAPID_BASEMASK)) & (item->class_base[(sd->job & JOBL_2_1) ? 1 : ((sd->job & JOBL_2_2) ? 2 : 0)])) == 0) return 0; //Not usable by upper class. [Haru] while( 1 ) { // Normal classes (no upper, no baby, no third classes) - if( item->class_upper&ITEMUPPER_NORMAL && !(sd->class_&(JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) ) break; + if ((item->class_upper & ITEMUPPER_NORMAL) != 0) { + if ((sd->job & (JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) == 0) + break; + } + if ((item->class_upper & ITEMUPPER_UPPER) != 0) { #ifdef RENEWAL - // Upper classes (no third classes) - if( item->class_upper&ITEMUPPER_UPPER && sd->class_&JOBL_UPPER && !(sd->class_&JOBL_THIRD) ) break; + // Upper classes (no third classes) + if ((sd->job & JOBL_UPPER) != 0 && (sd->job&JOBL_THIRD) == 0) + break; #else - //pre-re has no use for the extra, so we maintain the previous for backwards compatibility - if( item->class_upper&ITEMUPPER_UPPER && sd->class_&(JOBL_UPPER|JOBL_THIRD) ) break; + //pre-re has no use for the extra, so we maintain the previous for backwards compatibility + if ((sd->job & (JOBL_UPPER|JOBL_THIRD)) != 0) + break; #endif + } // Baby classes (no third classes) - if( item->class_upper&ITEMUPPER_BABY && sd->class_&JOBL_BABY && !(sd->class_&JOBL_THIRD) ) break; + if ((item->class_upper & ITEMUPPER_BABY) != 0) { + if ((sd->job & JOBL_BABY) != 0 && (sd->job&JOBL_THIRD) == 0) + break; + } // Third classes (no upper, no baby classes) - if( item->class_upper&ITEMUPPER_THIRD && sd->class_&JOBL_THIRD && !(sd->class_&(JOBL_UPPER|JOBL_BABY)) ) break; + if ((item->class_upper & ITEMUPPER_THIRD) != 0) { + if ((sd->job & JOBL_THIRD) != 0 && (sd->job & (JOBL_UPPER|JOBL_BABY)) == 0) + break; + } // Upper third classes - if( item->class_upper&ITEMUPPER_THURDUPPER && sd->class_&JOBL_THIRD && sd->class_&JOBL_UPPER ) break; + if ((item->class_upper & ITEMUPPER_THURDUPPER) != 0) { + if ((sd->job & JOBL_THIRD) != 0 && (sd->job & JOBL_UPPER) != 0) + break; + } // Baby third classes - if( item->class_upper&ITEMUPPER_THIRDBABY && sd->class_&JOBL_THIRD && sd->class_&JOBL_BABY ) break; + if ((item->class_upper & ITEMUPPER_THIRDBABY) != 0) { + if ((sd->job & JOBL_THIRD) != 0 && (sd->job & JOBL_BABY) != 0) + break; + } return 0; } @@ -6010,10 +6044,9 @@ int pc_jobid2mapid(int16 class) } //Reverts the map-style class id to the client-style one. -int pc_mapid2jobid(unsigned short class_, int sex) +int pc_mapid2jobid(uint16 job, int sex) { - switch(class_) - { + switch (job) { //Novice And 1-1 Jobs case MAPID_NOVICE: return JOB_NOVICE; case MAPID_SWORDMAN: return JOB_SWORDMAN; @@ -6609,7 +6642,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) { status_calc_pc(sd,SCO_FORCE); status_percent_heal(&sd->bl,100,100); - if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { + if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { sc_start(NULL,&sd->bl,status->skill2sc(PR_KYRIE),100,1,skill->get_time(PR_KYRIE,1)); sc_start(NULL,&sd->bl,status->skill2sc(PR_IMPOSITIO),100,1,skill->get_time(PR_IMPOSITIO,1)); sc_start(NULL,&sd->bl,status->skill2sc(PR_MAGNIFICAT),100,1,skill->get_time(PR_MAGNIFICAT,1)); @@ -6617,7 +6650,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) { sc_start(NULL,&sd->bl,status->skill2sc(PR_SUFFRAGIUM),100,1,skill->get_time(PR_SUFFRAGIUM,1)); if (sd->state.snovice_dead_flag) sd->state.snovice_dead_flag = 0; //Reenable steelbody resurrection on dead. - } else if( (sd->class_&MAPID_BASEMASK) == MAPID_TAEKWON ) { + } else if ((sd->job & MAPID_BASEMASK) == MAPID_TAEKWON) { sc_start(NULL,&sd->bl,status->skill2sc(AL_INCAGI),100,10,600000); sc_start(NULL,&sd->bl,status->skill2sc(AL_BLESSING),100,10,600000); } @@ -7132,7 +7165,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { sd->status.skill_point--; if( !skill->dbs->db[index].inf ) status_calc_pc(sd,SCO_NONE); // Only recalculate for passive skills. - else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) + else if (sd->status.skill_point == 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON)) pc->calc_skilltree(sd); // Required to grant all TK Ranger skills. else pc->check_skilltree(sd, skill_id); // Check if a new skill can Lvlup @@ -7313,7 +7346,7 @@ int pc_resetstate(struct map_session_data* sd) return 0; } - sd->status.status_point = pc->statp[sd->status.base_level] + ((sd->class_&JOBL_UPPER) ? 52 : 0); // extra 52+48=100 stat points + sd->status.status_point = pc->statp[sd->status.base_level] + ((sd->job & JOBL_UPPER) != 0 ? 52 : 0); // extra 52+48=100 stat points } else { @@ -7371,7 +7404,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) int i, inf2, skill_point=0; nullpo_ret(sd); - if( flag&PCRESETSKILL_CHSEX && (sd->class_&MAPID_UPPERMASK) != MAPID_BARDDANCER ) + if (flag&PCRESETSKILL_CHSEX && (sd->job & MAPID_UPPERMASK) != MAPID_BARDDANCER) return 0; if( !(flag&PCRESETSKILL_RECOUNT) ) { //Remove stuff lost when resetting skills. @@ -7379,7 +7412,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) /** * It has been confirmed on official server that when you reset skills with a ranked tweakwon your skills are not reset (because you have all of them anyway) **/ - 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)) return 0; if( pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd) ) //Remove perma blindness due to skill-reset. [Skotlex] @@ -7395,7 +7428,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) i &= ~OPTION_WUG; if( i&OPTION_WUGRIDER && pc->checkskill(sd, RA_WUGRIDER) ) i &= ~OPTION_WUGRIDER; - if( i&OPTION_MADOGEAR && ( sd->class_&MAPID_THIRDMASK ) == MAPID_MECHANIC ) + if (i&OPTION_MADOGEAR && (sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) i &= ~OPTION_MADOGEAR; #ifndef NEW_CARTS if( i&OPTION_CART && pc->checkskill(sd, MC_PUSHCART) ) @@ -7429,16 +7462,16 @@ int pc_resetskill(struct map_session_data* sd, int flag) skill_id = skill->dbs->db[i].nameid; // Don't reset trick dead if not a novice/baby - if( skill_id == NV_TRICKDEAD && (sd->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE ) { + 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->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE) + if (skill_id == NV_BASIC && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) continue; - if (skill_id == SU_BASIC_SKILL && (sd->class_&MAPID_BASEMASK) != MAPID_SUMMONER) + if (skill_id == SU_BASIC_SKILL && (sd->job & MAPID_BASEMASK) != MAPID_SUMMONER) continue; if( sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED ) @@ -7816,7 +7849,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // activate Steel body if a super novice dies at 99+% exp [celest] - if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && !sd->state.snovice_dead_flag) { + if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && !sd->state.snovice_dead_flag) { unsigned int next = pc->nextbaseexp(sd); if( next == 0 ) next = pc->thisbaseexp(sd); if( get_percentage(sd->status.base_exp,next) >= 99 ) { @@ -7835,7 +7868,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { // changed penalty options, added death by player if pk_mode [Valaris] if( battle_config.death_penalty_type - && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty + && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty && !map->list[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY] ) { @@ -8017,9 +8050,9 @@ int pc_readparam(const struct map_session_data *sd, int type) case SP_BASELEVEL: val = sd->status.base_level; break; case SP_JOBLEVEL: val = sd->status.job_level; break; case SP_CLASS: val = sd->status.class; break; - case SP_BASEJOB: val = pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex); break; //Base job, extracting upper type. - case SP_UPPER: val = (sd->class_&JOBL_UPPER) ? 1 : ((sd->class_&JOBL_BABY) ? 2 : 0); break; - case SP_BASECLASS: val = pc->mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex); break; //Extract base class tree. [Skotlex] + case SP_BASEJOB: val = pc->mapid2jobid(sd->job & MAPID_UPPERMASK, sd->status.sex); break; //Base job, extracting upper type. + case SP_UPPER: val = (sd->job & JOBL_UPPER) != 0 ? 1 : ((sd->job & JOBL_BABY) != 0 ? 2 : 0); break; + case SP_BASECLASS: val = pc->mapid2jobid(sd->job & MAPID_BASEMASK, sd->status.sex); break; //Extract base class tree. [Skotlex] case SP_SEX: val = sd->status.sex; break; case SP_WEIGHT: val = sd->weight; break; case SP_MAXWEIGHT: val = sd->max_weight; break; @@ -8505,14 +8538,14 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) if (class == -1) return 1; - if ((uint16)job == sd->class_) + if ((uint16)job == sd->job) return 1; //Nothing to change. - if ((job & JOBL_2) != 0 && (sd->class_ & JOBL_2) == 0 && (job & MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { + if ((job & JOBL_2) != 0 && (sd->job & JOBL_2) == 0 && (job & MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { // changing from 1st to 2nd job sd->change_level_2nd = sd->status.job_level; pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); - } else if((job & JOBL_THIRD) != 0 && (sd->class_ & JOBL_THIRD) == 0) { + } else if((job & JOBL_THIRD) != 0 && (sd->job & JOBL_THIRD) == 0) { // changing from 2nd to 3rd job sd->change_level_3rd = sd->status.job_level; pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); @@ -8544,7 +8577,7 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) pc_setglobalreg(sd, script->add_str("REPRODUCE_SKILL_LV"),0); } - if ((job & MAPID_UPPERMASK) != (sd->class_ & MAPID_UPPERMASK)) { //Things to remove when changing class tree. + if ((job & MAPID_UPPERMASK) != (sd->job & MAPID_UPPERMASK)) { //Things to remove when changing class tree. const int class_idx = pc->class2idx(sd->status.class); short id; for (i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[class_idx][i].id) > 0; i++) { @@ -8555,14 +8588,14 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) } } - if ((sd->class_ & MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && (job & MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) { + if ((sd->job & MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && (job & MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) { /* going off star glad lineage, reset feel to not store no-longer-used vars in the database */ pc->resetfeel(sd); } sd->status.class = class; - fame_flag = pc->famerank(sd->status.char_id, sd->class_); - sd->class_ = (uint16)job; + fame_flag = pc->famerank(sd->status.char_id, sd->job); + sd->job = (uint16)job; sd->status.job_level=1; sd->status.job_exp=0; @@ -8611,7 +8644,7 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) //Remove peco/cart/falcon i = sd->sc.option; - if( i&OPTION_RIDING && (!pc->checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) ) + if (i&OPTION_RIDING && (!pc->checkskill(sd, KN_RIDING) || (sd->job & MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT)) i&=~OPTION_RIDING; if( i&OPTION_FALCON && !pc->checkskill(sd, HT_FALCON) ) i&=~OPTION_FALCON; @@ -8652,7 +8685,7 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) chrif->buildfamelist(); } else if (sd->status.fame > 0) { //It may be that now they are famous? - switch (sd->class_&MAPID_UPPERMASK) { + switch (sd->job & MAPID_UPPERMASK) { case MAPID_BLACKSMITH: case MAPID_ALCHEMIST: case MAPID_TAEKWON: @@ -8961,7 +8994,7 @@ void pc_setmadogear(struct map_session_data *sd, bool flag) { nullpo_retv(sd); if (flag) { - if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) + if ((sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR); } else if (pc_ismadogear(sd)) { pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR); @@ -9207,7 +9240,7 @@ int pc_setregistry(struct map_session_data *sd, int64 reg, int val) { switch( regname[0] ) { default: //Char reg if( !strcmp(regname,"PC_DIE_COUNTER") && sd->die_counter != val ) { - int i = (!sd->die_counter && (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE); + int i = (!sd->die_counter && (sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE); sd->die_counter = val; if( i ) status_calc_pc(sd,SCO_NONE); // Lost the bonus. @@ -10245,7 +10278,7 @@ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd) { if(sd == NULL || dstsd == NULL || sd->status.partner_id > 0 || dstsd->status.partner_id > 0 || - (sd->class_&JOBL_BABY) || (dstsd->class_&JOBL_BABY)) + (sd->job & JOBL_BABY) != 0 || (dstsd->job & JOBL_BABY) != 0) return -1; sd->status.partner_id = dstsd->status.char_id; dstsd->status.partner_id = sd->status.char_id; @@ -10309,7 +10342,7 @@ struct map_session_data *pc_get_partner(struct map_session_data *sd) { * Get sd father charid. (Need to be baby) *------------------------------------------*/ struct map_session_data *pc_get_father(struct map_session_data *sd) { - if (sd && sd->class_&JOBL_BABY && sd->status.father > 0) + if (sd && (sd->job & JOBL_BABY) != 0 && sd->status.father > 0) // charid2sd returns NULL if not found return map->charid2sd(sd->status.father); @@ -10320,7 +10353,7 @@ struct map_session_data *pc_get_father(struct map_session_data *sd) { * Get sd mother charid. (Need to be baby) *------------------------------------------*/ struct map_session_data *pc_get_mother(struct map_session_data *sd) { - if (sd && sd->class_&JOBL_BABY && sd->status.mother > 0) + if (sd && (sd->job & JOBL_BABY) != 0 && sd->status.mother > 0) // charid2sd returns NULL if not found return map->charid2sd(sd->status.mother); @@ -11742,7 +11775,7 @@ void pc_check_supernovice_call(struct map_session_data *sd, const char *message) nullpo_retv(sd); nullpo_retv(message); - if ((sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) + if ((sd->job & MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) return; if (next == 0) next = pc->thisbaseexp(sd); diff --git a/src/map/pc.h b/src/map/pc.h index c68be7b97..5b0cc4cba 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -235,7 +235,7 @@ struct map_session_data { unsigned int bonus_coma : 1; } special_state; int login_id1, login_id2; - unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] + uint16 job; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] /// Groups & permissions int group_id; @@ -635,13 +635,13 @@ END_ZEROED_BLOCK; #define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle->bc->natural_heal_weight_rate ) #define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 ) #define pc_maxparameter(sd) ( \ - ((sd)->class_&MAPID_BASEMASK) == MAPID_SUMMONER ? battle->bc->max_summoner_parameter : \ - ( ((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO \ - || ((sd)->class_&MAPID_UPPERMASK) == MAPID_REBELLION \ - || ((sd)->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E \ - ) ? battle->bc->max_extended_parameter : ((sd)->class_&JOBL_THIRD) ? \ - (((sd)->class_&JOBL_BABY) ? battle->bc->max_baby_third_parameter : battle->bc->max_third_parameter ) : \ - (((sd)->class_&JOBL_BABY) ? battle->bc->max_baby_parameter : battle->bc->max_parameter) \ + ((sd)->job & MAPID_BASEMASK) == MAPID_SUMMONER ? battle->bc->max_summoner_parameter : \ + ( ((sd)->job & MAPID_UPPERMASK) == MAPID_KAGEROUOBORO \ + || ((sd)->job & MAPID_UPPERMASK) == MAPID_REBELLION \ + || ((sd)->job & MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E \ + ) ? battle->bc->max_extended_parameter : ((sd)->job & JOBL_THIRD) ? \ + (((sd)->job & JOBL_BABY) ? battle->bc->max_baby_third_parameter : battle->bc->max_third_parameter ) : \ + (((sd)->job & JOBL_BABY) ? battle->bc->max_baby_parameter : battle->bc->max_parameter) \ ) /// Generic check for mounts #define pc_hasmount(sd) ( (sd)->sc.option&(OPTION_RIDING|OPTION_WUGRIDER|OPTION_DRAGON|OPTION_MADOGEAR) ) @@ -1004,7 +1004,7 @@ END_ZEROED_BLOCK; /* End */ int (*delspiritball) (struct map_session_data *sd,int count,int type); int (*getmaxspiritball) (struct map_session_data *sd, int min); void (*addfame) (struct map_session_data *sd,int count); - unsigned char (*famerank) (int char_id, int job); + int (*famerank) (int char_id, uint32 job); int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl); int (*readdb) (void); diff --git a/src/map/script.c b/src/map/script.c index e2f5cf364..f876f1072 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9977,7 +9977,7 @@ BUILDIN(setmount) flag = SETMOUNT_TYPE_AUTODETECT; } // Sanity checks and auto-detection - if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { + if ((sd->job & MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { if (pc->checkskill(sd, RK_DRAGONTRAINING)) { // Rune Knight (Dragon) unsigned int option; @@ -9989,11 +9989,11 @@ BUILDIN(setmount) OPTION_DRAGON1); // default value pc->setridingdragon(sd, option); } - } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) { + } else if ((sd->job & MAPID_THIRDMASK) == MAPID_RANGER) { // Ranger (Warg) if (pc->checkskill(sd, RA_WUGRIDER)) pc->setridingwug(sd, true); - } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) { + } else if ((sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) { // Mechanic (Mado Gear) if (pc->checkskill(sd, NC_MADOLICENCE)) pc->setmadogear(sd, true); @@ -11782,7 +11782,7 @@ BUILDIN(eaclass) BUILDIN(roclass) { - int class_ =script_getnum(st,2); + int job = script_getnum(st,2); int sex; if (script_hasdata(st,3)) { sex = script_getnum(st,3); @@ -11793,7 +11793,7 @@ BUILDIN(roclass) else sex = 1; //Just use male when not found. } - script_pushint(st,pc->mapid2jobid(class_, sex)); + script_pushint(st,pc->mapid2jobid(job, sex)); return true; } @@ -11889,7 +11889,7 @@ BUILDIN(changebase) if(vclass == JOB_WEDDING) { if (!battle_config.wedding_modifydisplay || //Do not show the wedding sprites - sd->class_&JOBL_BABY //Baby classes screw up when showing wedding sprites. [Skotlex] They don't seem to anymore. + sd->job & JOBL_BABY //Baby classes screw up when showing wedding sprites. [Skotlex] They don't seem to anymore. ) return true; } diff --git a/src/map/skill.c b/src/map/skill.c index 596d6527d..dce372b6a 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -464,7 +464,7 @@ int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* b if (battle_config.copyskill_restrict == 2) { return 0; } else if (battle_config.copyskill_restrict == 1) { - if ((sd->class_ & (MAPID_UPPERMASK | JOBL_UPPER)) != MAPID_STALKER) + if ((sd->job & (MAPID_UPPERMASK | JOBL_UPPER)) != MAPID_STALKER) return 0; } } @@ -1151,8 +1151,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; case TK_JUMPKICK: - if( dstsd && dstsd->class_ != MAPID_SOUL_LINKER && !tsc->data[SC_PRESERVE] ) - {// debuff the following statuses + if (dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) != MAPID_SOUL_LINKER && tsc->data[SC_PRESERVE] == NULL) { + // debuff the following statuses status_change_end(bl, SC_SOULLINK, INVALID_TIMER); status_change_end(bl, SC_ADRENALINE2, INVALID_TIMER); status_change_end(bl, SC_KAITE, INVALID_TIMER); @@ -1843,7 +1843,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b break; } - if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR + if (sd != NULL && (sd->job & MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && rnd()%10000 < battle_config.sg_miracle_skill_ratio) // SG_MIRACLE [Komurka] sc_start(src,src,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration); @@ -5576,7 +5576,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (status->isimmune(bl) || (dstmd != NULL && (dstmd->class_ == MOBID_EMPELIUM || mob_is_battleground(dstmd)))) heal = 0; - if (sd && dstsd && sd->status.partner_id == dstsd->status.char_id && (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.sex == 0) + if (sd != NULL && dstsd != NULL && sd->status.partner_id == dstsd->status.char_id && (sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.sex == 0) heal = heal * 2; if (tsc && tsc->count) @@ -5867,7 +5867,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case CR_PROVIDENCE: if(sd && dstsd){ //Check they are not another crusader [Skotlex] - if ((dstsd->class_&MAPID_UPPERMASK) == MAPID_CRUSADER) { + if ((dstsd->job & MAPID_UPPERMASK) == MAPID_CRUSADER) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; @@ -5881,7 +5881,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin { struct status_change* sc = status->get_sc(src); - if( sd && dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex ) { + if (sd != NULL && dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex) { // Cannot cast on another bard/dancer-type class of the same gender as caster clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); @@ -6303,7 +6303,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( lv > battle_config.devotion_level_difference || // Level difference requeriments (dstsd->sc.data[type] && dstsd->sc.data[type]->val1 != src->id) || // Cannot Devote a player devoted from another source (skill_id == ML_DEVOTION && (!mer || mer != dstsd->md)) || // Mercenary only can devote owner - (dstsd->class_&MAPID_UPPERMASK) == MAPID_CRUSADER || // Crusader Cannot be devoted + (dstsd->job & MAPID_UPPERMASK) == MAPID_CRUSADER || // Crusader Cannot be devoted (dstsd->sc.data[SC_HELLPOWER])) // Players affected by SC_HELLPOWERR cannot be devoted. { if( sd ) @@ -6356,7 +6356,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case MO_KITRANSLATION: - if(dstsd && ((dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK)!=MAPID_REBELLION)) { + if (dstsd != NULL && (dstsd->job & MAPID_BASEMASK) != MAPID_GUNSLINGER) { pc->addspiritball(dstsd,skill->get_time(skill_id,skill_lv),5); } break; @@ -6372,10 +6372,10 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case MO_ABSORBSPIRITS: { int sp = 0; - if ( dstsd && dstsd->spiritball - && (sd == dstsd || map_flag_vs(src->m) || (sd && sd->duel_group && sd->duel_group == dstsd->duel_group)) - && ((dstsd->class_&MAPID_BASEMASK) != MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK) != MAPID_REBELLION) - ) { + if (dstsd != NULL && dstsd->spiritball != 0 + && (sd == dstsd || map_flag_vs(src->m) || (sd && sd->duel_group && sd->duel_group == dstsd->duel_group)) + && (dstsd->job & MAPID_BASEMASK) != MAPID_GUNSLINGER + ) { // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen] sp = dstsd->spiritball * 7; pc->delspiritball(dstsd, dstsd->spiritball, 0); @@ -6576,7 +6576,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (sd) { if (!dstsd || !( (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SOULLINKER) - || (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER + || (dstsd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER || dstsd->status.char_id == sd->status.char_id || dstsd->status.char_id == sd->status.partner_id || dstsd->status.char_id == sd->status.child @@ -7211,7 +7211,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if((dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER) + if ((dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER) || (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_ROGUE) //Rogue's spirit defends against dispel. || (dstsd && pc_ismadogear(dstsd)) || rnd()%100 >= 50+10*skill_lv ) @@ -8004,7 +8004,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SL_SUPERNOVICE: case SL_WIZARD: //NOTE: here, 'type' has the value of the associated MAPID, not of the SC_SOULLINK constant. - if (sd && !(dstsd && (dstsd->class_&MAPID_UPPERMASK) == type)) { + if (sd != NULL && !(dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == type)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -8020,7 +8020,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin sc_start(src,src,SC_SMA_READY,100,skill_lv,skill->get_time(SL_SMA,skill_lv)); break; case SL_HIGH: - if (sd && !(dstsd && (dstsd->class_&JOBL_UPPER) && !(dstsd->class_&JOBL_2) && dstsd->status.base_level < 70)) { + if (sd != NULL && !(dstsd != NULL && (dstsd->job & JOBL_UPPER) != 0 && (dstsd->job & JOBL_2) == 0 && dstsd->status.base_level < 70)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -8673,7 +8673,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if((dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER) || rnd()%100 >= 60 + 8 * skill_lv) { + if ((dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER) || rnd()%100 >= 60 + 8 * skill_lv) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -9230,8 +9230,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SR_ASSIMILATEPOWER: if( flag&1 ) { int sp = 0; - if( dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m)) && (dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER ) - { + if (dstsd != NULL && dstsd->spiritball != 0 && (sd == dstsd || map_flag_vs(src->m)) && (dstsd->job & MAPID_BASEMASK) != MAPID_GUNSLINGER) { sp = dstsd->spiritball; //1%sp per spiritball. pc->delspiritball(dstsd, dstsd->spiritball, 0); status_percent_heal(src, 0, sp); @@ -9249,7 +9248,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SR_POWERVELOCITY: if( !dstsd ) break; - if ( sd && (dstsd->class_&MAPID_BASEMASK) != MAPID_GUNSLINGER ) { + if (sd != NULL && (dstsd->job & MAPID_BASEMASK) != MAPID_GUNSLINGER) { int i, max = pc->getmaxspiritball(dstsd, 5); for ( i = 0; i < max; i++ ) { pc->addspiritball(dstsd, skill->get_time(MO_CALLSPIRITS, 1), max); @@ -13240,7 +13239,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) return 0; if( skill->get_inf2(skill_id)&INF2_CHORUS_SKILL ) { - if( tsd->status.party_id == sd->status.party_id && (tsd->class_&MAPID_THIRDMASK) == MAPID_MINSTRELWANDERER ) + if (tsd->status.party_id == sd->status.party_id && (tsd->job & MAPID_THIRDMASK) == MAPID_MINSTRELWANDERER) p_sd[(*c)++] = tsd->bl.id; return 1; } else { @@ -13249,24 +13248,23 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) case PR_BENEDICTIO: { uint8 dir = map->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); dir = (unit->getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. - if ((tsd->class_&MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest. + if ((tsd->job & MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest. && sd->status.sp >= 10) p_sd[(*c)++]=tsd->bl.id; return 1; } case AB_ADORAMUS: // Adoramus does not consume Blue Gemstone when there is at least 1 Priest class next to the caster - if( (tsd->class_&MAPID_UPPERMASK) == MAPID_PRIEST ) + if ((tsd->job & MAPID_UPPERMASK) == MAPID_PRIEST) p_sd[(*c)++] = tsd->bl.id; return 1; case WL_COMET: // Comet does not consume Red Gemstones when there is at least 1 Warlock class next to the caster - if( ( tsd->class_&MAPID_THIRDMASK ) == MAPID_WARLOCK ) + if ((tsd->job & MAPID_THIRDMASK) == MAPID_WARLOCK) p_sd[(*c)++] = tsd->bl.id; return 1; case LG_RAYOFGENESIS: - if( tsd->status.party_id == sd->status.party_id && (tsd->class_&MAPID_THIRDMASK) == MAPID_ROYAL_GUARD && - tsd->sc.data[SC_BANDING] ) + if (tsd->status.party_id == sd->status.party_id && (tsd->job & MAPID_THIRDMASK) == MAPID_ROYAL_GUARD && tsd->sc.data[SC_BANDING]) p_sd[(*c)++] = tsd->bl.id; return 1; default: //Warning: Assuming Ensemble Dance/Songs for code speed. [Skotlex] @@ -13275,7 +13273,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) if(pc_issit(tsd) || !unit->can_move(&tsd->bl)) return 0; if (sd->status.sex != tsd->status.sex && - (tsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && + (tsd->job & MAPID_UPPERMASK) == MAPID_BARDDANCER && (skill_lv = pc->checkskill(tsd, skill_id)) > 0 && (tsd->weapontype1==W_MUSICAL || tsd->weapontype1==W_WHIP) && sd->status.party_id && tsd->status.party_id && @@ -13725,7 +13723,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case TK_MISSION: - if( (sd->class_&MAPID_UPPERMASK) != MAPID_TAEKWON ) { + if ((sd->job & MAPID_UPPERMASK) != MAPID_TAEKWON) { // Cannot be used by Non-Taekwon classes clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -13737,7 +13735,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case TK_READYSTORM: case TK_READYTURN: case TK_JUMPKICK: - if( (sd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER ) { + if ((sd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER) { // Soul Linkers cannot use this skill clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -13748,7 +13746,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case TK_STORMKICK: case TK_DOWNKICK: case TK_COUNTER: - if ((sd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER) + if ((sd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER) return 0; //Anti-Soul Linker check in case you job-changed with Stances active. if(!(sc && sc->data[SC_COMBOATTACK]) || sc->data[SC_COMBOATTACK]->val1 == TK_JUMPKICK) return 0; //Combo needs to be ready @@ -17793,7 +17791,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, make_per = make_per * battle_config.wp_rate / 100; } - if (sd->class_&JOBL_BABY) //if it's a Baby Class + if ((sd->job & JOBL_BABY) != 0) //if it's a Baby Class make_per = (make_per * 50) / 100; //Baby penalty is 50% (bugreport:4847) if(make_per < 1) make_per = 1; 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 -- cgit v1.2.3-70-g09d2 From 8a9e589446058b33972aff2c054f8c300b3fd1b7 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 2 Dec 2016 20:42:22 +0100 Subject: Change the argument to pc->famerank() to a rank type (instead of job mapid) For consistency with `pc->addfame()`, the argument to pc->famerank() is now an enum fame_list_type. The function was renamed to `pc->fame_rank()` to avoid silently compiling old non-compliant code. Signed-off-by: Haru --- src/map/pc.c | 48 +++++++++++++++++++++++++++++++++--------------- src/map/pc.h | 2 +- src/map/skill.c | 5 +++-- src/map/status.c | 9 +++++---- 4 files changed, 42 insertions(+), 22 deletions(-) (limited to 'src/map/status.c') diff --git a/src/map/pc.c b/src/map/pc.c index 531cc555a..894880608 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -430,30 +430,41 @@ void pc_addfame(struct map_session_data *sd, int ranktype, int count) chrif->updatefamelist(sd); } -// Check whether a player ID is in the fame rankers' list of its job, returns his/her position if so, 0 else -int pc_famerank(int char_id, uint32 job) +/** + * Returns a character's rank in the specified fame list. + * + * @param char_id The character ID. + * @param ranktype The rank list type (@see enum fame_list_type). + * @return The rank position (1-based index) + * @retval 0 if the character isn't in the specified list. + */ +int pc_fame_rank(int char_id, int ranktype) { int i; - switch (job & MAPID_UPPERMASK) { - case MAPID_BLACKSMITH: // Blacksmith + switch (ranktype) { + case RANKTYPE_BLACKSMITH: for (i = 0; i < MAX_FAME_LIST; i++) { if (pc->smith_fame_list[i].id == char_id) return i + 1; } break; - case MAPID_ALCHEMIST: // Alchemist + case RANKTYPE_ALCHEMIST: for (i = 0; i < MAX_FAME_LIST; i++) { if (pc->chemist_fame_list[i].id == char_id) return i + 1; } break; - case MAPID_TAEKWON: // Taekwon + case RANKTYPE_TAEKWON: for (i = 0; i < MAX_FAME_LIST; i++) { if (pc->taekwon_fame_list[i].id == char_id) return i + 1; } break; + case RANKTYPE_PK: // Not implemented + FALLTHROUGH + default: + Assert_ret(0); } return 0; @@ -1656,8 +1667,10 @@ int pc_calc_skilltree(struct map_session_data *sd) } while(flag); // - if (classidx > 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc->famerank(sd->status.char_id, MAPID_TAEKWON)) { - /* Taekwon Ranger Bonus Skill Tree + if (classidx > 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON + && sd->status.base_level >= 90 && sd->status.skill_point == 0 + && pc->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON) > 0) { + /* Taekwon Ranker Bonus Skill Tree ============================================ - Grant All Taekwon Tree, but only as Bonus Skills in case they drop from ranking. - (c > 0) to avoid grant Novice Skill Tree in case of Skill Reset (need more logic) @@ -5108,9 +5121,8 @@ int pc_useitem(struct map_session_data *sd,int n) { } } - if(sd->status.inventory[n].card[0]==CARD0_CREATE && - pc->famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST)) - { + if (sd->status.inventory[n].card[0] == CARD0_CREATE + && pc->fame_rank(MakeDWord(sd->status.inventory[n].card[2], sd->status.inventory[n].card[3]), RANKTYPE_ALCHEMIST) > 0) { script->potion_flag = 2; // Famous player's potions have 50% more efficiency if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ROGUE) script->potion_flag = 3; //Even more effective potions. @@ -7182,7 +7194,8 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { sd->status.skill_point--; if( !skill->dbs->db[index].inf ) status_calc_pc(sd,SCO_NONE); // Only recalculate for passive skills. - else if (sd->status.skill_point == 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON)) + else if (sd->status.skill_point == 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON + && sd->status.base_level >= 90 && pc->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON) > 0) pc->calc_skilltree(sd); // Required to grant all TK Ranger skills. else pc->check_skilltree(sd, skill_id); // Check if a new skill can Lvlup @@ -7429,7 +7442,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) /** * It has been confirmed on official server that when you reset skills with a ranked tweakwon your skills are not reset (because you have all of them anyway) **/ - if ((sd->job & 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->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON)) return 0; if( pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd) ) //Remove perma blindness due to skill-reset. [Skotlex] @@ -8611,7 +8624,12 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) } sd->status.class = class; - fame_flag = pc->famerank(sd->status.char_id, sd->job); + 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); sd->job = (uint16)job; sd->status.job_level=1; sd->status.job_exp=0; @@ -12112,7 +12130,7 @@ void pc_defaults(void) { pc->addspiritball = pc_addspiritball; pc->delspiritball = pc_delspiritball; pc->addfame = pc_addfame; - pc->famerank = pc_famerank; + pc->fame_rank = pc_fame_rank; pc->set_hate_mob = pc_set_hate_mob; pc->getmaxspiritball = pc_getmaxspiritball; diff --git a/src/map/pc.h b/src/map/pc.h index f73a015ca..5c9bec9f6 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1004,7 +1004,7 @@ END_ZEROED_BLOCK; /* End */ int (*delspiritball) (struct map_session_data *sd,int count,int type); int (*getmaxspiritball) (struct map_session_data *sd, int min); void (*addfame) (struct map_session_data *sd, int ranktype, int count); - int (*famerank) (int char_id, uint32 job); + int (*fame_rank) (int char_id, int ranktype); int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl); int (*readdb) (void); diff --git a/src/map/skill.c b/src/map/skill.c index 41135920f..51a8a28e7 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2430,7 +2430,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr case TK_STORMKICK: case TK_DOWNKICK: case TK_COUNTER: - if (pc->famerank(sd->status.char_id,MAPID_TAEKWON)) {//Extend combo time. + if (pc->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON) > 0) { //Extend combo time. sce->val1 = skill_id; //Update combo-skill sce->val3 = skill_id; if( sce->timer != INVALID_TIMER ) @@ -13758,7 +13758,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id status_change_end(&sd->bl, SC_COMBOATTACK, INVALID_TIMER); return 0; } - if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { + if (sc->data[SC_COMBOATTACK]->val1 != skill_id + && !(sd != NULL && sd->status.base_level >= 90 && pc->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON) > 0)) { //Cancel combo wait. unit->cancel_combo(&sd->bl); return 0; diff --git a/src/map/status.c b/src/map/status.c index fe412dce7..c0ce1ac38 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2276,7 +2276,7 @@ unsigned int status_get_base_maxsp(const struct map_session_data *sd, const stru val += val * 25 / 100; else if ((sd->job & JOBL_BABY) != 0) val = val * 70 / 100; - if ((sd->job & 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->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON) > 0) val *= 3; //Triple max SP for top ranking Taekwons over level 90. val += val * st->int_ / 100; @@ -2303,7 +2303,7 @@ unsigned int status_get_base_maxhp(const struct map_session_data *sd, const stru else if ((sd->job & JOBL_BABY) != 0) val = val * 70 / 100; //Baby classes get a 30% hp penalty - if ((sd->job & 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->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON)) val *= 3; //Triple max HP for top ranking Taekwons over level 90. val += val * st->vit / 100; // +1% per each point of VIT @@ -2510,8 +2510,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) if (sd->status.inventory[index].card[0]==CARD0_FORGE) { // Forged weapon wd->star += (sd->status.inventory[index].card[1]>>8); - if(wd->star >= 15) wd->star = 40; // 3 Star Crumbs now give +40 dmg - if(pc->famerank(MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH)) + if (wd->star >= 15) + wd->star = 40; // 3 Star Crumbs now give +40 dmg + if (pc->fame_rank(MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]), RANKTYPE_BLACKSMITH) > 0) wd->star += 10; if (!wa->ele) //Do not overwrite element from previous bonuses. -- cgit v1.2.3-70-g09d2 From c1b4b0b2fb1066087e928e9440b40edd185b188e Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 04:20:55 +0100 Subject: Remove the platform-dependent variables from struct status_data `struct status_data::class_` was platform dependent since c30bb75ec50624429bff7b4106db4be0fda366d6 in order to silence some compile warnings (uint32 on 64 bit builds and uint16 on 32 bit builds). It's now been changed to the correct type, int32, on all platforms. Since the change has potential to silently break third party code, the variable was renamed to `class`. Signed-off-by: Haru --- src/map/atcommand.c | 6 +++--- src/map/clif.c | 52 ++++++++++++++++++++++++++++------------------------ src/map/elemental.c | 4 ++-- src/map/homunculus.c | 2 +- src/map/mercenary.c | 2 +- src/map/mob.c | 17 +++++++++-------- src/map/npc.c | 6 +++--- src/map/pc.c | 12 ++++++------ src/map/script.c | 2 +- src/map/status.c | 12 ++++++------ src/map/unit.h | 6 +----- 11 files changed, 61 insertions(+), 60 deletions(-) (limited to 'src/map/status.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index bd4fa7204..2beb6c634 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -951,7 +951,7 @@ ACMD(hide) { map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); } else { sd->sc.option |= OPTION_INVISIBLE; - sd->vd.class_ = INVISIBLE_CLASS; + sd->vd.class = INVISIBLE_CLASS; clif->message(fd, msg_fd(fd,11)); // Invisible: On // decrement the number of pvp players on the map @@ -6610,9 +6610,9 @@ ACMD(mobinfo) // stats if (monster->mexp) - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d) + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1240), monster->name, monster->jname, monster->sprite, monster->vd.class); // MVP Monster: '%s'/'%s'/'%s' (%d) else - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d) + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1241), monster->name, monster->jname, monster->sprite, monster->vd.class); // Monster: '%s'/'%s'/'%s' (%d) clif->message(fd, atcmd_output); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d diff --git a/src/map/clif.c b/src/map/clif.c index 262ea1c57..887fa9d64 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -276,7 +276,7 @@ unsigned char clif_bl_type(struct block_list *bl) vd = status->get_viewdata(bl); nullpo_retr(CLUT_NPC, vd); - if (clif->isdisguised(bl) && !pc->db_checkid(vd->class_)) + if (clif->isdisguised(bl) && !pc->db_checkid(vd->class)) return CLUT_NPC; return CLUT_PC; case BL_ITEM: @@ -288,15 +288,15 @@ unsigned char clif_bl_type(struct block_list *bl) case BL_MOB: vd = status->get_viewdata(bl); nullpo_retr(CLUT_NPC, vd); - return pc->db_checkid(vd->class_) ? CLUT_PC : CLUT_MOB; + return pc->db_checkid(vd->class) ? CLUT_PC : CLUT_MOB; case BL_NPC: vd = status->get_viewdata(bl); nullpo_retr(CLUT_NPC, vd); - return pc->db_checkid(vd->class_) ? CLUT_PC : CLUT_EVENT; + return pc->db_checkid(vd->class) ? CLUT_PC : CLUT_EVENT; case BL_PET: vd = status->get_viewdata(bl); nullpo_retr(CLUT_NPC, vd); - return pc->db_checkid(vd->class_) ? CLUT_PC : CLUT_PET; + return pc->db_checkid(vd->class) ? CLUT_PC : CLUT_PET; case BL_HOM: return CLUT_HOMNUCLUS; case BL_MER: @@ -961,14 +961,15 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); - p.job = vd->class_; + p.job = vd->class; p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; p.shield = vd->shield; p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; - if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? + if (bl->type == BL_NPC && vd->class == FLAG_CLASS) { + // The hell, why flags work like this? p.shield = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); @@ -1005,7 +1006,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu nullpo_retv(bl); #if PACKETVER < 20091103 - if( !pc->db_checkid(vd->class_) ) { + if (!pc->db_checkid(vd->class)) { clif->set_unit_idle2(bl,tsd,target); return; } @@ -1028,7 +1029,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); - p.job = vd->class_; + p.job = vd->class; p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; @@ -1037,7 +1038,8 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu #endif p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; - if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? + if (bl->type == BL_NPC && vd->class == FLAG_CLASS) { + // The hell, why flags work like this? p.accessory = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); @@ -1082,7 +1084,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu if (clif->isdisguised(bl)) { #if PACKETVER >= 20091103 - p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; #else p.GID = -bl->id; @@ -1115,11 +1117,12 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; - p.job = vd->class_; + p.job = vd->class; p.shield = vd->shield; p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; - if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? + if (bl->type == BL_NPC && vd->class == FLAG_CLASS) { + // The hell, why flags work like this? p.shield = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); @@ -1147,7 +1150,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { nullpo_retv(bl); #if PACKETVER < 20091103 - if( !pc->db_checkid(vd->class_) ) { + if (!pc->db_checkid(vd->class)) { clif->spawn_unit2(bl,target); return; } @@ -1170,7 +1173,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); - p.job = vd->class_; + p.job = vd->class; p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; @@ -1179,7 +1182,8 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { #endif p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; - if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? + if (bl->type == BL_NPC && vd->class == FLAG_CLASS) { + // The hell, why flags work like this? p.accessory = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); @@ -1223,7 +1227,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { if (sd->status.class != sd->disguise) clif->send(&p,sizeof(p),bl,target); #if PACKETVER >= 20091103 - p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; #else p.GID = -bl->id; @@ -1266,7 +1270,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); - p.job = vd->class_; + p.job = vd->class; p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; @@ -1315,7 +1319,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, if (clif->isdisguised(bl)) { #if PACKETVER >= 20091103 - p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; #else p.GID = -bl->id; @@ -1427,7 +1431,7 @@ bool clif_spawn(struct block_list *bl) if( !vd ) return false; - if (vd->class_ == INVISIBLE_CLASS) + if (vd->class == INVISIBLE_CLASS) return true; // Doesn't need to be spawned, so everything is alright if (bl->type == BL_NPC) { @@ -1774,7 +1778,7 @@ void clif_move(struct unit_data *ud) bl = ud->bl; nullpo_retv(bl); vd = status->get_viewdata(bl); - if (!vd || vd->class_ == INVISIBLE_CLASS) + if (vd == NULL || vd->class == INVISIBLE_CLASS) return; //This performance check is needed to keep GM-hidden objects from being notified to bots. if (bl->type == BL_NPC) { @@ -4231,7 +4235,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { nullpo_retv(bl); vd = status->get_viewdata(bl); - if (!vd || vd->class_ == INVISIBLE_CLASS) + if (vd == NULL || vd->class == INVISIBLE_CLASS) return; if (bl->type == BL_NPC) { @@ -4691,7 +4695,7 @@ int clif_outsight(struct block_list *bl,va_list ap) nullpo_ret(bl); switch(bl->type){ case BL_PC: - if (sd->vd.class_ != INVISIBLE_CLASS) + if (sd->vd.class != INVISIBLE_CLASS) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); if (sd->chat_id != 0) { struct chat_data *cd = map->id2cd(sd->chat_id); @@ -4714,7 +4718,7 @@ int clif_outsight(struct block_list *bl,va_list ap) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); break; default: - if ((vd=status->get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS) + if ((vd=status->get_viewdata(bl)) && vd->class != INVISIBLE_CLASS) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); break; } @@ -4723,7 +4727,7 @@ int clif_outsight(struct block_list *bl,va_list ap) nullpo_ret(tbl); if (tbl->type == BL_SKILL) //Trap knocked out of sight clif->clearchar_skillunit(BL_UCAST(BL_SKILL, tbl), sd->fd); - else if ((vd = status->get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS + else if ((vd = status->get_viewdata(tbl)) != NULL && vd->class != INVISIBLE_CLASS && !(tbl->type == BL_NPC && (BL_UCAST(BL_NPC, tbl)->option&OPTION_INVISIBLE))) clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd); } diff --git a/src/map/elemental.c b/src/map/elemental.c index 76b7ba24b..ae1fda0a2 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -704,7 +704,7 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds int sp = 5; - switch (ed->vd->class_) { + switch (ed->vd->class) { case ELEID_EL_AGNI_M: case ELEID_EL_AQUA_M: case ELEID_EL_VENTUS_M: @@ -864,7 +864,7 @@ int read_elementaldb(void) { db->lv = atoi(str[3]); estatus = &db->status; - db->vd.class_ = db->class_; + db->vd.class = db->class_; estatus->max_hp = atoi(str[4]); estatus->max_sp = atoi(str[5]); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index cc920b888..91a455416 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1350,7 +1350,7 @@ void do_init_homunculus(bool minimal) { //Stock view data for homuncs memset(homun->dbs->viewdb, 0, sizeof(homun->dbs->viewdb)); for (class_ = 0; class_ < MAX_HOMUNCULUS_CLASS; class_++) - homun->dbs->viewdb[class_].class_ = HM_CLASS_BASE+class_; + homun->dbs->viewdb[class_].class = HM_CLASS_BASE + class_; } void do_final_homunculus(void) { diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 95c1f9be3..f5d3fe11c 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -444,7 +444,7 @@ bool read_mercenarydb_sub(char* str[], int columns, int current) { db->lv = atoi(str[3]); mstatus = &db->status; - db->vd.class_ = db->class_; + db->vd.class = db->class_; mstatus->max_hp = atoi(str[4]); mstatus->max_sp = atoi(str[5]); diff --git a/src/map/mob.c b/src/map/mob.c index c3fdbead2..d5932f195 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1652,7 +1652,7 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { memmove(&md->lootitem[0], &md->lootitem[1], (LOOTITEM_SIZE-1)*sizeof(md->lootitem[0])); memcpy (&md->lootitem[LOOTITEM_SIZE-1], &fitem->item_data, sizeof(md->lootitem[0])); } - if (pc->db_checkid(md->vd->class_)) { + if (pc->db_checkid(md->vd->class)) { //Give them walk act/delay to properly mimic players. [Skotlex] clif->takeitem(&md->bl,tbl); md->ud.canact_tick = tick + md->status.amotion; @@ -2684,7 +2684,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if( !rebirth ) { - if( pc->db_checkid(md->vd->class_) ) {//Player mobs are not removed automatically by the client. + if (pc->db_checkid(md->vd->class)) { + // Player mobs are not removed automatically by the client. /* first we set them dead, then we delay the out sight effect */ clif->clearunit_area(&md->bl,CLR_DEAD); clif->clearunit_delayed(&md->bl, CLR_OUTSIGHT,tick+3000); @@ -2831,7 +2832,7 @@ int mob_class_change (struct mob_data *md, int class_) { mob_stop_walking(md, STOPWALKING_FLAG_NONE); unit->skillcastcancel(&md->bl, 0); status->set_viewdata(&md->bl, class_); - clif->class_change(&md->bl, md->vd->class_, 1); + clif->class_change(&md->bl, md->vd->class, 1); status_calc_mob(md, SCO_FIRST); md->ud.state.speed_changed = 1; //Speed change update. @@ -4209,7 +4210,7 @@ int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *source) return 0; } md.mob_id = i32; - md.vd.class_ = md.mob_id; + md.vd.class = md.mob_id; if ((t = libconfig->setting_get_member(mobt, "Inherit")) && (inherit = libconfig->setting_get_bool(t))) { if (!mob->db_data[md.mob_id]) { @@ -4563,7 +4564,7 @@ void mob_name_constants(void) { *------------------------------------------*/ bool mob_readdb_mobavail(char* str[], int columns, int current) { - int class_, k; + int class_, view_class; nullpo_retr(false, str); class_=atoi(str[0]); @@ -4574,13 +4575,13 @@ bool mob_readdb_mobavail(char* str[], int columns, int current) return false; } - k=atoi(str[1]); + view_class = atoi(str[1]); memset(&mob->db_data[class_]->vd, 0, sizeof(struct view_data)); - mob->db_data[class_]->vd.class_=k; + mob->db_data[class_]->vd.class = view_class; //Player sprites - if(pc->db_checkid(k) && columns==12) { + if (pc->db_checkid(view_class) && columns == 12) { mob->db_data[class_]->vd.sex=atoi(str[2]); mob->db_data[class_]->vd.hair_style=atoi(str[3]); mob->db_data[class_]->vd.hair_color=atoi(str[4]); diff --git a/src/map/npc.c b/src/map/npc.c index 72c451ef9..a824d4216 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -4961,11 +4961,11 @@ int do_init_npc(bool minimal) { //Stock view data for normal npcs. memset(&npc_viewdb, 0, sizeof(npc_viewdb)); - npc_viewdb[0].class_ = INVISIBLE_CLASS; //Invisible class is stored here. + npc_viewdb[0].class = INVISIBLE_CLASS; //Invisible class is stored here. for( i = 1; i < MAX_NPC_CLASS; i++ ) - npc_viewdb[i].class_ = i; + npc_viewdb[i].class = i; for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ ) - npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i; + npc_viewdb2[i - MAX_NPC_CLASS2_START].class = i; npc->ev_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH); npc->ev_label_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, NAME_LENGTH); diff --git a/src/map/pc.c b/src/map/pc.c index 8d6910ce4..2cf5d75b4 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1492,7 +1492,7 @@ int pc_reg_received(struct map_session_data *sd) } if (pc_isinvisible(sd)) { - sd->vd.class_ = INVISIBLE_CLASS; + sd->vd.class = INVISIBLE_CLASS; clif->message(sd->fd, msg_sd(sd,11)); // Invisible: On // decrement the number of pvp players on the map map->list[sd->bl.m].users_pvp--; @@ -1945,7 +1945,7 @@ int pc_disguise(struct map_session_data *sd, int class) clif->changeoption(&sd->bl); // We need to update the client so it knows that a costume is being used if( sd->sc.option&OPTION_COSTUME ) { - clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); + clif->changelook(&sd->bl, LOOK_BASE, sd->vd.class); clif->changelook(&sd->bl,LOOK_WEAPON,0); clif->changelook(&sd->bl,LOOK_SHIELD,0); clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); @@ -8679,7 +8679,7 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper) pc->disguise(sd, -1); status->set_viewdata(&sd->bl, class); - clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris] + clif->changelook(&sd->bl, LOOK_BASE, sd->vd.class); // move sprite update to prevent client crashes with incompatible equipment [Valaris] if(sd->vd.cloth_color) clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); if (sd->vd.body_style) @@ -8779,7 +8779,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) switch(type){ case LOOK_BASE: status->set_viewdata(&sd->bl, val); - clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); + clif->changelook(&sd->bl, LOOK_BASE, sd->vd.class); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); if (sd->vd.cloth_color) clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); @@ -8926,7 +8926,7 @@ int pc_setoption(struct map_session_data *sd,int type) if (new_look < 0) { //Restore normal look. status->set_viewdata(&sd->bl, sd->status.class); - new_look = sd->vd.class_; + new_look = sd->vd.class; } pc_stop_attack(sd); //Stop attacking on new view change (to prevent wedding/santa attacks. @@ -11743,7 +11743,7 @@ void pc_update_idle_time(struct map_session_data* sd, enum e_battle_config_idlet } //Checks if the given class value corresponds to a player class. [Skotlex] -//JOB_NOVICE isn't checked for class_ is supposed to be unsigned +//JOB_NOVICE isn't checked for class is supposed to be unsigned bool pc_db_checkid(int class) { return class < JOB_MAX_BASIC diff --git a/src/map/script.c b/src/map/script.c index 27db206cf..38931bd11 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11894,7 +11894,7 @@ BUILDIN(changebase) return true; } - if(sd->disguise == -1 && vclass != sd->vd.class_) + if (sd->disguise == -1 && vclass != sd->vd.class) pc->changelook(sd,LOOK_BASE,vclass); //Updated client view. Base, Weapon and Cloth Colors. return true; diff --git a/src/map/status.c b/src/map/status.c index c0ce1ac38..78c11899b 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6432,7 +6432,7 @@ int status_get_class(const struct block_list *bl) nullpo_ret(bl); switch (bl->type) { case BL_PC: return BL_UCCAST(BL_PC, bl)->status.class; - case BL_MOB: return BL_UCCAST(BL_MOB, bl)->vd->class_; //Class used on all code should be the view class of the mob. + case BL_MOB: return BL_UCCAST(BL_MOB, bl)->vd->class; //Class used on all code should be the view class of the mob. case BL_PET: return BL_UCCAST(BL_PET, bl)->pet.class_; case BL_HOM: return BL_UCCAST(BL_HOM, bl)->homunculus.class_; case BL_MER: return BL_UCCAST(BL_MER, bl)->mercenary.class_; @@ -6827,7 +6827,7 @@ void status_set_viewdata(struct block_list *bl, int class_) break; } } - sd->vd.class_ = class_; + sd->vd.class = class_; clif->get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield); sd->vd.head_top = sd->status.head_top; sd->vd.head_mid = sd->status.head_mid; @@ -6879,7 +6879,7 @@ void status_set_viewdata(struct block_list *bl, int class_) struct pet_data *pd = BL_UCAST(BL_PET, bl); if (vd != NULL) { memcpy(&pd->vd, vd, sizeof(struct view_data)); - if (!pc->db_checkid(vd->class_)) { + if (!pc->db_checkid(vd->class)) { pd->vd.hair_style = battle_config.pet_hair_style; if(pd->pet.equip) { pd->vd.head_bottom = itemdb_viewid(pd->pet.equip); @@ -9864,7 +9864,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_HANBOK: case SC_OKTOBERFEST: if( !vd ) break; - clif->changelook(bl,LOOK_BASE,vd->class_); + clif->changelook(bl, LOOK_BASE, vd->class); clif->changelook(bl,LOOK_WEAPON,0); clif->changelook(bl,LOOK_SHIELD,0); clif->changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color); @@ -10264,7 +10264,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t clif->changeoption(bl); if( sd && opt_flag&0x4 ) { if (vd) - clif->changelook(bl,LOOK_BASE,vd->class_); + clif->changelook(bl, LOOK_BASE, vd->class); clif->changelook(bl,LOOK_WEAPON,0); clif->changelook(bl,LOOK_SHIELD,0); if (vd) @@ -11202,7 +11202,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const else if(opt_flag) { clif->changeoption(bl); if( sd && opt_flag&0x4 ) { - clif->changelook(bl,LOOK_BASE,sd->vd.class_); + clif->changelook(bl, LOOK_BASE, sd->vd.class); clif->get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield); clif->changelook(bl,LOOK_WEAPON,sd->vd.weapon); clif->changelook(bl,LOOK_SHIELD,sd->vd.shield); diff --git a/src/map/unit.h b/src/map/unit.h index a3241a4b9..d065b3d57 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -80,11 +80,7 @@ struct unit_data { }; struct view_data { -#ifdef __64BIT__ - uint32 class_; // FIXME: This shouldn't really depend on the architecture. -#else // not __64BIT__ - uint16 class_; -#endif // __64BIT__ + int16 class; uint16 weapon, shield, //Or left-hand weapon. robe, -- cgit v1.2.3-70-g09d2