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 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/map/atcommand.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! -- cgit v1.2.3-60-g2f50