From a98b2d93f3727d18d8add5cb5c35830cbb171114 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 5 Sep 2016 00:07:08 +0200 Subject: Split 'View' in two different fields in the item database - The field was used both for sprite view IDs and for weapon or ammunition subtypes. Now the fields 'ViewSprite' and 'Subtype' are used respectively. Signed-off-by: Haru --- src/map/pc.c | 105 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 52 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index f332feea8..904867f76 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -765,9 +765,9 @@ int pc_equippoint(struct map_session_data *sd,int n) return 0; //Not equippable by players. ep = sd->inventory_data[n]->equip; - if (sd->inventory_data[n]->look == W_DAGGER - || sd->inventory_data[n]->look == W_1HSWORD - || sd->inventory_data[n]->look == W_1HAXE + if (sd->inventory_data[n]->subtype == W_DAGGER + || sd->inventory_data[n]->subtype == W_1HSWORD + || sd->inventory_data[n]->subtype == W_1HAXE ) { if (pc->checkskill(sd,AS_LEFT) > 0 || (sd->job & MAPID_UPPERMASK) == MAPID_ASSASSIN @@ -794,9 +794,9 @@ int pc_item_equippoint(struct map_session_data *sd, struct item_data* id) return 0; //Not equippable by players. ep = id->equip; - if (id->look == W_DAGGER || - id->look == W_1HSWORD || - id->look == W_1HAXE) { + if (id->subtype == W_DAGGER || + id->subtype == W_1HSWORD || + id->subtype == W_1HAXE) { if (pc->checkskill(sd, AS_LEFT) > 0 || (sd->job & MAPID_UPPERMASK) == MAPID_ASSASSIN || (sd->job & MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) { @@ -837,7 +837,7 @@ int pc_calcweapontype(struct map_session_data *sd) return 1; } // dual-wield - sd->status.weapon = 0; + sd->status.weapon = W_FIST; switch (sd->weapontype1){ case W_DAGGER: switch (sd->weapontype2) { @@ -861,7 +861,7 @@ int pc_calcweapontype(struct map_session_data *sd) } } // unknown, default to right hand type - if (!sd->status.weapon) + if (sd->status.weapon == W_FIST) sd->status.weapon = sd->weapontype1; return 2; @@ -884,20 +884,18 @@ int pc_setequipindex(struct map_session_data *sd) if(sd->status.inventory[i].equip & pc->equip_pos[j]) sd->equip_index[j] = i; - if(sd->status.inventory[i].equip & EQP_HAND_R) - { - if(sd->inventory_data[i]) - sd->weapontype1 = sd->inventory_data[i]->look; + if (sd->status.inventory[i].equip & EQP_HAND_R) { + if (sd->inventory_data[i]) + sd->weapontype1 = sd->inventory_data[i]->subtype; else - sd->weapontype1 = 0; + sd->weapontype1 = W_FIST; } - if( sd->status.inventory[i].equip & EQP_HAND_L ) - { - if( sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON ) - sd->weapontype2 = sd->inventory_data[i]->look; + 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 - sd->weapontype2 = 0; + sd->weapontype2 = W_FIST; } } } @@ -1088,13 +1086,13 @@ int pc_isequip(struct map_session_data *sd,int n) return 1; //Can equip all helms if (sd->status.base_level > 96 && item->equip & EQP_ARMS && item->type == IT_WEAPON) - switch(item->look) { //In weapons, the look determines type of weapon. - case W_DAGGER: //Level 4 Knives are equippable.. this means all knives, I'd guess? - case W_1HSWORD: //All 1H swords - case W_1HAXE: //All 1H Axes - case W_MACE: //All 1H Maces - case W_STAFF: //All 1H Staves - return 1; + switch (item->subtype) { //In weapons, the look determines type of weapon. + case W_DAGGER: //Level 4 Knives are equippable.. this means all knives, I'd guess? + case W_1HSWORD: //All 1H swords + case W_1HAXE: //All 1H Axes + case W_MACE: //All 1H Maces + case W_STAFF: //All 1H Staves + return 1; } } } @@ -5942,7 +5940,7 @@ int pc_checkallowskill(struct map_session_data *sd) status_change_end(&sd->bl, scw_list[i], INVALID_TIMER); } - if(sd->sc.data[SC_STRUP] && sd->status.weapon) + if(sd->sc.data[SC_STRUP] && sd->status.weapon != W_FIST) // Spurt requires bare hands (feet, in fact xD) status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); @@ -9757,25 +9755,27 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, nullpo_retv(sd); if ((!map_no_view(sd->bl.m,EQP_SHADOW_WEAPON) && pos & EQP_SHADOW_WEAPON) || (pos & EQP_HAND_R)) { - if(id) - sd->weapontype1 = id->look; + if (id != NULL) + sd->weapontype1 = id->subtype; else - sd->weapontype1 = 0; + sd->weapontype1 = W_FIST; pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); } if ((!map_no_view(sd->bl.m,EQP_SHADOW_SHIELD) && pos & EQP_SHADOW_SHIELD) || (pos & EQP_HAND_L)) { - if (id) { - if(id->type == IT_WEAPON) { + if (id != NULL) { + if (id->type == IT_WEAPON) { sd->status.shield = 0; - sd->weapontype2 = id->look; - } else if(id->type == IT_ARMOR) { - sd->status.shield = id->look; - sd->weapontype2 = 0; + sd->weapontype2 = id->subtype; + } else if (id->type == IT_ARMOR) { + sd->status.shield = id->view_sprite; + sd->weapontype2 = W_FIST; } - } else - sd->status.shield = sd->weapontype2 = 0; + } else { + sd->status.shield = 0; + sd->weapontype2 = W_FIST; + } pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); } @@ -9783,42 +9783,42 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, //causes client to redraw item on top of itself. (suggested by Lupus) if (!map_no_view(sd->bl.m,EQP_HEAD_LOW) && pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))) - sd->status.head_bottom = id->look; + sd->status.head_bottom = id->view_sprite; else sd->status.head_bottom = 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } if (!map_no_view(sd->bl.m,EQP_HEAD_TOP) && pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { if (id) - sd->status.head_top = id->look; + sd->status.head_top = id->view_sprite; else sd->status.head_top = 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if (!map_no_view(sd->bl.m,EQP_HEAD_MID) && pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { if (id && !(pos&EQP_HEAD_TOP)) - sd->status.head_mid = id->look; + sd->status.head_mid = id->view_sprite; else sd->status.head_mid = 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_TOP) && pos & EQP_COSTUME_HEAD_TOP) { if (id){ - sd->status.head_top = id->look; + sd->status.head_top = id->view_sprite; } else sd->status.head_top = 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_MID) && pos & EQP_COSTUME_HEAD_MID) { if(id && !(pos&EQP_HEAD_TOP)){ - sd->status.head_mid = id->look; + sd->status.head_mid = id->view_sprite; } else sd->status.head_mid = 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_LOW) && pos & EQP_COSTUME_HEAD_LOW) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){ - sd->status.head_bottom = id->look; + sd->status.head_bottom = id->view_sprite; } else sd->status.head_bottom = 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); @@ -9827,12 +9827,12 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, if (!map_no_view(sd->bl.m,EQP_SHOES) && pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); if (!map_no_view(sd->bl.m,EQP_GARMENT) && pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) { - sd->status.robe = id ? id->look : 0; + sd->status.robe = id ? id->view_sprite : 0; clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); } if (!map_no_view(sd->bl.m,EQP_COSTUME_GARMENT) && pos & EQP_COSTUME_GARMENT) { - sd->status.robe = id ? id->look : 0; + sd->status.robe = id ? id->view_sprite : 0; clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); } } @@ -9987,7 +9987,7 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) { nullpo_retv(sd); if (pos & EQP_HAND_R) { - sd->weapontype1 = 0; + sd->weapontype1 = W_FIST; sd->status.weapon = sd->weapontype2; pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); @@ -9995,7 +9995,8 @@ 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 = sd->weapontype2 = 0; + sd->status.shield = 0; + sd->weapontype2 = W_FIST; pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); } @@ -10013,17 +10014,17 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) } if (pos & EQP_COSTUME_HEAD_TOP) { - sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->look : 0; + sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if (pos & EQP_COSTUME_HEAD_MID) { - sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->look : 0; + sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if (pos & EQP_COSTUME_HEAD_LOW) { - sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->look : 0; + sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } @@ -10036,7 +10037,7 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) } if (pos & EQP_COSTUME_GARMENT) { - sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0; + sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); } } @@ -10091,7 +10092,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) clif->unequipitemack(sd, n, pos, UIA_SUCCESS); if ((pos & EQP_ARMS) && - sd->weapontype1 == 0 && sd->weapontype2 == 0 && (sd->sc.data[SC_TK_SEVENWIND] == 0 || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!) + sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST && (sd->sc.data[SC_TK_SEVENWIND] == NULL || sd->sc.data[SC_ASPERSIO] != NULL)) //Check for seven wind (but not level seven!) skill->enchant_elemental_end(&sd->bl, -1); if (pos & EQP_ARMOR) { -- cgit v1.2.3-70-g09d2 From a681d759cc887e8adccbd30d3b7a7ca355bbda96 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 03:41:08 +0100 Subject: Differentiate variables that hold a ViewSprite and a weapon Subtype `sd->status.weapon` is renamed to `sd->status.look.weapon` and only holds ViewSprite IDs. Its previous other meaning is now transferred to `sd->weapontype` (holding the currently equipped weapon type, considering both hands at once) Signed-off-by: Haru --- src/char/char.c | 10 +++++----- src/common/mmo.h | 4 +++- src/map/battle.c | 36 +++++++++++++++++------------------ src/map/clif.c | 4 ++-- src/map/pc.c | 58 +++++++++++++++++++++++++++++++------------------------- src/map/pc.h | 13 ++++++++++--- src/map/script.c | 2 +- src/map/skill.c | 10 +++++----- src/map/status.c | 39 ++++++++++++++++++------------------- 9 files changed, 94 insertions(+), 82 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/char/char.c b/src/char/char.c index 4687d4d6b..09aa8684b 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -460,7 +460,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->int_ != cp->int_) || (p->dex != cp->dex) || (p->luk != cp->luk) || (p->option != cp->option) || (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || - (p->pet_id != cp->pet_id) || (p->weapon != cp->weapon) || (p->hom_id != cp->hom_id) || + (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) || (p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || @@ -490,7 +490,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id, - p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, + p->look.weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size @@ -1094,7 +1094,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.weapon, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) @@ -1208,7 +1208,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->weapon, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) @@ -1942,7 +1942,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { //When the weapon is sent and your option is riding, the client crashes on login!? // FIXME[Haru]: is OPTION_HANBOK intended to be part of this list? And if it is, should the list also include other OPTION_ costumes? - WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->weapon; + WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->look.weapon; WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); diff --git a/src/common/mmo.h b/src/common/mmo.h index 7670a7ac8..1ade0caa9 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -612,7 +612,9 @@ struct mmo_charstatus { int spear_faith, spear_calls; int sword_faith, sword_calls; - short weapon; // enum weapon_type + struct { + short weapon; ///< Weapon view sprite id. + } look; short shield; // view-id short head_top,head_mid,head_bottom; short robe; diff --git a/src/map/battle.c b/src/map/battle.c index 9d67242a2..2861599b8 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -875,7 +875,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, } #else if( skill_id != ASC_BREAKER && weapon ) // Adv Katar Mastery is does not applies to ASC_BREAKER, but other masteries DO apply >_> - if( sd->status.weapon == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0 ) + if (sd->weapontype == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0) damage += damage * (10 + 2 * skill2_lv) / 100; #endif @@ -2032,7 +2032,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 100 + 100 * skill_lv + 100 * (skill_lv / 2); break; case RG_BACKSTAP: - if( sd && sd->status.weapon == W_BOW && battle_config.backstab_bow_penalty ) + if (sd != NULL && sd->weapontype == W_BOW && battle_config.backstab_bow_penalty) skillratio += (200 + 40 * skill_lv) / 2; else skillratio += 200 + 40 * skill_lv; @@ -2053,10 +2053,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case CR_HOLYCROSS: { int ratio = 35 * skill_lv; - #ifdef RENEWAL - if(sd && sd->status.weapon == W_2HSPEAR) - ratio *= 2; - #endif +#ifdef RENEWAL + if (sd != NULL && sd->weapontype == W_2HSPEAR) + ratio *= 2; +#endif skillratio += ratio; break; } @@ -2714,7 +2714,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 2*sc->data[SC_TRUESIGHT]->val1; if( sc->data[SC_LKCONCENTRATION] ) skillratio += sc->data[SC_LKCONCENTRATION]->val2; - if( sd && sd->status.weapon == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0 ) + if (sd != NULL && sd->weapontype == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0) skillratio += skillratio * (10 + 2 * i) / 100; #endif if( (!skill_id || skill_id == KN_AUTOCOUNTER) && sc->data[SC_CRUSHSTRIKE] ){ @@ -3023,7 +3023,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam status_change_end(bl,SC_DEEP_SLEEP,INVALID_TIMER); } if( s_sd && t_sd && sc->data[SC_COLD] && flag&BF_WEAPON ){ - switch(s_sd->status.weapon){ + switch (s_sd->weapontype) { case W_MACE: case W_2HMACE: case W_1HAXE: @@ -3165,7 +3165,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) { sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX); if( src->type == BL_PC ) { - if (s_sd && s_sd->status.weapon != W_BOW) + if (s_sd != NULL && s_sd->weapontype != W_BOW) skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF); } else skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF); @@ -4648,7 +4648,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list short cri = sstatus->cri; if (sd != NULL) { // if show_katar_crit_bonus is enabled, it already done the calculation in status.c - if (!battle_config.show_katar_crit_bonus && sd->status.weapon == W_KATAR) { + if (!battle_config.show_katar_crit_bonus && sd->weapontype == W_KATAR) { cri <<= 1; } @@ -4821,8 +4821,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if ((temp = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0) hitrate += hitrate * ( 2 * temp ) / 100; - if( (sd->status.weapon == W_1HSWORD || sd->status.weapon == W_DAGGER) && - (temp = pc->checkskill(sd, GN_TRAINING_SWORD))>0 ) + if ((sd->weapontype == W_1HSWORD || sd->weapontype == W_DAGGER) && (temp = pc->checkskill(sd, GN_TRAINING_SWORD)) > 0) hitrate += 3 * temp; } @@ -4956,7 +4955,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list (!skill_id && sc && sc->data[SC_HLIF_CHANGE]?4:0)| (sc && sc->data[SC_WEAPONPERFECT]?8:0); if (flag.arrow && sd) - switch(sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: case W_REVOLVER: case W_GATLING: @@ -5582,7 +5581,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if(wd.damage < 1) wd.damage = 1; if(wd.damage2 < 1) wd.damage2 = 1; #endif - } else if(sd->status.weapon == W_KATAR && !skill_id) { //Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2) + } else if (sd->weapontype == W_KATAR && skill_id == 0) { + // Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2) temp = pc->checkskill(sd,TF_DOUBLE); wd.damage2 = wd.damage * (1 + (temp * 2))/100; @@ -5701,7 +5701,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } //Reject Sword bugreport:4493 by Daegaladh if (wd.damage != 0 && tsc != NULL && tsc->data[SC_SWORDREJECT] != NULL - && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->status.weapon == W_2HSWORD) + && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->weapontype == W_2HSWORD) && rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 ) { ATK_RATER(50); @@ -6099,7 +6099,7 @@ bool battle_check_arrows(struct map_session_data *sd) } //Ammo check by Ishizu-chan if (sd->inventory_data[index]) { - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: if (sd->inventory_data[index]->subtype != A_ARROW) { clif->arrow_fail(sd, 0); @@ -6160,7 +6160,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if (sd) { - sd->state.arrow_atk = (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)); + sd->state.arrow_atk = (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE)); if (sd->state.arrow_atk) { if (battle->check_arrows(sd) == false) @@ -6186,7 +6186,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t return ATK_BLOCK; } } - if( tsc && tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src) && (src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->status.weapon == W_FIST ? 1 : 2)) ) + if( tsc && tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src) && (src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->weapontype == W_FIST ? 1 : 2)) ) { uint16 skill_lv = tsc->data[SC_BLADESTOP_WAIT]->val1; int duration = skill->get_time2(MO_BLADESTOP,skill_lv); diff --git a/src/map/clif.c b/src/map/clif.c index 3599640b9..2962aaa8b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -888,7 +888,7 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un } #if PACKETVER < 4 - *rhand = sd->status.weapon; + *rhand = sd->status.look.weapon; *lhand = sd->status.shield; #else if (sd->equip_index[EQI_HAND_R] >= 0 && @@ -9449,7 +9449,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.weapon); + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); #else clif->changelook(&sd->bl,LOOK_WEAPON,0); diff --git a/src/map/pc.c b/src/map/pc.c index 904867f76..c30161a0c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -829,40 +829,40 @@ int pc_calcweapontype(struct map_session_data *sd) // single-hand if(sd->weapontype2 == W_FIST) { - sd->status.weapon = sd->weapontype1; + sd->weapontype = sd->weapontype1; return 1; } if(sd->weapontype1 == W_FIST) { - sd->status.weapon = sd->weapontype2; + sd->weapontype = sd->weapontype2; return 1; } // dual-wield - sd->status.weapon = W_FIST; + sd->weapontype = W_FIST; switch (sd->weapontype1){ case W_DAGGER: switch (sd->weapontype2) { - case W_DAGGER: sd->status.weapon = W_DOUBLE_DD; break; - case W_1HSWORD: sd->status.weapon = W_DOUBLE_DS; break; - case W_1HAXE: sd->status.weapon = W_DOUBLE_DA; break; + case W_DAGGER: sd->weapontype = W_DOUBLE_DD; break; + case W_1HSWORD: sd->weapontype = W_DOUBLE_DS; break; + case W_1HAXE: sd->weapontype = W_DOUBLE_DA; break; } break; case W_1HSWORD: switch (sd->weapontype2) { - case W_DAGGER: sd->status.weapon = W_DOUBLE_DS; break; - case W_1HSWORD: sd->status.weapon = W_DOUBLE_SS; break; - case W_1HAXE: sd->status.weapon = W_DOUBLE_SA; break; + case W_DAGGER: sd->weapontype = W_DOUBLE_DS; break; + case W_1HSWORD: sd->weapontype = W_DOUBLE_SS; break; + case W_1HAXE: sd->weapontype = W_DOUBLE_SA; break; } break; case W_1HAXE: switch (sd->weapontype2) { - case W_DAGGER: sd->status.weapon = W_DOUBLE_DA; break; - case W_1HSWORD: sd->status.weapon = W_DOUBLE_SA; break; - case W_1HAXE: sd->status.weapon = W_DOUBLE_AA; break; + case W_DAGGER: sd->weapontype = W_DOUBLE_DA; break; + case W_1HSWORD: sd->weapontype = W_DOUBLE_SA; break; + case W_1HAXE: sd->weapontype = W_DOUBLE_AA; break; } } // unknown, default to right hand type - if (sd->status.weapon == W_FIST) - sd->status.weapon = sd->weapontype1; + if (sd->weapontype == W_FIST) + sd->weapontype = sd->weapontype1; return 2; } @@ -885,10 +885,13 @@ int pc_setequipindex(struct map_session_data *sd) sd->equip_index[j] = i; if (sd->status.inventory[i].equip & EQP_HAND_R) { - if (sd->inventory_data[i]) + if (sd->inventory_data[i]) { sd->weapontype1 = sd->inventory_data[i]->subtype; - else + sd->status.look.weapon = sd->inventory_data[i]->view_sprite; + } else { sd->weapontype1 = W_FIST; + sd->status.look.weapon = 0; + } } if (sd->status.inventory[i].equip & EQP_HAND_L) { @@ -2486,7 +2489,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { } switch (sd->state.lr_flag) { case 2: - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -2553,7 +2556,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { case SP_ATTACKRANGE: switch (sd->state.lr_flag) { case 2: - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -5940,7 +5943,7 @@ int pc_checkallowskill(struct map_session_data *sd) status_change_end(&sd->bl, scw_list[i], INVALID_TIMER); } - if(sd->sc.data[SC_STRUP] && sd->status.weapon != W_FIST) + if(sd->sc.data[SC_STRUP] && sd->weapontype != W_FIST) // Spurt requires bare hands (feet, in fact xD) status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); @@ -8842,7 +8845,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) case LOOK_BASE: status->set_viewdata(&sd->bl, val); clif->changelook(&sd->bl, LOOK_BASE, sd->vd.class); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); if (sd->vd.cloth_color) clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); if (sd->vd.body_style) @@ -8861,7 +8864,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) } break; case LOOK_WEAPON: - sd->status.weapon=val; + sd->status.look.weapon = val; break; case LOOK_HEAD_BOTTOM: sd->status.head_bottom=val; @@ -9755,12 +9758,15 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, nullpo_retv(sd); if ((!map_no_view(sd->bl.m,EQP_SHADOW_WEAPON) && pos & EQP_SHADOW_WEAPON) || (pos & EQP_HAND_R)) { - if (id != NULL) + if (id != NULL) { sd->weapontype1 = id->subtype; - else + sd->status.look.weapon = id->view_sprite; + } else { sd->weapontype1 = W_FIST; + sd->status.look.weapon = 0; + } pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); } if ((!map_no_view(sd->bl.m,EQP_SHADOW_SHIELD) && pos & EQP_SHADOW_SHIELD) || (pos & EQP_HAND_L)) { @@ -9988,9 +9994,9 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) nullpo_retv(sd); if (pos & EQP_HAND_R) { sd->weapontype1 = W_FIST; - sd->status.weapon = sd->weapontype2; pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + sd->status.look.weapon = 0; + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); if (!battle_config.dancing_weaponswitch_fix) status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. } diff --git a/src/map/pc.h b/src/map/pc.h index c94ec6099..62129b5ae 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -308,7 +308,9 @@ struct map_session_data { short nameid; int64 tick; } item_delay[MAX_ITEMDELAYS]; // [Paradox924X] - short weapontype1,weapontype2; + 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). short disguise; // [Valaris] struct weapon_data right_weapon, left_weapon; @@ -685,8 +687,13 @@ END_ZEROED_BLOCK; #define pc_stop_attack(sd) (unit->stop_attack(&(sd)->bl)) //Weapon check considering dual wielding. -#define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_SINGLE_WEAPON_TYPE? \ - 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon))) +#define pc_check_weapontype(sd, type) ( \ + (type) & ( \ + (sd)->weapontype < MAX_SINGLE_WEAPON_TYPE ? \ + 1 << (sd)->weapontype : \ + (1 << (sd)->weapontype1) | (1 << (sd)->weapontype2) \ + ) \ + ) // clientside display macros (values to the left/right of the "+") #ifdef RENEWAL diff --git a/src/map/script.c b/src/map/script.c index a919467cf..58dd65173 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15519,7 +15519,7 @@ BUILDIN(getlook) type=script_getnum(st,2); switch(type) { case LOOK_HAIR: val = sd->status.hair; break; //1 - case LOOK_WEAPON: val = sd->status.weapon; break; //2 + case LOOK_WEAPON: val = sd->status.look.weapon; break; //2 case LOOK_HEAD_BOTTOM: val = sd->status.head_bottom; break; //3 case LOOK_HEAD_TOP: val = sd->status.head_top; break; //4 case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5 diff --git a/src/map/skill.c b/src/map/skill.c index 1f510e6fe..4649ace42 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -806,7 +806,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; // If a normal attack is a skill, it's splash damage. [Inkfish] if(sd) { // Automatic trigger of Blitz Beat - if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 && + if (pc_isfalcon(sd) && sd->weapontype == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 && rnd()%1000 <= sstatus->luk*3 ) { rate = sd->status.job_level / 10 + 1; skill->castend_damage_id(src,bl,HT_BLITZBEAT,(tempcheckskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*3 ) skill->castend_damage_id(src,bl,RA_WUGSTRIKE,temp,tick,0); // Gank - if(dstmd && sd->status.weapon != W_BOW && + if(dstmd && sd->weapontype != W_BOW && (temp=pc->checkskill(sd,RG_SNATCHER)) > 0 && (temp*15 + 55) + pc->checkskill(sd,TF_STEAL)*10 > rnd()%1000) { if(pc->steal_item(sd,bl,pc->checkskill(sd,TF_STEAL))) @@ -2012,7 +2012,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in if (sd->bonus.unbreakable) rate -= rate*sd->bonus.unbreakable/100; if (where&EQP_WEAPON) { - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_FIST: //Bare fists should not break :P case W_1HAXE: case W_2HAXE: @@ -5917,7 +5917,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SA_LIGHTNINGLOADER: case SA_SEISMICWEAPON: if (dstsd) { - if(dstsd->status.weapon == W_FIST || + if (dstsd->weapontype == W_FIST || (dstsd->sc.count && !dstsd->sc.data[type] && ( //Allow re-enchanting to lengthen time. [Skotlex] dstsd->sc.data[SC_PROPERTYFIRE] || @@ -13391,7 +13391,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id) nullpo_ret(sd); return ( battle_config.arrow_decrement==2 && - (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) && + (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE)) && skill_id != HT_PHANTASMIC && skill->get_type(skill_id) == BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_DAMAGE) && diff --git a/src/map/status.c b/src/map/status.c index 0d2171eac..ed29e85be 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2713,9 +2713,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) sd->left_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype2]; sd->left_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype2]; - if ((pc_isridingpeco(sd) || pc_isridingdragon(sd)) - && (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR) - ) { + if ((pc_isridingpeco(sd) || pc_isridingdragon(sd)) && (sd->weapontype == W_1HSPEAR || sd->weapontype == W_2HSPEAR)) { //When Riding with spear, damage modifier to mid-class becomes //same as versus large size. sd->right_weapon.atkmods[1] = sd->right_weapon.atkmods[2]; @@ -2779,8 +2777,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) // Base batk value is set on status->calc_misc // weapon-type bonus (FIXME: Why is the weapon_atk bonus applied to base attack?) - if (sd->status.weapon < MAX_SINGLE_WEAPON_TYPE && sd->weapon_atk[sd->status.weapon]) - bstatus->batk += sd->weapon_atk[sd->status.weapon]; + if (sd->weapontype < MAX_SINGLE_WEAPON_TYPE && sd->weapon_atk[sd->weapontype]) + bstatus->batk += sd->weapon_atk[sd->weapontype]; // Absolute modifiers from passive skills #ifndef RENEWAL if((skill_lv=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE. @@ -2928,10 +2926,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) #ifndef RENEWAL bstatus->hit += skill_lv; #endif - if(sd->status.weapon == W_BOW) + if (sd->weapontype == W_BOW) bstatus->rhw.range += skill_lv; } - if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE) { + if (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE) { if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0) bstatus->hit += 2*skill_lv; if((skill_lv=pc->checkskill(sd,GS_SNAKEEYE))>0) { @@ -2939,9 +2937,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) bstatus->rhw.range += skill_lv; } } - if( (sd->status.weapon == W_1HAXE || sd->status.weapon == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0 ) + if ((sd->weapontype == W_1HAXE || sd->weapontype == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) bstatus->hit += 3*skill_lv; - if((sd->status.weapon == W_MACE || sd->status.weapon == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) + if ((sd->weapontype == W_MACE || sd->weapontype == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) bstatus->hit += 2*skill_lv; if (pc->checkskill(sd, SU_POWEROFLIFE) > 0) bstatus->hit += 20; @@ -3001,12 +2999,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) // Relative modifiers from passive skills #ifndef RENEWAL_ASPD - if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) + if (sd->weapontype == W_BOOK && (skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK)) > 0) bstatus->aspd_rate -= 5*skill_lv; if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) bstatus->aspd_rate -= 30*skill_lv; - if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 && - (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) + if (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE && (skill_lv=pc->checkskill(sd,GS_SINGLEACTION)) > 0) bstatus->aspd_rate -= ((skill_lv+1)/2) * 10; if (pc_isridingpeco(sd)) bstatus->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); @@ -3896,7 +3893,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } else { st->cri = status->calc_critical(bl, sc, bst->cri + 3*(st->luk - bst->luk), true); } - if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && BL_UCAST(BL_PC, bl)->status.weapon == W_KATAR) { + if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && BL_UCAST(BL_PC, bl)->weapontype == W_KATAR) { st->cri *= 2; } } @@ -4327,11 +4324,11 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) nullpo_ret(st); amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1]; - if ( sd->status.weapon > MAX_SINGLE_WEAPON_TYPE) + if (sd->weapontype > MAX_SINGLE_WEAPON_TYPE) 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]; - switch ( sd->status.weapon ) { + switch (sd->weapontype) { case W_BOW: case W_MUSICAL: case W_WHIP: @@ -4346,15 +4343,15 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) temp = st->dex * st->dex / 5.0f + st->agi * st->agi * 0.5f; } temp = (float)(sqrt(temp) * 0.25f) + 0xc4; - if ( (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0 && sd->status.weapon == W_BOOK ) + if (sd->weapontype == W_BOOK && (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0) val += (skill_lv - 1) / 2 + 1; if ( (skill_lv = pc->checkskill(sd, GS_SINGLEACTION)) > 0 ) val += ((skill_lv + 1) / 2); amotion = ((int)(temp + ((float)(status->calc_aspd(&sd->bl, &sd->sc, 1) + val) * st->agi / 200)) - min(amotion, 200)); #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 + amotion = (sd->weapontype < MAX_SINGLE_WEAPON_TYPE) + ? (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype]) // 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 @@ -4381,7 +4378,7 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_ return 0; if (bl->type == BL_PC) { - switch (BL_UCCAST(BL_PC, bl)->status.weapon) { + switch (BL_UCCAST(BL_PC, bl)->weapontype) { case W_BOW: case W_MUSICAL: case W_WHIP: @@ -5942,7 +5939,7 @@ short status_calc_aspd(struct block_list *bl, struct status_change *sc, short fl if (bl->type != BL_PC) { bonus = sc->data[SC_ASSNCROS]->val2; } else { - switch (BL_UCCAST(BL_PC, bl)->status.weapon) { + switch (BL_UCCAST(BL_PC, bl)->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -6103,7 +6100,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int if (bl->type != BL_PC) { max = sc->data[SC_ASSNCROS]->val2; } else { - switch (BL_UCCAST(BL_PC, bl)->status.weapon) { + switch (BL_UCCAST(BL_PC, bl)->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: -- cgit v1.2.3-70-g09d2 From 20caa41aeae6e49375aeb187c06dc077e330b414 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 06:19:35 +0100 Subject: 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 --- src/char/char.c | 10 +++++----- src/common/mmo.h | 2 +- src/map/clif.c | 4 ++-- src/map/pc.c | 35 ++++++++++++++++++++++++----------- src/map/pc.h | 1 + src/map/script.c | 2 +- src/map/skill.c | 2 +- src/map/status.c | 2 +- 8 files changed, 36 insertions(+), 22 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/char/char.c b/src/char/char.c index 09aa8684b..c02ee33ef 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -461,7 +461,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->option != cp->option) || (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) || - (p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) || + (p->ele_id != cp->ele_id) || (p->look.shield != cp->look.shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) || @@ -490,7 +490,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id, - p->look.weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, + p->look.weapon, p->look.shield, p->head_top, p->head_mid, p->head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size @@ -1095,7 +1095,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.shield, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.look.shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) @@ -1209,7 +1209,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->shield, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->look.shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) @@ -1947,7 +1947,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); WBUFW(buf,62) = p->head_bottom; - WBUFW(buf,64) = p->shield; + WBUFW(buf,64) = p->look.shield; WBUFW(buf,66) = p->head_top; WBUFW(buf,68) = p->head_mid; WBUFW(buf,70) = p->hair_color; diff --git a/src/common/mmo.h b/src/common/mmo.h index 1ade0caa9..4b120e812 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -614,8 +614,8 @@ struct mmo_charstatus { struct { short weapon; ///< Weapon view sprite id. + short shield; ///< Shield view sprite id. } look; - short shield; // view-id short head_top,head_mid,head_bottom; short robe; 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: -- cgit v1.2.3-70-g09d2 From 2b5309e5e393cf3f5fb7678c7e7690aec0511f21 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 06:29:06 +0100 Subject: Move other view-related variables to `sd->status.look` The following variables are now moved to `sd->status.look` (from `sd->status`): `head_top`, `head_mid`, `head_bottom`, `robe` Signed-off-by: Haru --- src/char/char.c | 34 ++++++++++----------- src/common/mmo.h | 10 ++++--- src/map/clif.c | 8 ++--- src/map/pc.c | 90 ++++++++++++++++++++++++++++---------------------------- src/map/script.c | 8 ++--- src/map/status.c | 8 ++--- 6 files changed, 80 insertions(+), 78 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/char/char.c b/src/char/char.c index c02ee33ef..12dc2554a 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -461,9 +461,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->option != cp->option) || (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) || - (p->ele_id != cp->ele_id) || (p->look.shield != cp->look.shield) || (p->head_top != cp->head_top) || - (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || - (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || + (p->ele_id != cp->ele_id) || (p->look.shield != cp->look.shield) || (p->look.head_top != cp->look.head_top) || + (p->look.head_mid != cp->look.head_mid) || (p->look.head_bottom != cp->look.head_bottom) || (p->delete_date != cp->delete_date) || + (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->look.robe != cp->look.robe) || (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) || (p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) ) { @@ -490,11 +490,11 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id, - p->look.weapon, p->look.shield, p->head_top, p->head_mid, p->head_bottom, + p->look.weapon, p->look.shield, p->look.head_top, p->look.head_mid, p->look.head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size - p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter, + p->look.robe,p->slotchange,opt,p->font,p->uniqueitem_counter, p->hotkey_rowshift, p->account_id, p->char_id) ) { @@ -1096,13 +1096,13 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.look.shield, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.look.head_top, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.look.head_mid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p.look.head_bottom, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_USHORT, &p.rename, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p.robe, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p.look.robe, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_LONG, &unban_time, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL) @@ -1210,9 +1210,9 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->look.shield, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->look.head_top, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->look.head_mid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_SHORT, &p->look.head_bottom, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL) @@ -1226,7 +1226,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_INT, &p->fame, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_USHORT, &p->rename, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_SHORT, &p->robe, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_SHORT, &p->look.robe, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UINT, &opt, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UCHAR, &p->font, 0, NULL, NULL) @@ -1946,10 +1946,10 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); - WBUFW(buf,62) = p->head_bottom; + WBUFW(buf,62) = p->look.head_bottom; WBUFW(buf,64) = p->look.shield; - WBUFW(buf,66) = p->head_top; - WBUFW(buf,68) = p->head_mid; + WBUFW(buf,66) = p->look.head_top; + WBUFW(buf,68) = p->look.head_mid; WBUFW(buf,70) = p->hair_color; WBUFW(buf,72) = p->clothes_color; memcpy(WBUFP(buf,74), p->name, NAME_LENGTH); @@ -1973,7 +1973,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { offset += 4; #endif #if PACKETVER >= 20110111 - WBUFL(buf,128) = p->robe; + WBUFL(buf,128) = p->look.robe; offset += 4; #endif #if PACKETVER != 20111116 //2011-11-16 wants 136, ask gravity. diff --git a/src/common/mmo.h b/src/common/mmo.h index 4b120e812..85e0a83ae 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -613,11 +613,13 @@ struct mmo_charstatus { int sword_faith, sword_calls; struct { - short weapon; ///< Weapon view sprite id. - short shield; ///< Shield view sprite id. + short weapon; ///< Weapon view sprite id. + short shield; ///< Shield view sprite id. + short head_top; ///< Top headgear view sprite id. + short head_mid; ///< Middle headgear view sprite id. + short head_bottom; ///< Bottom headgear view sprite id. + short robe; ///< Robe view sprite id. } look; - short head_top,head_mid,head_bottom; - short robe; char name[NAME_LENGTH]; int base_level, job_level; diff --git a/src/map/clif.c b/src/map/clif.c index 77e6d6055..07f394da4 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1491,8 +1491,8 @@ bool clif_spawn(struct block_list *bl) } if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0) clif->spiritcharm(sd); - if (sd->status.robe) - clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA); + if (sd->status.look.robe != 0) + clif->refreshlook(bl, bl->id, LOOK_ROBE, sd->status.look.robe, AREA); } break; case BL_MOB: @@ -4309,8 +4309,8 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->specialeffect_single(bl,421,sd->fd); if (tsd->bg_id != 0 && map->list[tsd->bl.m].flag.battleground) clif->sendbgemblem_single(sd->fd,tsd); - if (tsd->status.robe) - clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); + if (tsd->status.look.robe != 0) + clif->refreshlook(&sd->bl, bl->id, LOOK_ROBE, tsd->status.look.robe, SELF); } break; case BL_MER: // Devotion Effects diff --git a/src/map/pc.c b/src/map/pc.c index a8a715a70..5948a3cf7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8835,10 +8835,10 @@ int pc_equiplookall(struct map_session_data *sd) clif->changelook(&sd->bl,LOOK_WEAPON,0); clif->changelook(&sd->bl,LOOK_SHOES,0); - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); - clif->changelook(&sd->bl,LOOK_ROBE, sd->status.robe); + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); return 0; } @@ -8876,13 +8876,13 @@ int pc_changelook(struct map_session_data *sd,int type,int val) sd->status.look.weapon = val; break; case LOOK_HEAD_BOTTOM: - sd->status.head_bottom=val; + sd->status.look.head_bottom = val; break; case LOOK_HEAD_TOP: - sd->status.head_top=val; + sd->status.look.head_top = val; break; case LOOK_HEAD_MID: - sd->status.head_mid=val; + sd->status.look.head_mid = val; break; case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex] val = cap_value(val, MIN_HAIR_COLOR, MAX_HAIR_COLOR); @@ -8905,7 +8905,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) case LOOK_SHOES: break; case LOOK_ROBE: - sd->status.robe = val; + sd->status.look.robe = val; break; case LOOK_BODY2: val = cap_value(val, MIN_BODY_STYLE, MAX_BODY_STYLE); @@ -9801,57 +9801,57 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, //causes client to redraw item on top of itself. (suggested by Lupus) if (!map_no_view(sd->bl.m,EQP_HEAD_LOW) && pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))) - sd->status.head_bottom = id->view_sprite; + sd->status.look.head_bottom = id->view_sprite; else - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (!map_no_view(sd->bl.m,EQP_HEAD_TOP) && pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { if (id) - sd->status.head_top = id->view_sprite; + sd->status.look.head_top = id->view_sprite; else - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (!map_no_view(sd->bl.m,EQP_HEAD_MID) && pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { if (id && !(pos&EQP_HEAD_TOP)) - sd->status.head_mid = id->view_sprite; + sd->status.look.head_mid = id->view_sprite; else - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_TOP) && pos & EQP_COSTUME_HEAD_TOP) { if (id){ - sd->status.head_top = id->view_sprite; + sd->status.look.head_top = id->view_sprite; } else - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_MID) && pos & EQP_COSTUME_HEAD_MID) { if(id && !(pos&EQP_HEAD_TOP)){ - sd->status.head_mid = id->view_sprite; + sd->status.look.head_mid = id->view_sprite; } else - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_LOW) && pos & EQP_COSTUME_HEAD_LOW) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){ - sd->status.head_bottom = id->view_sprite; + sd->status.look.head_bottom = id->view_sprite; } else - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (!map_no_view(sd->bl.m,EQP_SHOES) && pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); if (!map_no_view(sd->bl.m,EQP_GARMENT) && pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) { - sd->status.robe = id ? id->view_sprite : 0; - clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); + sd->status.look.robe = id ? id->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); } if (!map_no_view(sd->bl.m,EQP_COSTUME_GARMENT) && pos & EQP_COSTUME_GARMENT) { - sd->status.robe = id ? id->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); + sd->status.look.robe = id ? id->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); } } @@ -10020,44 +10020,44 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) 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; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (pos & EQP_COSTUME_HEAD_TOP) { - sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (pos & EQP_COSTUME_HEAD_MID) { - sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (pos & EQP_COSTUME_HEAD_LOW) { - sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); if (pos & EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) { - sd->status.robe = 0; + sd->status.look.robe = 0; clif->changelook(&sd->bl, LOOK_ROBE, 0); } if (pos & EQP_COSTUME_GARMENT) { - sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); + sd->status.look.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); } } diff --git a/src/map/script.c b/src/map/script.c index 09f6377ef..5ce581db6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15520,14 +15520,14 @@ BUILDIN(getlook) switch(type) { case LOOK_HAIR: val = sd->status.hair; break; //1 case LOOK_WEAPON: val = sd->status.look.weapon; break; //2 - case LOOK_HEAD_BOTTOM: val = sd->status.head_bottom; break; //3 - case LOOK_HEAD_TOP: val = sd->status.head_top; break; //4 - case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5 + case LOOK_HEAD_BOTTOM: val = sd->status.look.head_bottom; break; //3 + case LOOK_HEAD_TOP: val = sd->status.look.head_top; break; //4 + case LOOK_HEAD_MID: val = sd->status.look.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.look.shield; break; //8 case LOOK_SHOES: break; //9 - case LOOK_ROBE: val = sd->status.robe; break; //12 + case LOOK_ROBE: val = sd->status.look.robe; break; //12 case LOOK_BODY2: val=sd->status.body; break; //13 } diff --git a/src/map/status.c b/src/map/status.c index 733eb5f6f..e04769e3f 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6864,13 +6864,13 @@ void status_set_viewdata(struct block_list *bl, int 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; - sd->vd.head_bottom = sd->status.head_bottom; + sd->vd.head_top = sd->status.look.head_top; + sd->vd.head_mid = sd->status.look.head_mid; + sd->vd.head_bottom = sd->status.look.head_bottom; sd->vd.hair_style = cap_value(sd->status.hair,0,battle_config.max_hair_style); sd->vd.hair_color = cap_value(sd->status.hair_color,0,battle_config.max_hair_color); sd->vd.cloth_color = cap_value(sd->status.clothes_color,0,battle_config.max_cloth_color); - sd->vd.robe = sd->status.robe; + sd->vd.robe = sd->status.look.robe; sd->vd.body_style = sd->status.body; sd->vd.sex = sd->status.sex; -- cgit v1.2.3-70-g09d2 From 3745f1658aab4a5ffe504a5660b76402f2e2c6d6 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 20:52:14 +0200 Subject: Fix a typo in the constant ITEMUPPER_THIRDUPPER Was: ITEMUPPER_THURDUPPER Signed-off-by: Haru --- src/map/itemdb.h | 2 +- src/map/pc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 980e8730e..d2d3b6c73 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -337,7 +337,7 @@ enum item_class_upper { ITEMUPPER_UPPER = 0x02, ITEMUPPER_BABY = 0x04, ITEMUPPER_THIRD = 0x08, - ITEMUPPER_THURDUPPER = 0x10, + ITEMUPPER_THIRDUPPER = 0x10, ITEMUPPER_THIRDBABY = 0x20, ITEMUPPER_ALL = 0x3f, // Sum of all the above }; diff --git a/src/map/pc.c b/src/map/pc.c index 5948a3cf7..609a4ec56 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5032,7 +5032,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; } // Upper third classes - if ((item->class_upper & ITEMUPPER_THURDUPPER) != 0) { + if ((item->class_upper & ITEMUPPER_THIRDUPPER) != 0) { if ((sd->job & JOBL_THIRD) != 0 && (sd->job & JOBL_UPPER) != 0) break; } -- cgit v1.2.3-70-g09d2