From c2d3457d574c2a9bdf9ba4bf799e86c490f9a2c3 Mon Sep 17 00:00:00 2001 From: Smokexyz Date: Tue, 11 Apr 2017 16:13:51 +0800 Subject: Fixes an issue where the unequipped items with options do not re-calculate status. --- src/map/pc.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/map/pc.c b/src/map/pc.c index 2cf5d75b4..120403a2c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9987,7 +9987,7 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) int pc_unequipitem(struct map_session_data *sd,int n,int flag) { int i,iflag; - bool status_cacl = false; + bool status_calc = false; int pos; nullpo_ret(sd); @@ -10043,13 +10043,12 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) iflag = sd->npc_item_flag; /* check for combos (MUST be before status_calc_pc) */ - if ( sd->inventory_data[n] ) { + if ( sd->inventory_data[n] != NULL ) { if( sd->inventory_data[n]->combos_count ) { if( pc->removecombo(sd,sd->inventory_data[n]) ) - status_cacl = true; - } if(itemdb_isspecial(sd->status.inventory[n].card[0])) - ; //No cards - else { + status_calc = true; + } + if(itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { for( i = 0; i < sd->inventory_data[n]->slot; i++ ) { struct item_data *data; if (!sd->status.inventory[n].card[i]) @@ -10057,14 +10056,26 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { if( data->combos_count ) { if( pc->removecombo(sd,data) ) - status_cacl = true; + status_calc = true; } } } } + /* Item Options checking */ + for (i = 0; i < MAX_ITEM_OPTIONS; i++) { + struct item_option *ito = NULL; + int16 item_option = sd->status.inventory[n].option[i].index; + + if (item_option <= 0) + continue; + if ((ito = itemdb->option_exists(sd->status.inventory[n].option[i].index)) == NULL) + continue; + + status_calc = true; + } } - if(flag&PCUNEQUIPITEM_RECALC || status_cacl) { + if(flag&PCUNEQUIPITEM_RECALC || status_calc) { pc->checkallowskill(sd); status_calc_pc(sd,SCO_NONE); } -- cgit v1.2.3-70-g09d2 From 67de09ecaaaf46dde61e03bb98ed65b99b97bbf9 Mon Sep 17 00:00:00 2001 From: Smokexyz Date: Tue, 11 Apr 2017 16:31:20 +0800 Subject: Code-styling fixes to pc_unequipitem() in pc.c --- src/map/pc.c | 99 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/map/pc.c b/src/map/pc.c index 120403a2c..fc0f21cdb 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9986,51 +9986,51 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) *------------------------------------------*/ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { - int i,iflag; + int i, iflag; bool status_calc = false; int pos; + nullpo_ret(sd); - if( n < 0 || n >= MAX_INVENTORY ) { - clif->unequipitemack(sd,0,0,UIA_FAIL); + if (n < 0 || n >= MAX_INVENTORY) { + clif->unequipitemack(sd, 0, 0, UIA_FAIL); return 0; } // if player is berserk then cannot unequip - if (!(flag&PCUNEQUIPITEM_FORCE) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP]) ) - { - clif->unequipitemack(sd,n,0,UIA_FAIL); + if (!(flag & PCUNEQUIPITEM_FORCE) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP])) { + clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - if( !(flag&PCUNEQUIPITEM_FORCE) && sd->sc.count && sd->sc.data[SC_KYOUGAKU] ) - { - clif->unequipitemack(sd,n,0,UIA_FAIL); + if (!(flag & PCUNEQUIPITEM_FORCE) && sd->sc.count && sd->sc.data[SC_KYOUGAKU]) { + clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - if(battle_config.battle_log) + if (battle_config.battle_log) ShowInfo("unequip %d %x:%x\n", n, (unsigned int)(pc->equippoint(sd, n)), sd->status.inventory[n].equip); - if(!sd->status.inventory[n].equip){ //Nothing to unequip - clif->unequipitemack(sd,n,0,UIA_FAIL); + if (sd->status.inventory[n].equip == 0) { //Nothing to unequip + clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - for(i=0;istatus.inventory[n].equip & pc->equip_pos[i]) + + for (i = 0; i < EQI_MAX; i++) { + if (sd->status.inventory[n].equip & pc->equip_pos[i]) sd->equip_index[i] = -1; } pos = sd->status.inventory[n].equip; pc->unequipitem_pos(sd, n, pos); - clif->unequipitemack(sd,n,pos,UIA_SUCCESS); + clif->unequipitemack(sd, n, pos, UIA_SUCCESS); - 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 ((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!) + skill->enchant_elemental_end(&sd->bl, -1); - if(pos & 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); @@ -10039,23 +10039,23 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) if( sd->state.autobonus&pos ) sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish] - sd->status.inventory[n].equip=0; + sd->status.inventory[n].equip = 0; iflag = sd->npc_item_flag; /* check for combos (MUST be before status_calc_pc) */ - if ( sd->inventory_data[n] != NULL ) { - if( sd->inventory_data[n]->combos_count ) { - if( pc->removecombo(sd,sd->inventory_data[n]) ) + if (sd->inventory_data[n] != NULL) { + if (sd->inventory_data[n]->combos_count) { + if (pc->removecombo(sd, sd->inventory_data[n])) status_calc = true; } - if(itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { - for( i = 0; i < sd->inventory_data[n]->slot; i++ ) { + if (itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { + for (i = 0; i < sd->inventory_data[n]->slot; i++) { struct item_data *data; - if (!sd->status.inventory[n].card[i]) + if (sd->status.inventory[n].card[i] == 0) continue; - if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if( data->combos_count ) { - if( pc->removecombo(sd,data) ) + if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) { + if (data->combos_count) { + if (pc->removecombo(sd, data)) status_calc = true; } } @@ -10075,49 +10075,48 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) } } - if(flag&PCUNEQUIPITEM_RECALC || status_calc) { + if (flag & PCUNEQUIPITEM_RECALC || status_calc) { pc->checkallowskill(sd); - status_calc_pc(sd,SCO_NONE); + status_calc_pc(sd, SCO_NONE); } - if(sd->sc.data[SC_CRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) + if (sd->sc.data[SC_CRUCIS] && battle->check_undead(sd->battle_status.race, sd->battle_status.def_ele) == false) status_change_end(&sd->bl, SC_CRUCIS, INVALID_TIMER); //OnUnEquip script [Skotlex] - if (sd->inventory_data[n]) { - if (sd->inventory_data[n]->unequip_script) { - if ( battle_config.unequip_restricted_equipment & 1 ) { - ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid); - if ( i == map->list[sd->bl.m].zone->disabled_items_count ) + if (sd->inventory_data[n] != NULL) { + if (sd->inventory_data[n]->unequip_script != NULL) { + if (battle_config.unequip_restricted_equipment & 1) { + ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid); + if (i == map->list[sd->bl.m].zone->disabled_items_count) script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); } else script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); } - if(itemdb_isspecial(sd->status.inventory[n].card[0])) - ; //No cards - else { - for( i = 0; i < sd->inventory_data[n]->slot; i++ ) { - struct item_data *data; - if (!sd->status.inventory[n].card[i]) + if (itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { + for (i = 0; i < sd->inventory_data[n]->slot; i++) { + struct item_data *data = NULL; + if (sd->status.inventory[n].card[i] == 0) continue; - if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if ( data->unequip_script ) { - if ( battle_config.unequip_restricted_equipment & 2 ) { + if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) { + if (data->unequip_script) { + if (battle_config.unequip_restricted_equipment & 2) { int j; - ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]); - if ( j == map->list[sd->bl.m].zone->disabled_items_count ) + ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]); + if (j == map->list[sd->bl.m].zone->disabled_items_count) script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); - } - else + } else { script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); + } } } } } } + sd->npc_item_flag = iflag; return 1; -- cgit v1.2.3-70-g09d2 From 0aa15b4510384bbbf0392399bf1f97fd547c03fb Mon Sep 17 00:00:00 2001 From: Smokexyz Date: Sun, 16 Apr 2017 14:15:19 +0800 Subject: Fix issue #1685 Where the item in a vending list would display incorrect option information. --- src/map/clif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index 8de18da30..8d4c63d26 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6417,7 +6417,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven WFIFOB(fd,21+i*item_length) = sd->status.cart[index].refine; clif->addcards(WFIFOP(fd,22+i*item_length), &sd->status.cart[index]); #if PACKETVER >= 20150226 - clif->add_item_options(WFIFOP(fd,30+22+i*item_length), &sd->status.cart[index]); + clif->add_item_options(WFIFOP(fd,30+i*item_length), &sd->status.cart[index]); #endif } WFIFOSET(fd,WFIFOW(fd,2)); -- cgit v1.2.3-70-g09d2 From ccb43c9d84e6d6a8fff85cc11c4396ea343da3b5 Mon Sep 17 00:00:00 2001 From: Smokexyz Date: Mon, 24 Apr 2017 18:54:38 +0800 Subject: Followup 0aa15b4 with style fixes. --- src/map/clif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index 8d4c63d26..236297dba 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4149,7 +4149,7 @@ void clif_storageitemadded(struct map_session_data* sd, struct item* i, int inde WFIFOB(fd,12+offset) = i->refine; //refine clif->addcards(WFIFOP(fd,13+offset), i); #if PACKETVER >= 20150226 - clif->add_item_options(WFIFOP(fd,21+offset), i); + clif->add_item_options(WFIFOP(fd, 21 + offset), i); #endif WFIFOSET(fd,packet_len(storageaddType)); } @@ -6223,7 +6223,7 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail) WBUFB(buf,12+offset)=sd->status.cart[n].refine; clif->addcards(WBUFP(buf,13+offset), &sd->status.cart[n]); #if PACKETVER >= 20150226 - clif->add_item_options(WBUFP(buf,21+offset), &sd->status.cart[n]); + clif->add_item_options(WBUFP(buf, 21 + offset), &sd->status.cart[n]); #endif WFIFOSET(fd,packet_len(cartaddType)); } @@ -6351,7 +6351,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven WFIFOB(fd,offset+13+i*item_length) = vsd->status.cart[index].refine; clif->addcards(WFIFOP(fd,offset+14+i*item_length), &vsd->status.cart[index]); #if PACKETVER >= 20150226 - clif->add_item_options(WFIFOP(fd,offset+22+i*item_length), &vsd->status.cart[index]); + clif->add_item_options(WFIFOP(fd, offset + 22 + i * item_length), &vsd->status.cart[index]); #endif } WFIFOSET(fd,WFIFOW(fd,2)); @@ -6417,7 +6417,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven WFIFOB(fd,21+i*item_length) = sd->status.cart[index].refine; clif->addcards(WFIFOP(fd,22+i*item_length), &sd->status.cart[index]); #if PACKETVER >= 20150226 - clif->add_item_options(WFIFOP(fd,30+i*item_length), &sd->status.cart[index]); + clif->add_item_options(WFIFOP(fd, 30 + i * item_length), &sd->status.cart[index]); #endif } WFIFOSET(fd,WFIFOW(fd,2)); -- cgit v1.2.3-70-g09d2