diff options
author | Haru <haru@dotalux.com> | 2016-12-03 06:19:35 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2017-09-17 17:48:16 +0200 |
commit | 20caa41aeae6e49375aeb187c06dc077e330b414 (patch) | |
tree | 9e96d78a78005c979e8204da8dd806fc706c6ceb /src/map | |
parent | a681d759cc887e8adccbd30d3b7a7ca355bbda96 (diff) | |
download | hercules-20caa41aeae6e49375aeb187c06dc077e330b414.tar.gz hercules-20caa41aeae6e49375aeb187c06dc077e330b414.tar.bz2 hercules-20caa41aeae6e49375aeb187c06dc077e330b414.tar.xz hercules-20caa41aeae6e49375aeb187c06dc077e330b414.zip |
Differentiate variables that hold a ViewSprite and a Subtype (part 2)
`sd->status.shield` is renamed to `sd->status.look.shield` and only
holds ViewSprite IDs. Its previous other meaning is now transferred to
`sd->has_shield`, of boolean type (to detect the presence of a shield)
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.c | 4 | ||||
-rw-r--r-- | src/map/pc.c | 35 | ||||
-rw-r--r-- | src/map/pc.h | 1 | ||||
-rw-r--r-- | src/map/script.c | 2 | ||||
-rw-r--r-- | src/map/skill.c | 2 | ||||
-rw-r--r-- | src/map/status.c | 2 |
6 files changed, 30 insertions, 16 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 2962aaa8b..77e6d6055 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -889,7 +889,7 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un #if PACKETVER < 4 *rhand = sd->status.look.weapon; - *lhand = sd->status.shield; + *lhand = sd->status.look.shield; #else if (sd->equip_index[EQI_HAND_R] >= 0 && sd->inventory_data[sd->equip_index[EQI_HAND_R]]) @@ -9450,7 +9450,7 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) { // Character Looks #if PACKETVER < 4 clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); #else clif->changelook(&sd->bl,LOOK_WEAPON,0); #endif diff --git a/src/map/pc.c b/src/map/pc.c index c30161a0c..a8a715a70 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -895,10 +895,19 @@ int pc_setequipindex(struct map_session_data *sd) } if (sd->status.inventory[i].equip & EQP_HAND_L) { - if (sd->inventory_data[i] != NULL && sd->inventory_data[i]->type == IT_WEAPON) - sd->weapontype2 = sd->inventory_data[i]->subtype; - else + if (sd->inventory_data[i] != NULL) { + if (sd->inventory_data[i]->type == IT_WEAPON) + sd->weapontype2 = sd->inventory_data[i]->subtype; + else + sd->weapontype2 = W_FIST; + if (sd->inventory_data[i]->type == IT_ARMOR) + sd->has_shield = true; + else + sd->has_shield = false; + } else { sd->weapontype2 = W_FIST; + sd->has_shield = false; + } } } } @@ -5947,7 +5956,7 @@ int pc_checkallowskill(struct map_session_data *sd) // Spurt requires bare hands (feet, in fact xD) status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); - if(sd->status.shield <= 0) { // Skills requiring a shield + if (!sd->has_shield) { // Skills requiring a shield for (i = 0; i < ARRAYLENGTH(scs_list); i++) if(sd->sc.data[scs_list[i]]) status_change_end(&sd->bl, scs_list[i], INVALID_TIMER); @@ -8891,7 +8900,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) sd->status.clothes_color=val; break; case LOOK_SHIELD: - sd->status.shield=val; + sd->status.look.shield = val; break; case LOOK_SHOES: break; @@ -9772,18 +9781,21 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, (pos & EQP_HAND_L)) { if (id != NULL) { if (id->type == IT_WEAPON) { - sd->status.shield = 0; + sd->has_shield = false; + sd->status.look.shield = 0; sd->weapontype2 = id->subtype; } else if (id->type == IT_ARMOR) { - sd->status.shield = id->view_sprite; + sd->has_shield = true; + sd->status.look.shield = id->view_sprite; sd->weapontype2 = W_FIST; } } else { - sd->status.shield = 0; + sd->has_shield = false; + sd->status.look.shield = 0; sd->weapontype2 = W_FIST; } pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); } //Added check to prevent sending the same look on multiple slots -> //causes client to redraw item on top of itself. (suggested by Lupus) @@ -10001,10 +10013,11 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. } if (pos & EQP_HAND_L) { - sd->status.shield = 0; + sd->has_shield = false; + sd->status.look.shield = 0; sd->weapontype2 = W_FIST; pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); } if (pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { sd->status.head_bottom = 0; diff --git a/src/map/pc.h b/src/map/pc.h index 62129b5ae..8615f00f2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -308,6 +308,7 @@ struct map_session_data { short nameid; int64 tick; } item_delay[MAX_ITEMDELAYS]; // [Paradox924X] + bool has_shield; ///< Whether the character is wearing a shield. int16 weapontype; ///< Weapon type considering both hands (@see enum weapon_type). int16 weapontype1; ///< Weapon type in the right/primary hand (@see enum weapon_type). int16 weapontype2; ///< Weapon type in the left/secondary hand (@see enum weapon_type). diff --git a/src/map/script.c b/src/map/script.c index 58dd65173..09f6377ef 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15525,7 +15525,7 @@ BUILDIN(getlook) case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5 case LOOK_HAIR_COLOR: val = sd->status.hair_color; break; //6 case LOOK_CLOTHES_COLOR: val = sd->status.clothes_color; break; //7 - case LOOK_SHIELD: val = sd->status.shield; break; //8 + case LOOK_SHIELD: val = sd->status.look.shield; break; //8 case LOOK_SHOES: break; //9 case LOOK_ROBE: val = sd->status.robe; break; //12 case LOOK_BODY2: val=sd->status.body; break; //13 diff --git a/src/map/skill.c b/src/map/skill.c index 4649ace42..25d85e746 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14245,7 +14245,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } break; case ST_SHIELD: - if(sd->status.shield <= 0) { + if (!sd->has_shield) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } diff --git a/src/map/status.c b/src/map/status.c index ed29e85be..733eb5f6f 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4326,7 +4326,7 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1]; if (sd->weapontype > MAX_SINGLE_WEAPON_TYPE) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2] / 4; - if ( sd->status.shield ) + if (sd->has_shield) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][MAX_SINGLE_WEAPON_TYPE]; switch (sd->weapontype) { case W_BOW: |