From e697df2275b17694436d0efe05ebaf5bb8617361 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Nov 2014 16:47:24 +0300 Subject: Split functions pc_equipitem and pc_unequipitem. --- src/map/pc.c | 286 +++++++++++++++++++++++++++++++---------------------------- src/map/pc.h | 2 + 2 files changed, 152 insertions(+), 136 deletions(-) diff --git a/src/map/pc.c b/src/map/pc.c index 9af5ee5ff..c5d1eba19 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8825,6 +8825,89 @@ int pc_load_combo(struct map_session_data *sd) { } return ret; } + +void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int pos) +{ + if (pos & (EQP_HAND_R|EQP_SHADOW_WEAPON)) { + if(id) + sd->weapontype1 = id->look; + else + sd->weapontype1 = 0; + pc->calcweapontype(sd); + clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + } + if (pos & (EQP_HAND_L|EQP_SHADOW_SHIELD)) { + if (id) { + 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; + } + } else + sd->status.shield = sd->weapontype2 = 0; + pc->calcweapontype(sd); + clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + } + //Added check to prevent sending the same look on multiple slots -> + //causes client to redraw item on top of itself. (suggested by Lupus) + if (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; + else + sd->status.head_bottom = 0; + clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + } + if (pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { + if (id) + sd->status.head_top = id->look; + else + sd->status.head_top = 0; + clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + } + if (pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { + if (id && !(pos&EQP_HEAD_TOP)) + sd->status.head_mid = id->look; + else + sd->status.head_mid = 0; + clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + } + if (pos & EQP_COSTUME_HEAD_TOP) { + if (id){ + sd->status.head_top = id->look; + } else + sd->status.head_top = 0; + clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + } + if (pos & EQP_COSTUME_HEAD_MID) { + if(id && !(pos&EQP_HEAD_TOP)){ + sd->status.head_mid = id->look; + } else + sd->status.head_mid = 0; + clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + } + if (pos & EQP_COSTUME_HEAD_LOW) { + if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){ + sd->status.head_bottom = id->look; + } else + sd->status.head_bottom = 0; + clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.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 = id ? id->look : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); + } + + if (pos & EQP_COSTUME_GARMENT) { + sd->status.robe = id ? id->look : 0; + clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); + } +} + /*========================================== * Equip item on player sd at req_pos from inventory index n *------------------------------------------*/ @@ -8914,86 +8997,8 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) sd->status.inventory[n].equip=pos; - if(pos & (EQP_HAND_R|EQP_SHADOW_WEAPON)) { - if(id) - sd->weapontype1 = id->look; - else - sd->weapontype1 = 0; - pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); - } - if(pos & (EQP_HAND_L|EQP_SHADOW_SHIELD)) { - if(id) { - 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; - } - } else - sd->status.shield = sd->weapontype2 = 0; - pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); - } - //Added check to prevent sending the same look on multiple slots -> - //causes client to redraw item on top of itself. (suggested by Lupus) - if(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; - else - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); - } - if(pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { - if(id) - sd->status.head_top = id->look; - else - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); - } - if(pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { - if(id && !(pos&EQP_HEAD_TOP)) - sd->status.head_mid = id->look; - else - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); - } - if(pos & EQP_COSTUME_HEAD_TOP) { - if(id){ - sd->status.head_top = id->look; - } else - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); - } - if(pos & EQP_COSTUME_HEAD_MID) { - if(id && !(pos&EQP_HEAD_TOP)){ - sd->status.head_mid = id->look; - } else - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); - } - if(pos & EQP_COSTUME_HEAD_LOW) { - if(id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){ - sd->status.head_bottom = id->look; - } else - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.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 = id ? id->look : 0; - clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); - } + pc->equipitem_pos(sd, id, pos); - if(pos & EQP_COSTUME_GARMENT) { - sd->status.robe = id ? id->look : 0; - clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); - } - - pc->checkallowskill(sd); //Check if status changes should be halted. iflag = sd->npc_item_flag; @@ -9043,6 +9048,63 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) return 0; } +void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) +{ + if (pos & EQP_HAND_R) { + sd->weapontype1 = 0; + sd->status.weapon = sd->weapontype2; + pc->calcweapontype(sd); + clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + if (!battle_config.dancing_weaponswitch_fix) + status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. + } + if (pos & EQP_HAND_L) { + sd->status.shield = sd->weapontype2 = 0; + pc->calcweapontype(sd); + clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.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); + } + 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); + } + 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); + } + + 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; + 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; + 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; + clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.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; + 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)]->look : 0; + clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); + } +} + /*========================================== * Called when attemting to unequip an item from player * type: @@ -9053,6 +9115,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) int pc_unequipitem(struct map_session_data *sd,int n,int flag) { int i,iflag; bool status_cacl = false; + int pos; nullpo_ret(sd); if( n < 0 || n >= MAX_INVENTORY ) { @@ -9085,73 +9148,22 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { sd->equip_index[i] = -1; } - if(sd->status.inventory[n].equip & EQP_HAND_R) { - sd->weapontype1 = 0; - sd->status.weapon = sd->weapontype2; - pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); - if( !battle_config.dancing_weaponswitch_fix ) - status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. - } - if(sd->status.inventory[n].equip & EQP_HAND_L) { - sd->status.shield = sd->weapontype2 = 0; - pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); - } - if(sd->status.inventory[n].equip & 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); - } - if(sd->status.inventory[n].equip & 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); - } - if(sd->status.inventory[n].equip & 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); - } - - if(sd->status.inventory[n].equip & 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; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); - } - - if(sd->status.inventory[n].equip & 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; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); - } - - if(sd->status.inventory[n].equip & 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; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); - } + pos = sd->status.inventory[n].equip; + pc->unequipitem_pos(sd, n, pos); - if(sd->status.inventory[n].equip & EQP_SHOES) - clif->changelook(&sd->bl,LOOK_SHOES,0); - - if( sd->status.inventory[n].equip&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) { - sd->status.robe = 0; - clif->changelook(&sd->bl, LOOK_ROBE, 0); - } - - if(sd->status.inventory[n].equip & EQP_COSTUME_GARMENT) { - sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0; - clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); - } - - clif->unequipitemack(sd,n,sd->status.inventory[n].equip,UIA_SUCCESS); + clif->unequipitemack(sd,n,pos,UIA_SUCCESS); - if((sd->status.inventory[n].equip & EQP_ARMS) && + if((pos & EQP_ARMS) && sd->weapontype1 == 0 && sd->weapontype2 == 0 && (!sd->sc.data[SC_TK_SEVENWIND] || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!) skill->enchant_elemental_end(&sd->bl,-1); - if(sd->status.inventory[n].equip & EQP_ARMOR) { + if(pos & EQP_ARMOR) { // On Armor Change... status_change_end(&sd->bl, SC_BENEDICTIO, INVALID_TIMER); status_change_end(&sd->bl, SC_ARMOR_RESIST, INVALID_TIMER); } - if( sd->state.autobonus&sd->status.inventory[n].equip ) + if( sd->state.autobonus&pos ) sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish] sd->status.inventory[n].equip=0; @@ -11028,7 +11040,9 @@ void pc_defaults(void) { pc->resetfeel = pc_resetfeel; pc->resethate = pc_resethate; pc->equipitem = pc_equipitem; + pc->equipitem_pos = pc_equipitem_pos; pc->unequipitem = pc_unequipitem; + pc->unequipitem_pos = pc_unequipitem_pos; pc->checkitem = pc_checkitem; pc->useitem = pc_useitem; diff --git a/src/map/pc.h b/src/map/pc.h index aa2bb0e74..a17300701 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -883,7 +883,9 @@ struct pc_interface { int (*resetfeel) (struct map_session_data *sd); int (*resethate) (struct map_session_data *sd); int (*equipitem) (struct map_session_data *sd,int n,int req_pos); + void (*equipitem_pos) (struct map_session_data *sd, struct item_data *id, int pos); int (*unequipitem) (struct map_session_data *sd,int n,int flag); + void (*unequipitem_pos) (struct map_session_data *sd, int n, int pos); int (*checkitem) (struct map_session_data *sd); int (*useitem) (struct map_session_data *sd,int n); -- cgit v1.2.3-60-g2f50 From 727c785081bd045f2f3e7ccb8f2d825d1a777998 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Nov 2014 17:11:49 +0300 Subject: update HPM hooks. --- .../HPMHooking/HPMHooking_map.HPMHooksCore.inc | 8 ++++ .../HPMHooking/HPMHooking_map.HookingPoints.inc | 2 + src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 52 ++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 9c616ba00..5448186d0 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -3697,8 +3697,12 @@ struct { struct HPMHookPoint *HP_pc_resethate_post; struct HPMHookPoint *HP_pc_equipitem_pre; struct HPMHookPoint *HP_pc_equipitem_post; + struct HPMHookPoint *HP_pc_equipitem_pos_pre; + struct HPMHookPoint *HP_pc_equipitem_pos_post; struct HPMHookPoint *HP_pc_unequipitem_pre; struct HPMHookPoint *HP_pc_unequipitem_post; + struct HPMHookPoint *HP_pc_unequipitem_pos_pre; + struct HPMHookPoint *HP_pc_unequipitem_pos_post; struct HPMHookPoint *HP_pc_checkitem_pre; struct HPMHookPoint *HP_pc_checkitem_post; struct HPMHookPoint *HP_pc_useitem_pre; @@ -8760,8 +8764,12 @@ struct { int HP_pc_resethate_post; int HP_pc_equipitem_pre; int HP_pc_equipitem_post; + int HP_pc_equipitem_pos_pre; + int HP_pc_equipitem_pos_post; int HP_pc_unequipitem_pre; int HP_pc_unequipitem_post; + int HP_pc_unequipitem_pos_pre; + int HP_pc_unequipitem_pos_post; int HP_pc_checkitem_pre; int HP_pc_checkitem_post; int HP_pc_useitem_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 545f07d01..af376fe05 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1879,7 +1879,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->resetfeel, HP_pc_resetfeel) }, { HP_POP(pc->resethate, HP_pc_resethate) }, { HP_POP(pc->equipitem, HP_pc_equipitem) }, + { HP_POP(pc->equipitem_pos, HP_pc_equipitem_pos) }, { HP_POP(pc->unequipitem, HP_pc_unequipitem) }, + { HP_POP(pc->unequipitem_pos, HP_pc_unequipitem_pos) }, { HP_POP(pc->checkitem, HP_pc_checkitem) }, { HP_POP(pc->useitem, HP_pc_useitem) }, { HP_POP(pc->skillatk_bonus, HP_pc_skillatk_bonus) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 35e98693c..954436e94 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -49467,6 +49467,32 @@ int HP_pc_equipitem(struct map_session_data *sd, int n, int req_pos) { } return retVal___; } +void HP_pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int pos) { + int hIndex = 0; + if( HPMHooks.count.HP_pc_equipitem_pos_pre ) { + void (*preHookFunc) (struct map_session_data *sd, struct item_data *id, int *pos); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_equipitem_pos_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_pc_equipitem_pos_pre[hIndex].func; + preHookFunc(sd, id, &pos); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.pc.equipitem_pos(sd, id, pos); + } + if( HPMHooks.count.HP_pc_equipitem_pos_post ) { + void (*postHookFunc) (struct map_session_data *sd, struct item_data *id, int *pos); + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_equipitem_pos_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_pc_equipitem_pos_post[hIndex].func; + postHookFunc(sd, id, &pos); + } + } + return; +} int HP_pc_unequipitem(struct map_session_data *sd, int n, int flag) { int hIndex = 0; int retVal___ = 0; @@ -49494,6 +49520,32 @@ int HP_pc_unequipitem(struct map_session_data *sd, int n, int flag) { } return retVal___; } +void HP_pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) { + int hIndex = 0; + if( HPMHooks.count.HP_pc_unequipitem_pos_pre ) { + void (*preHookFunc) (struct map_session_data *sd, int *n, int *pos); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_unequipitem_pos_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_pc_unequipitem_pos_pre[hIndex].func; + preHookFunc(sd, &n, &pos); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.pc.unequipitem_pos(sd, n, pos); + } + if( HPMHooks.count.HP_pc_unequipitem_pos_post ) { + void (*postHookFunc) (struct map_session_data *sd, int *n, int *pos); + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_unequipitem_pos_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_pc_unequipitem_pos_post[hIndex].func; + postHookFunc(sd, &n, &pos); + } + } + return; +} int HP_pc_checkitem(struct map_session_data *sd) { int hIndex = 0; int retVal___ = 0; -- cgit v1.2.3-60-g2f50