|
@@ -537,6 +537,10 @@ bool pc_can_sell_item(struct map_session_data *sd, struct item *item, enum npc_s
|
|
if (!battle_config.rental_transaction && item->expire_time)
|
|
if (!battle_config.rental_transaction && item->expire_time)
|
|
return false; // Cannot Sell Rental Items
|
|
return false; // Cannot Sell Rental Items
|
|
|
|
|
|
|
|
+ if( item->equipSwitch ){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
switch (shoptype) {
|
|
switch (shoptype) {
|
|
case NPCTYPE_SHOP:
|
|
case NPCTYPE_SHOP:
|
|
if (item->bound && battle_config.allow_bound_sell&ISR_BOUND_SELLABLE && (
|
|
if (item->bound && battle_config.allow_bound_sell&ISR_BOUND_SELLABLE && (
|
|
@@ -771,8 +775,10 @@ void pc_setequipindex(struct map_session_data *sd)
|
|
|
|
|
|
nullpo_retv(sd);
|
|
nullpo_retv(sd);
|
|
|
|
|
|
- for (i = 0; i < EQI_MAX; i++)
|
|
|
|
|
|
+ for (i = 0; i < EQI_MAX; i++){
|
|
sd->equip_index[i] = -1;
|
|
sd->equip_index[i] = -1;
|
|
|
|
+ sd->equip_switch_index[i] = -1;
|
|
|
|
+ }
|
|
|
|
|
|
for (i = 0; i < MAX_INVENTORY; i++) {
|
|
for (i = 0; i < MAX_INVENTORY; i++) {
|
|
if (sd->inventory.u.items_inventory[i].nameid <= 0)
|
|
if (sd->inventory.u.items_inventory[i].nameid <= 0)
|
|
@@ -797,6 +803,13 @@ void pc_setequipindex(struct map_session_data *sd)
|
|
sd->weapontype2 = 0;
|
|
sd->weapontype2 = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (sd->inventory.u.items_inventory[i].equipSwitch) {
|
|
|
|
+ for (uint8 j = 0; j < EQI_MAX; j++) {
|
|
|
|
+ if (sd->inventory.u.items_inventory[i].equipSwitch & equip_bitmask[j]) {
|
|
|
|
+ sd->equip_switch_index[j] = i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
pc_calcweapontype(sd);
|
|
pc_calcweapontype(sd);
|
|
}
|
|
}
|
|
@@ -1220,6 +1233,7 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
|
|
memset(&sd->storage, 0, sizeof(struct s_storage));
|
|
memset(&sd->storage, 0, sizeof(struct s_storage));
|
|
memset(&sd->premiumStorage, 0, sizeof(struct s_storage));
|
|
memset(&sd->premiumStorage, 0, sizeof(struct s_storage));
|
|
memset(&sd->equip_index, -1, sizeof(sd->equip_index));
|
|
memset(&sd->equip_index, -1, sizeof(sd->equip_index));
|
|
|
|
+ memset(&sd->equip_switch_index, -1, sizeof(sd->equip_switch_index));
|
|
|
|
|
|
if( pc_isinvisible(sd) && !pc_can_use_command( sd, "hide", COMMAND_ATCOMMAND ) ){
|
|
if( pc_isinvisible(sd) && !pc_can_use_command( sd, "hide", COMMAND_ATCOMMAND ) ){
|
|
sd->status.option &= ~OPTION_INVISIBLE;
|
|
sd->status.option &= ~OPTION_INVISIBLE;
|
|
@@ -4586,6 +4600,8 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p
|
|
sd->inventory.u.items_inventory[i].equip = 0;
|
|
sd->inventory.u.items_inventory[i].equip = 0;
|
|
if( item->favorite )
|
|
if( item->favorite )
|
|
sd->inventory.u.items_inventory[i].favorite = 0;
|
|
sd->inventory.u.items_inventory[i].favorite = 0;
|
|
|
|
+ if( item->equipSwitch )
|
|
|
|
+ sd->inventory.u.items_inventory[i].equipSwitch = 0;
|
|
|
|
|
|
sd->inventory.u.items_inventory[i].amount = amount;
|
|
sd->inventory.u.items_inventory[i].amount = amount;
|
|
sd->inventory_data[i] = id;
|
|
sd->inventory_data[i] = id;
|
|
@@ -4682,6 +4698,9 @@ bool pc_dropitem(struct map_session_data *sd,int n,int amount)
|
|
)
|
|
)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
+ if( sd->inventory.u.items_inventory[n].equipSwitch )
|
|
|
|
+ return false;
|
|
|
|
+
|
|
if( map_getmapflag(sd->bl.m, MF_NODROP) )
|
|
if( map_getmapflag(sd->bl.m, MF_NODROP) )
|
|
{
|
|
{
|
|
clif_displaymessage (sd->fd, msg_txt(sd,271));
|
|
clif_displaymessage (sd->fd, msg_txt(sd,271));
|
|
@@ -5122,6 +5141,7 @@ unsigned char pc_cart_additem(struct map_session_data *sd,struct item *item,int
|
|
clif_cart_additem(sd,i,amount,0);
|
|
clif_cart_additem(sd,i,amount,0);
|
|
}
|
|
}
|
|
sd->cart.u.items_cart[i].favorite = 0; // clear
|
|
sd->cart.u.items_cart[i].favorite = 0; // clear
|
|
|
|
+ sd->cart.u.items_cart[i].equipSwitch = 0;
|
|
log_pick_pc(sd, log_type, amount, &sd->cart.u.items_cart[i]);
|
|
log_pick_pc(sd, log_type, amount, &sd->cart.u.items_cart[i]);
|
|
|
|
|
|
sd->cart_weight += w;
|
|
sd->cart_weight += w;
|
|
@@ -5173,6 +5193,11 @@ void pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
|
|
if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
|
|
if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ if( item_data->equipSwitch ){
|
|
|
|
+ clif_msg( sd, C_ITEM_EQUIP_SWITCH );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
if( (flag = pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0 )
|
|
if( (flag = pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0 )
|
|
pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
|
|
pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
|
|
else {
|
|
else {
|
|
@@ -5801,15 +5826,21 @@ static void pc_checkallowskill(struct map_session_data *sd)
|
|
* -1 : Nothing equipped
|
|
* -1 : Nothing equipped
|
|
* idx : (this index could be used in inventory to found item_data)
|
|
* idx : (this index could be used in inventory to found item_data)
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
-short pc_checkequip(struct map_session_data *sd,int pos)
|
|
|
|
|
|
+short pc_checkequip(struct map_session_data *sd,int pos, bool checkall)
|
|
{
|
|
{
|
|
uint8 i;
|
|
uint8 i;
|
|
|
|
|
|
nullpo_retr(-1, sd);
|
|
nullpo_retr(-1, sd);
|
|
|
|
|
|
for(i=0;i<EQI_MAX;i++){
|
|
for(i=0;i<EQI_MAX;i++){
|
|
- if(pos & equip_bitmask[i])
|
|
|
|
|
|
+ if(pos & equip_bitmask[i]){
|
|
|
|
+ if( checkall && ( pos&~equip_bitmask[i] ) != 0 && sd->equip_index[i] == -1 ){
|
|
|
|
+ // Check all if any match is found
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
return sd->equip_index[i];
|
|
return sd->equip_index[i];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return -1;
|
|
return -1;
|
|
@@ -9756,20 +9787,29 @@ int pc_load_combo(struct map_session_data *sd) {
|
|
* Equip item on player sd at req_pos from inventory index n
|
|
* Equip item on player sd at req_pos from inventory index n
|
|
* return: false - fail; true - success
|
|
* return: false - fail; true - success
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
-bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
|
|
|
|
+bool pc_equipitem(struct map_session_data *sd,short n,int req_pos,bool equipswitch)
|
|
{
|
|
{
|
|
int i, pos, flag = 0, iflag;
|
|
int i, pos, flag = 0, iflag;
|
|
struct item_data *id;
|
|
struct item_data *id;
|
|
uint8 res = ITEM_EQUIP_ACK_OK;
|
|
uint8 res = ITEM_EQUIP_ACK_OK;
|
|
|
|
+ short* equip_index;
|
|
|
|
|
|
nullpo_retr(false,sd);
|
|
nullpo_retr(false,sd);
|
|
|
|
|
|
if( n < 0 || n >= MAX_INVENTORY ) {
|
|
if( n < 0 || n >= MAX_INVENTORY ) {
|
|
- clif_equipitemack(sd,0,0,ITEM_EQUIP_ACK_FAIL);
|
|
|
|
|
|
+ if( equipswitch ){
|
|
|
|
+ clif_equipswitch_add( sd, n, req_pos, true );
|
|
|
|
+ }else{
|
|
|
|
+ clif_equipitemack(sd,0,0,ITEM_EQUIP_ACK_FAIL);
|
|
|
|
+ }
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
if( DIFF_TICK(sd->canequip_tick,gettick()) > 0 ) {
|
|
if( DIFF_TICK(sd->canequip_tick,gettick()) > 0 ) {
|
|
- clif_equipitemack(sd,n,0,ITEM_EQUIP_ACK_FAIL);
|
|
|
|
|
|
+ if( equipswitch ){
|
|
|
|
+ clif_equipswitch_add( sd, n, req_pos, true );
|
|
|
|
+ }else{
|
|
|
|
+ clif_equipitemack(sd,n,0,ITEM_EQUIP_ACK_FAIL);
|
|
|
|
+ }
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -9777,25 +9817,44 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
return false;
|
|
return false;
|
|
pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
|
|
pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
|
|
|
|
|
|
- if(battle_config.battle_log)
|
|
|
|
|
|
+ if(battle_config.battle_log && !equipswitch)
|
|
ShowInfo("equip %hu (%d) %x:%x\n",sd->inventory.u.items_inventory[n].nameid,n,id?id->equip:0,req_pos);
|
|
ShowInfo("equip %hu (%d) %x:%x\n",sd->inventory.u.items_inventory[n].nameid,n,id?id->equip:0,req_pos);
|
|
|
|
|
|
if((res = pc_isequip(sd,n))) {
|
|
if((res = pc_isequip(sd,n))) {
|
|
- clif_equipitemack(sd,n,0,res); // fail
|
|
|
|
|
|
+ if( equipswitch ){
|
|
|
|
+ clif_equipswitch_add( sd, n, req_pos, true );
|
|
|
|
+ }else{
|
|
|
|
+ clif_equipitemack(sd,n,0,res); // fail
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if( equipswitch && id->type == IT_AMMO ){
|
|
|
|
+ clif_equipswitch_add( sd, n, req_pos, true );
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
if (!(pos&req_pos) || sd->inventory.u.items_inventory[n].equip != 0 || sd->inventory.u.items_inventory[n].attribute==1 ) { // [Valaris]
|
|
if (!(pos&req_pos) || sd->inventory.u.items_inventory[n].equip != 0 || sd->inventory.u.items_inventory[n].attribute==1 ) { // [Valaris]
|
|
- clif_equipitemack(sd,n,0,ITEM_EQUIP_ACK_FAIL); // fail
|
|
|
|
|
|
+ if( equipswitch ){
|
|
|
|
+ clif_equipswitch_add( sd, n, req_pos, true );
|
|
|
|
+ }else{
|
|
|
|
+ clif_equipitemack(sd,n,0,ITEM_EQUIP_ACK_FAIL); // fail
|
|
|
|
+ }
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
if( sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] ||
|
|
if( sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] ||
|
|
sd->sc.data[SC_KYOUGAKU] || (sd->sc.data[SC_PYROCLASTIC] && sd->inventory_data[n]->type == IT_WEAPON)) ) {
|
|
sd->sc.data[SC_KYOUGAKU] || (sd->sc.data[SC_PYROCLASTIC] && sd->inventory_data[n]->type == IT_WEAPON)) ) {
|
|
- clif_equipitemack(sd,n,0,ITEM_EQUIP_ACK_FAIL); //Fail
|
|
|
|
|
|
+ if( equipswitch ){
|
|
|
|
+ clif_equipswitch_add( sd, n, req_pos, true );
|
|
|
|
+ }else{
|
|
|
|
+ clif_equipitemack(sd,n,0,ITEM_EQUIP_ACK_FAIL); //Fail
|
|
|
|
+ }
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- if (id->flag.bindOnEquip && !sd->inventory.u.items_inventory[n].bound) {
|
|
|
|
|
|
+ equip_index = equipswitch ? sd->equip_switch_index : sd->equip_index;
|
|
|
|
+
|
|
|
|
+ if ( !equipswitch && id->flag.bindOnEquip && !sd->inventory.u.items_inventory[n].bound) {
|
|
sd->inventory.u.items_inventory[n].bound = (char)battle_config.default_bind_on_equip;
|
|
sd->inventory.u.items_inventory[n].bound = (char)battle_config.default_bind_on_equip;
|
|
clif_notify_bindOnEquip(sd,n);
|
|
clif_notify_bindOnEquip(sd,n);
|
|
}
|
|
}
|
|
@@ -9803,52 +9862,72 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
if(pos == EQP_ACC) { //Accesories should only go in one of the two,
|
|
if(pos == EQP_ACC) { //Accesories should only go in one of the two,
|
|
pos = req_pos&EQP_ACC;
|
|
pos = req_pos&EQP_ACC;
|
|
if (pos == EQP_ACC) //User specified both slots..
|
|
if (pos == EQP_ACC) //User specified both slots..
|
|
- pos = sd->equip_index[EQI_ACC_R] >= 0 ? EQP_ACC_L : EQP_ACC_R;
|
|
|
|
|
|
+ pos = equip_index[EQI_ACC_R] >= 0 ? EQP_ACC_L : EQP_ACC_R;
|
|
}
|
|
}
|
|
|
|
|
|
if(pos == EQP_ARMS && id->equip == EQP_HAND_R) { //Dual wield capable weapon.
|
|
if(pos == EQP_ARMS && id->equip == EQP_HAND_R) { //Dual wield capable weapon.
|
|
pos = (req_pos&EQP_ARMS);
|
|
pos = (req_pos&EQP_ARMS);
|
|
if (pos == EQP_ARMS) //User specified both slots, pick one for them.
|
|
if (pos == EQP_ARMS) //User specified both slots, pick one for them.
|
|
- pos = sd->equip_index[EQI_HAND_R] >= 0 ? EQP_HAND_L : EQP_HAND_R;
|
|
|
|
|
|
+ pos = equip_index[EQI_HAND_R] >= 0 ? EQP_HAND_L : EQP_HAND_R;
|
|
}
|
|
}
|
|
|
|
|
|
if(pos == EQP_SHADOW_ACC) { // Shadow System
|
|
if(pos == EQP_SHADOW_ACC) { // Shadow System
|
|
pos = req_pos&EQP_SHADOW_ACC;
|
|
pos = req_pos&EQP_SHADOW_ACC;
|
|
if (pos == EQP_SHADOW_ACC)
|
|
if (pos == EQP_SHADOW_ACC)
|
|
- pos = sd->equip_index[EQI_SHADOW_ACC_L] >= 0 ? EQP_SHADOW_ACC_R : EQP_SHADOW_ACC_L;
|
|
|
|
|
|
+ pos = equip_index[EQI_SHADOW_ACC_L] >= 0 ? EQP_SHADOW_ACC_R : EQP_SHADOW_ACC_L;
|
|
}
|
|
}
|
|
if(pos == EQP_SHADOW_ARMS && id->equip == EQP_SHADOW_WEAPON) {
|
|
if(pos == EQP_SHADOW_ARMS && id->equip == EQP_SHADOW_WEAPON) {
|
|
pos = (req_pos&EQP_SHADOW_ARMS);
|
|
pos = (req_pos&EQP_SHADOW_ARMS);
|
|
if( pos == EQP_SHADOW_ARMS )
|
|
if( pos == EQP_SHADOW_ARMS )
|
|
- pos = (sd->equip_index[EQI_SHADOW_WEAPON] >= 0 ? EQP_SHADOW_SHIELD : EQP_SHADOW_WEAPON);
|
|
|
|
|
|
+ pos = (equip_index[EQI_SHADOW_WEAPON] >= 0 ? EQP_SHADOW_SHIELD : EQP_SHADOW_WEAPON);
|
|
}
|
|
}
|
|
|
|
|
|
if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC) {
|
|
if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC) {
|
|
//Update skill-block range database when weapon range changes. [Skotlex]
|
|
//Update skill-block range database when weapon range changes. [Skotlex]
|
|
- i = sd->equip_index[EQI_HAND_R];
|
|
|
|
|
|
+ i = equip_index[EQI_HAND_R];
|
|
if (i < 0 || !sd->inventory_data[i]) //No data, or no weapon equipped
|
|
if (i < 0 || !sd->inventory_data[i]) //No data, or no weapon equipped
|
|
flag = 1;
|
|
flag = 1;
|
|
else
|
|
else
|
|
flag = id->range != sd->inventory_data[i]->range;
|
|
flag = id->range != sd->inventory_data[i]->range;
|
|
}
|
|
}
|
|
|
|
|
|
- for(i=0;i<EQI_MAX;i++) {
|
|
|
|
- if(pos & equip_bitmask[i]) {
|
|
|
|
- if(sd->equip_index[i] >= 0) //Slot taken, remove item from there.
|
|
|
|
- pc_unequipitem(sd,sd->equip_index[i],2 | 4);
|
|
|
|
|
|
+ if( equipswitch ){
|
|
|
|
+ for( i = 0; i < EQI_MAX; i++ ){
|
|
|
|
+ if( pos&equip_bitmask[i] ){
|
|
|
|
+ // If there was already an item assigned to this slot
|
|
|
|
+ if( sd->equip_switch_index[i] >= 0 ){
|
|
|
|
+ pc_equipswitch_remove( sd, sd->equip_switch_index[i] );
|
|
|
|
+ }
|
|
|
|
|
|
- sd->equip_index[i] = n;
|
|
|
|
|
|
+ // Assign the new index to it
|
|
|
|
+ sd->equip_switch_index[i] = n;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- if(pos==EQP_AMMO) {
|
|
|
|
- clif_arrowequip(sd,n);
|
|
|
|
- clif_arrow_fail(sd,3);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- clif_equipitemack(sd,n,pos,ITEM_EQUIP_ACK_OK);
|
|
|
|
|
|
+ sd->inventory.u.items_inventory[n].equipSwitch = pos;
|
|
|
|
+ clif_equipswitch_add( sd, n, pos, false );
|
|
|
|
+ return true;
|
|
|
|
+ }else{
|
|
|
|
+ for(i=0;i<EQI_MAX;i++) {
|
|
|
|
+ if(pos & equip_bitmask[i]) {
|
|
|
|
+ if(sd->equip_index[i] >= 0) //Slot taken, remove item from there.
|
|
|
|
+ pc_unequipitem(sd,sd->equip_index[i],2 | 4);
|
|
|
|
|
|
- sd->inventory.u.items_inventory[n].equip = pos;
|
|
|
|
|
|
+ sd->equip_index[i] = n;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pc_equipswitch_remove(sd, n);
|
|
|
|
+
|
|
|
|
+ if(pos==EQP_AMMO) {
|
|
|
|
+ clif_arrowequip(sd,n);
|
|
|
|
+ clif_arrow_fail(sd,3);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ clif_equipitemack(sd,n,pos,ITEM_EQUIP_ACK_OK);
|
|
|
|
+
|
|
|
|
+ sd->inventory.u.items_inventory[n].equip = pos;
|
|
|
|
+ }
|
|
|
|
|
|
if(pos & EQP_HAND_R) {
|
|
if(pos & EQP_HAND_R) {
|
|
if(id)
|
|
if(id)
|
|
@@ -10152,13 +10231,114 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int pc_equipswitch( struct map_session_data* sd, int index ){
|
|
|
|
+ // Get the target equip mask
|
|
|
|
+ int position = sd->inventory.u.items_inventory[index].equipSwitch;
|
|
|
|
+
|
|
|
|
+ // Get the currently equipped item
|
|
|
|
+ short equippedItem = pc_checkequip( sd, position, true );
|
|
|
|
+
|
|
|
|
+ // No item equipped at the target
|
|
|
|
+ if( equippedItem == -1 ){
|
|
|
|
+ // Remove it from the equip switch
|
|
|
|
+ pc_equipswitch_remove( sd, index );
|
|
|
|
+
|
|
|
|
+ pc_equipitem( sd, index, position );
|
|
|
|
+
|
|
|
|
+ return position;
|
|
|
|
+ }else{
|
|
|
|
+ std::map<int, int> unequipped;
|
|
|
|
+ int unequipped_position = 0;
|
|
|
|
+
|
|
|
|
+ // Unequip all items that interfere
|
|
|
|
+ for( int i = 0; i < EQI_MAX; i++ ){
|
|
|
|
+ int unequip_index = sd->equip_index[i];
|
|
|
|
+
|
|
|
|
+ if( unequip_index >= 0 && position & equip_bitmask[i] ){
|
|
|
|
+ struct item* unequip_item = &sd->inventory.u.items_inventory[unequip_index];
|
|
|
|
+
|
|
|
|
+ // Store the unequipped index and position mask for later
|
|
|
|
+ unequipped[unequip_index] = unequip_item->equip;
|
|
|
|
+
|
|
|
|
+ // Keep the position for later
|
|
|
|
+ unequipped_position |= unequip_item->equip;
|
|
|
|
+
|
|
|
|
+ // Unequip the item
|
|
|
|
+ pc_unequipitem( sd, unequip_index, 0 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int all_position = position | unequipped_position;
|
|
|
|
+
|
|
|
|
+ // Equip everything that is hit by the mask
|
|
|
|
+ for( int i = 0; i < EQI_MAX; i++ ){
|
|
|
|
+ int exchange_index = sd->equip_switch_index[i];
|
|
|
|
+
|
|
|
|
+ if( exchange_index >= 0 && all_position & equip_bitmask[i] ){
|
|
|
|
+ struct item* exchange_item = &sd->inventory.u.items_inventory[exchange_index];
|
|
|
|
+
|
|
|
|
+ // Store the target position
|
|
|
|
+ int exchange_position = exchange_item->equipSwitch;
|
|
|
|
+
|
|
|
|
+ // Remove the item from equip switch
|
|
|
|
+ pc_equipswitch_remove( sd, exchange_index );
|
|
|
|
+
|
|
|
|
+ // Equip the item at the destinated position
|
|
|
|
+ pc_equipitem( sd, exchange_index, exchange_position );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Place all unequipped items into the equip switch window
|
|
|
|
+ for( std::pair<int, int> pair : unequipped ){
|
|
|
|
+ int unequipped_index = pair.first;
|
|
|
|
+ int unequipped_position = pair.second;
|
|
|
|
+
|
|
|
|
+ // Rebuild the index cache
|
|
|
|
+ for( int i = 0; i < EQI_MAX; i++ ){
|
|
|
|
+ if( unequipped_position & equip_bitmask[i] ){
|
|
|
|
+ sd->equip_switch_index[i] = unequipped_index;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Set the correct position mask
|
|
|
|
+ sd->inventory.u.items_inventory[unequipped_index].equipSwitch = unequipped_position;
|
|
|
|
+
|
|
|
|
+ // Notify the client
|
|
|
|
+ clif_equipswitch_add( sd, unequipped_index, unequipped_position, false );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return all_position;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void pc_equipswitch_remove( struct map_session_data* sd, int index ){
|
|
|
|
+ struct item* item = &sd->inventory.u.items_inventory[index];
|
|
|
|
+
|
|
|
|
+ if( !item->equipSwitch ){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for( int i = 0; i < EQI_MAX; i++ ){
|
|
|
|
+ // If a match is found
|
|
|
|
+ if( sd->equip_switch_index[i] == index ){
|
|
|
|
+ // Remove it from the slot
|
|
|
|
+ sd->equip_switch_index[i] = -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Send out one packet for all slots using the current item's mask
|
|
|
|
+ clif_equipswitch_remove( sd, index, item->equipSwitch, false );
|
|
|
|
+
|
|
|
|
+ item->equipSwitch = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
/*==========================================
|
|
/*==========================================
|
|
* Checking if player (sd) has an invalid item
|
|
* Checking if player (sd) has an invalid item
|
|
* and is unequiped on map load (item_noequip)
|
|
* and is unequiped on map load (item_noequip)
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
void pc_checkitem(struct map_session_data *sd) {
|
|
void pc_checkitem(struct map_session_data *sd) {
|
|
int i, calc_flag = 0;
|
|
int i, calc_flag = 0;
|
|
- struct item it;
|
|
|
|
|
|
+ struct item* it;
|
|
|
|
|
|
nullpo_retv(sd);
|
|
nullpo_retv(sd);
|
|
|
|
|
|
@@ -10168,13 +10348,13 @@ void pc_checkitem(struct map_session_data *sd) {
|
|
pc_check_available_item(sd, ITMCHK_NONE); // Check for invalid(ated) items.
|
|
pc_check_available_item(sd, ITMCHK_NONE); // Check for invalid(ated) items.
|
|
|
|
|
|
for( i = 0; i < MAX_INVENTORY; i++ ) {
|
|
for( i = 0; i < MAX_INVENTORY; i++ ) {
|
|
- it = sd->inventory.u.items_inventory[i];
|
|
|
|
|
|
+ it = &sd->inventory.u.items_inventory[i];
|
|
|
|
|
|
- if( it.nameid == 0 )
|
|
|
|
|
|
+ if( it->nameid == 0 )
|
|
continue;
|
|
continue;
|
|
- if( !it.equip )
|
|
|
|
|
|
+ if( !it->equip )
|
|
continue;
|
|
continue;
|
|
- if( it.equip&~pc_equippoint(sd,i) ) {
|
|
|
|
|
|
+ if( it->equip&~pc_equippoint(sd,i) ) {
|
|
pc_unequipitem(sd, i, 2);
|
|
pc_unequipitem(sd, i, 2);
|
|
calc_flag = 1;
|
|
calc_flag = 1;
|
|
continue;
|
|
continue;
|
|
@@ -10187,6 +10367,28 @@ void pc_checkitem(struct map_session_data *sd) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ for( i = 0; i < MAX_INVENTORY; i++ ) {
|
|
|
|
+ it = &sd->inventory.u.items_inventory[i];
|
|
|
|
+
|
|
|
|
+ if( it->nameid == 0 )
|
|
|
|
+ continue;
|
|
|
|
+ if( !it->equipSwitch )
|
|
|
|
+ continue;
|
|
|
|
+ if( it->equipSwitch&~pc_equippoint(sd,i) ||
|
|
|
|
+ ( !pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT) && !battle_config.allow_equip_restricted_item && itemdb_isNoEquip(sd->inventory_data[i], sd->bl.m) ) ){
|
|
|
|
+
|
|
|
|
+ for( int j = 0; j < EQI_MAX; j++ ){
|
|
|
|
+ if( sd->equip_switch_index[j] == i ){
|
|
|
|
+ sd->equip_switch_index[j] = -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sd->inventory.u.items_inventory[i].equipSwitch = 0;
|
|
|
|
+
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if( calc_flag && sd->state.active ) {
|
|
if( calc_flag && sd->state.active ) {
|
|
pc_checkallowskill(sd);
|
|
pc_checkallowskill(sd);
|
|
status_calc_pc(sd,SCO_NONE);
|
|
status_calc_pc(sd,SCO_NONE);
|