Corrected a potential crash from equip switch (#4198)

* Resolves a potential crash with the equip switch feature and invalid items.
Thanks to Melvo and @functor-x!
This commit is contained in:
Aleos 2019-06-03 09:04:25 -04:00 committed by GitHub
parent 8ed3d0583a
commit 8cfee2c872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20869,6 +20869,10 @@ void clif_parse_equipswitch_request_single( int fd, struct map_session_data* sd
return;
}
// Check if the item exists
if (sd->inventory_data[index] == nullptr)
return;
// Check if the item was already added to equip switch
if( sd->inventory.u.items_inventory[index].equipSwitch ){
if( sd->npc_id ){
@ -20884,9 +20888,10 @@ void clif_parse_equipswitch_request_single( int fd, struct map_session_data* sd
}
pc_equipswitch( sd, index );
}else{
pc_equipitem( sd, index, pc_equippoint(sd, index), true );
return;
}
pc_equipitem( sd, index, pc_equippoint(sd, index), true );
#endif
}