|
@@ -475,18 +475,18 @@ void pc_inventory_rentals(struct map_session_data *sd)
|
|
|
unsigned int expire_tick, next_tick = UINT_MAX;
|
|
|
|
|
|
for( i = 0; i < MAX_INVENTORY; i++ ) { // Check for Rentals on Inventory
|
|
|
- if( sd->status.inventory[i].nameid == 0 )
|
|
|
+ if( sd->inventory.u.items_inventory[i].nameid == 0 )
|
|
|
continue; // Nothing here
|
|
|
- if( sd->status.inventory[i].expire_time == 0 )
|
|
|
+ if( sd->inventory.u.items_inventory[i].expire_time == 0 )
|
|
|
continue;
|
|
|
- if( sd->status.inventory[i].expire_time <= time(NULL) ) {
|
|
|
+ if( sd->inventory.u.items_inventory[i].expire_time <= time(NULL) ) {
|
|
|
if (sd->inventory_data[i]->unequip_script)
|
|
|
run_script(sd->inventory_data[i]->unequip_script, 0, sd->bl.id, fake_nd->bl.id);
|
|
|
- clif_rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
|
|
|
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
|
|
|
+ clif_rental_expired(sd->fd, i, sd->inventory.u.items_inventory[i].nameid);
|
|
|
+ pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
|
|
|
} else {
|
|
|
- expire_tick = (unsigned int)(sd->status.inventory[i].expire_time - time(NULL)) * 1000;
|
|
|
- clif_rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000));
|
|
|
+ expire_tick = (unsigned int)(sd->inventory.u.items_inventory[i].expire_time - time(NULL)) * 1000;
|
|
|
+ clif_rental_time(sd->fd, sd->inventory.u.items_inventory[i].nameid, (int)(expire_tick / 1000));
|
|
|
next_tick = umin(expire_tick, next_tick);
|
|
|
c++;
|
|
|
}
|
|
@@ -646,14 +646,14 @@ void pc_setinventorydata(struct map_session_data *sd)
|
|
|
nullpo_retv(sd);
|
|
|
|
|
|
for(i = 0; i < MAX_INVENTORY; i++) {
|
|
|
- unsigned short id = sd->status.inventory[i].nameid;
|
|
|
+ unsigned short id = sd->inventory.u.items_inventory[i].nameid;
|
|
|
sd->inventory_data[i] = id?itemdb_search(id):NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 'Calculates' weapon type
|
|
|
-* @param sd : player
|
|
|
+* @param sd : Player
|
|
|
*/
|
|
|
void pc_calcweapontype(struct map_session_data *sd)
|
|
|
{
|
|
@@ -711,22 +711,22 @@ void pc_setequipindex(struct map_session_data *sd)
|
|
|
sd->equip_index[i] = -1;
|
|
|
|
|
|
for (i = 0; i < MAX_INVENTORY; i++) {
|
|
|
- if (sd->status.inventory[i].nameid <= 0)
|
|
|
+ if (sd->inventory.u.items_inventory[i].nameid <= 0)
|
|
|
continue;
|
|
|
- if (sd->status.inventory[i].equip) {
|
|
|
+ if (sd->inventory.u.items_inventory[i].equip) {
|
|
|
uint8 j;
|
|
|
for (j = 0; j < EQI_MAX; j++)
|
|
|
- if (sd->status.inventory[i].equip & equip_pos[j])
|
|
|
+ if (sd->inventory.u.items_inventory[i].equip & equip_pos[j])
|
|
|
sd->equip_index[j] = i;
|
|
|
|
|
|
- if (sd->status.inventory[i].equip & EQP_HAND_R) {
|
|
|
+ if (sd->inventory.u.items_inventory[i].equip & EQP_HAND_R) {
|
|
|
if (sd->inventory_data[i])
|
|
|
sd->weapontype1 = sd->inventory_data[i]->look;
|
|
|
else
|
|
|
sd->weapontype1 = 0;
|
|
|
}
|
|
|
|
|
|
- if( sd->status.inventory[i].equip & EQP_HAND_L ) {
|
|
|
+ if( sd->inventory.u.items_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;
|
|
|
else
|
|
@@ -740,7 +740,7 @@ void pc_setequipindex(struct map_session_data *sd)
|
|
|
//static int pc_isAllowedCardOn(struct map_session_data *sd,int s,int eqindex,int flag)
|
|
|
//{
|
|
|
// int i;
|
|
|
-// struct item *item = &sd->status.inventory[eqindex];
|
|
|
+// struct item *item = &sd->inventory.u.items_inventory[eqindex];
|
|
|
// struct item_data *data;
|
|
|
//
|
|
|
// //Crafted/made/hatched items.
|
|
@@ -779,7 +779,7 @@ bool pc_isequipped(struct map_session_data *sd, unsigned short nameid)
|
|
|
if( sd->inventory_data[index]->nameid == nameid )
|
|
|
return true;
|
|
|
for( j = 0; j < sd->inventory_data[index]->slot; j++ ){
|
|
|
- if( sd->status.inventory[index].card[j] == nameid )
|
|
|
+ if( sd->inventory.u.items_inventory[index].card[j] == nameid )
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -1018,10 +1018,6 @@ uint8 pc_isequip(struct map_session_data *sd,int n)
|
|
|
bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers)
|
|
|
{
|
|
|
int i;
|
|
|
-#ifdef BOUND_ITEMS
|
|
|
- int j;
|
|
|
- int idxlist[MAX_INVENTORY];
|
|
|
-#endif
|
|
|
unsigned long tick = gettick();
|
|
|
uint32 ip = session[sd->fd]->client_addr;
|
|
|
|
|
@@ -1056,7 +1052,8 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
|
|
|
sd->status.body = cap_value(sd->status.body,MIN_BODY_STYLE,MAX_BODY_STYLE);
|
|
|
|
|
|
//Initializations to null/0 unneeded since map_session_data was filled with 0 upon allocation.
|
|
|
- if(!sd->status.hp) pc_setdead(sd);
|
|
|
+ if (!sd->status.hp)
|
|
|
+ pc_setdead(sd);
|
|
|
sd->state.connect_new = 1;
|
|
|
|
|
|
sd->followtimer = INVALID_TIMER; // [MouseJstr]
|
|
@@ -1106,8 +1103,7 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
|
|
|
if (!(battle_config.display_skill_fail&2))
|
|
|
sd->state.showdelay = 1;
|
|
|
|
|
|
- pc_setinventorydata(sd);
|
|
|
- pc_setequipindex(sd);
|
|
|
+ pc_setequipindex(sd); // required at the moment, to complete auth_ok [lighta]
|
|
|
|
|
|
if( sd->status.option&OPTION_INVISIBLE && !pc_can_use_command( sd, "hide", COMMAND_ATCOMMAND ) ){
|
|
|
sd->status.option &= ~OPTION_INVISIBLE;
|
|
@@ -1116,8 +1112,7 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
|
|
|
status_change_init(&sd->bl);
|
|
|
|
|
|
sd->sc.option = sd->status.option; //This is the actual option used in battle.
|
|
|
- //Set here because we need the inventory data for weapon sprite parsing.
|
|
|
- status_set_viewdata(&sd->bl, sd->status.class_);
|
|
|
+
|
|
|
unit_dataset(&sd->bl);
|
|
|
|
|
|
sd->guild_x = -1;
|
|
@@ -1198,20 +1193,8 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
|
|
|
clif_changemap(sd,sd->bl.m,sd->bl.x,sd->bl.y);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Check if player have any item cooldowns on
|
|
|
- **/
|
|
|
- pc_itemcd_do(sd,true);
|
|
|
pc_validate_skill(sd);
|
|
|
|
|
|
-#ifdef BOUND_ITEMS
|
|
|
- // Party bound item check
|
|
|
- if(sd->status.party_id == 0 && (j = pc_bound_chk(sd,BOUND_PARTY,idxlist))) { // Party was deleted while character offline
|
|
|
- for(i=0;i<j;i++)
|
|
|
- pc_delitem(sd,idxlist[i],sd->status.inventory[idxlist[i]].amount,0,1,LOG_TYPE_OTHER);
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
/* [Ind] */
|
|
|
sd->sc_display = NULL;
|
|
|
sd->sc_display_count = 0;
|
|
@@ -1282,6 +1265,8 @@ bool pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl
|
|
|
|
|
|
/*==========================================
|
|
|
* Invoked once after the char/account/account2 registry variables are received. [Skotlex]
|
|
|
+ * We didn't receive item information at this point so DO NOT attempt to do item operations here.
|
|
|
+ * See intif_parse_StorageReceived() for item operations [lighta]
|
|
|
*------------------------------------------*/
|
|
|
void pc_reg_received(struct map_session_data *sd)
|
|
|
{
|
|
@@ -1418,12 +1403,9 @@ void pc_reg_received(struct map_session_data *sd)
|
|
|
clif_changeoption( &sd->bl );
|
|
|
}
|
|
|
|
|
|
- pc_check_expiration(sd);
|
|
|
-
|
|
|
- if( sd->state.autotrade ) {
|
|
|
- clif_parse_LoadEndAck(sd->fd, sd);
|
|
|
- sd->autotrade_tid = add_timer(gettick() + battle_config.feature_autotrade_open_delay, pc_autotrade_timer, sd->bl.id, 0);
|
|
|
- }
|
|
|
+ intif_storage_request(sd,TABLE_STORAGE); // Request storage data
|
|
|
+ intif_storage_request(sd,TABLE_CART); // Request cart data
|
|
|
+ intif_storage_request(sd,TABLE_INVENTORY); // Request inventory data
|
|
|
}
|
|
|
|
|
|
static int pc_calc_skillpoint(struct map_session_data* sd)
|
|
@@ -2209,7 +2191,7 @@ void pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,
|
|
|
//Create a list of all equipped positions to see if all items needed for the autobonus are still present [Playtester]
|
|
|
for(j = 0; j < EQI_MAX; j++) {
|
|
|
if(sd->equip_index[j] >= 0)
|
|
|
- equip_pos_idx |= sd->status.inventory[sd->equip_index[j]].equip;
|
|
|
+ equip_pos_idx |= sd->inventory.u.items_inventory[sd->equip_index[j]].equip;
|
|
|
}
|
|
|
if((equip_pos_idx&autobonus[i].pos) == autobonus[i].pos)
|
|
|
script_run_autobonus(autobonus[i].bonus_script,sd,autobonus[i].pos);
|
|
@@ -2243,7 +2225,7 @@ void pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus)
|
|
|
//Create a list of all equipped positions to see if all items needed for the autobonus are still present [Playtester]
|
|
|
for(j = 0; j < EQI_MAX; j++) {
|
|
|
if(sd->equip_index[j] >= 0)
|
|
|
- equip_pos_idx |= sd->status.inventory[sd->equip_index[j]].equip;
|
|
|
+ equip_pos_idx |= sd->inventory.u.items_inventory[sd->equip_index[j]].equip;
|
|
|
}
|
|
|
if((equip_pos_idx&autobonus->pos) == autobonus->pos)
|
|
|
script_run_autobonus(autobonus->other_script,sd,autobonus->pos);
|
|
@@ -3959,31 +3941,31 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
|
|
|
return 0; //Invalid item index.
|
|
|
if( idx_card < 0 || idx_card >= MAX_INVENTORY || sd->inventory_data[idx_card] == NULL )
|
|
|
return 0; //Invalid card index.
|
|
|
- if( sd->status.inventory[idx_equip].nameid <= 0 || sd->status.inventory[idx_equip].amount < 1 )
|
|
|
+ if( sd->inventory.u.items_inventory[idx_equip].nameid <= 0 || sd->inventory.u.items_inventory[idx_equip].amount < 1 )
|
|
|
return 0; // target item missing
|
|
|
- if( sd->status.inventory[idx_card].nameid <= 0 || sd->status.inventory[idx_card].amount < 1 )
|
|
|
+ if( sd->inventory.u.items_inventory[idx_card].nameid <= 0 || sd->inventory.u.items_inventory[idx_card].amount < 1 )
|
|
|
return 0; // target card missing
|
|
|
if( sd->inventory_data[idx_equip]->type != IT_WEAPON && sd->inventory_data[idx_equip]->type != IT_ARMOR )
|
|
|
return 0; // only weapons and armor are allowed
|
|
|
if( sd->inventory_data[idx_card]->type != IT_CARD )
|
|
|
return 0; // must be a card
|
|
|
- if( sd->status.inventory[idx_equip].identify == 0 )
|
|
|
+ if( sd->inventory.u.items_inventory[idx_equip].identify == 0 )
|
|
|
return 0; // target must be identified
|
|
|
- if( itemdb_isspecial(sd->status.inventory[idx_equip].card[0]) )
|
|
|
+ if( itemdb_isspecial(sd->inventory.u.items_inventory[idx_equip].card[0]) )
|
|
|
return 0; // card slots reserved for other purposes
|
|
|
if( (sd->inventory_data[idx_equip]->equip & sd->inventory_data[idx_card]->equip) == 0 )
|
|
|
return 0; // card cannot be compounded on this item type
|
|
|
if( sd->inventory_data[idx_equip]->type == IT_WEAPON && sd->inventory_data[idx_card]->equip == EQP_SHIELD )
|
|
|
return 0; // attempted to place shield card on left-hand weapon.
|
|
|
- if( sd->status.inventory[idx_equip].equip != 0 )
|
|
|
+ if( sd->inventory.u.items_inventory[idx_equip].equip != 0 )
|
|
|
return 0; // item must be unequipped
|
|
|
|
|
|
- ARR_FIND( 0, sd->inventory_data[idx_equip]->slot, i, sd->status.inventory[idx_equip].card[i] == 0 );
|
|
|
+ ARR_FIND( 0, sd->inventory_data[idx_equip]->slot, i, sd->inventory.u.items_inventory[idx_equip].card[i] == 0 );
|
|
|
if( i == sd->inventory_data[idx_equip]->slot )
|
|
|
return 0; // no free slots
|
|
|
|
|
|
// remember the card id to insert
|
|
|
- nameid = sd->status.inventory[idx_card].nameid;
|
|
|
+ nameid = sd->inventory.u.items_inventory[idx_card].nameid;
|
|
|
|
|
|
if( pc_delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 )
|
|
|
{// failed
|
|
@@ -3991,9 +3973,9 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
|
|
|
}
|
|
|
else
|
|
|
{// success
|
|
|
- log_pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->status.inventory[idx_equip]);
|
|
|
- sd->status.inventory[idx_equip].card[i] = nameid;
|
|
|
- log_pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->status.inventory[idx_equip]);
|
|
|
+ log_pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->inventory.u.items_inventory[idx_equip]);
|
|
|
+ sd->inventory.u.items_inventory[idx_equip].card[i] = nameid;
|
|
|
+ log_pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->inventory.u.items_inventory[idx_equip]);
|
|
|
clif_insert_card(sd,idx_equip,idx_card,0);
|
|
|
}
|
|
|
|
|
@@ -4067,8 +4049,8 @@ char pc_checkadditem(struct map_session_data *sd, unsigned short nameid, int amo
|
|
|
|
|
|
for(i=0;i<MAX_INVENTORY;i++){
|
|
|
// FIXME: This does not consider the checked item's cards, thus could check a wrong slot for stackability.
|
|
|
- if(sd->status.inventory[i].nameid==nameid){
|
|
|
- if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) )
|
|
|
+ if(sd->inventory.u.items_inventory[i].nameid == nameid){
|
|
|
+ if( amount > MAX_AMOUNT - sd->inventory.u.items_inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->inventory.u.items_inventory[i].amount ) )
|
|
|
return CHKADDITEM_OVERAMOUNT;
|
|
|
return CHKADDITEM_EXIST;
|
|
|
}
|
|
@@ -4090,7 +4072,7 @@ uint8 pc_inventoryblank(struct map_session_data *sd)
|
|
|
nullpo_ret(sd);
|
|
|
|
|
|
for(i = 0, b = 0; i < MAX_INVENTORY; i++){
|
|
|
- if(sd->status.inventory[i].nameid==0)
|
|
|
+ if(sd->inventory.u.items_inventory[i].nameid == 0)
|
|
|
b++;
|
|
|
}
|
|
|
|
|
@@ -4301,7 +4283,7 @@ short pc_search_inventory(struct map_session_data *sd, unsigned short nameid) {
|
|
|
short i;
|
|
|
nullpo_retr(-1, sd);
|
|
|
|
|
|
- ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid && (sd->status.inventory[i].amount > 0 || nameid == 0) );
|
|
|
+ ARR_FIND( 0, MAX_INVENTORY, i, sd->inventory.u.items_inventory[i].nameid == nameid && (sd->inventory.u.items_inventory[i].amount > 0 || nameid == 0) );
|
|
|
return ( i < MAX_INVENTORY ) ? i : -1;
|
|
|
}
|
|
|
|
|
@@ -4352,16 +4334,14 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p
|
|
|
// Stackable | Non Rental
|
|
|
if( itemdb_isstackable2(id) && item->expire_time == 0 ) {
|
|
|
for( i = 0; i < MAX_INVENTORY; i++ ) {
|
|
|
- if( sd->status.inventory[i].nameid == item->nameid &&
|
|
|
- sd->status.inventory[i].bound == item->bound &&
|
|
|
- sd->status.inventory[i].expire_time == 0 &&
|
|
|
- sd->status.inventory[i].unique_id == item->unique_id &&
|
|
|
- memcmp(&sd->status.inventory[i].card, &item->card, sizeof(item->card)) == 0
|
|
|
- )
|
|
|
- {
|
|
|
- if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( id->stack.inventory && amount > id->stack.amount - sd->status.inventory[i].amount ) )
|
|
|
+ if( sd->inventory.u.items_inventory[i].nameid == item->nameid &&
|
|
|
+ sd->inventory.u.items_inventory[i].bound == item->bound &&
|
|
|
+ sd->inventory.u.items_inventory[i].expire_time == 0 &&
|
|
|
+ sd->inventory.u.items_inventory[i].unique_id == item->unique_id &&
|
|
|
+ memcmp(&sd->inventory.u.items_inventory[i].card, &item->card, sizeof(item->card)) == 0 ) {
|
|
|
+ if( amount > MAX_AMOUNT - sd->inventory.u.items_inventory[i].amount || ( id->stack.inventory && amount > id->stack.amount - sd->inventory.u.items_inventory[i].amount ) )
|
|
|
return ADDITEM_OVERAMOUNT;
|
|
|
- sd->status.inventory[i].amount += amount;
|
|
|
+ sd->inventory.u.items_inventory[i].amount += amount;
|
|
|
clif_additem(sd,i,amount,0);
|
|
|
break;
|
|
|
}
|
|
@@ -4373,24 +4353,24 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p
|
|
|
if( i < 0 )
|
|
|
return ADDITEM_OVERITEM;
|
|
|
|
|
|
- memcpy(&sd->status.inventory[i], item, sizeof(sd->status.inventory[0]));
|
|
|
+ memcpy(&sd->inventory.u.items_inventory[i], item, sizeof(sd->inventory.u.items_inventory[0]));
|
|
|
// clear equip and favorite fields first, just in case
|
|
|
if( item->equip )
|
|
|
- sd->status.inventory[i].equip = 0;
|
|
|
+ sd->inventory.u.items_inventory[i].equip = 0;
|
|
|
if( item->favorite )
|
|
|
- sd->status.inventory[i].favorite = 0;
|
|
|
+ sd->inventory.u.items_inventory[i].favorite = 0;
|
|
|
|
|
|
- sd->status.inventory[i].amount = amount;
|
|
|
+ sd->inventory.u.items_inventory[i].amount = amount;
|
|
|
sd->inventory_data[i] = id;
|
|
|
sd->last_addeditem_index = i;
|
|
|
|
|
|
if (!itemdb_isstackable2(id) || id->flag.guid)
|
|
|
- sd->status.inventory[i].unique_id = item->unique_id ? item->unique_id : pc_generate_unique_id(sd);
|
|
|
+ sd->inventory.u.items_inventory[i].unique_id = item->unique_id ? item->unique_id : pc_generate_unique_id(sd);
|
|
|
|
|
|
clif_additem(sd,i,amount,0);
|
|
|
}
|
|
|
|
|
|
- log_pick_pc(sd, log_type, amount, &sd->status.inventory[i]);
|
|
|
+ log_pick_pc(sd, log_type, amount, &sd->inventory.u.items_inventory[i]);
|
|
|
|
|
|
sd->weight += w;
|
|
|
clif_updatestatus(sd,SP_WEIGHT);
|
|
@@ -4401,11 +4381,11 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p
|
|
|
/* rental item check */
|
|
|
if( item->expire_time ) {
|
|
|
if( time(NULL) > item->expire_time ) {
|
|
|
- clif_rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
|
|
|
- pc_delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
|
|
|
+ clif_rental_expired(sd->fd, i, sd->inventory.u.items_inventory[i].nameid);
|
|
|
+ pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
|
|
|
} else {
|
|
|
unsigned int seconds = (unsigned int)( item->expire_time - time(NULL) );
|
|
|
- clif_rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
|
|
|
+ clif_rental_time(sd->fd, sd->inventory.u.items_inventory[i].nameid, seconds);
|
|
|
pc_inventory_rental_add(sd, seconds);
|
|
|
}
|
|
|
}
|
|
@@ -4427,17 +4407,17 @@ char pc_delitem(struct map_session_data *sd,int n,int amount,int type, short rea
|
|
|
{
|
|
|
nullpo_retr(1, sd);
|
|
|
|
|
|
- if(n < 0 || sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
|
|
|
+ if(n < 0 || sd->inventory.u.items_inventory[n].nameid == 0 || amount <= 0 || sd->inventory.u.items_inventory[n].amount<amount || sd->inventory_data[n] == NULL)
|
|
|
return 1;
|
|
|
|
|
|
- log_pick_pc(sd, log_type, -amount, &sd->status.inventory[n]);
|
|
|
+ log_pick_pc(sd, log_type, -amount, &sd->inventory.u.items_inventory[n]);
|
|
|
|
|
|
- sd->status.inventory[n].amount -= amount;
|
|
|
+ sd->inventory.u.items_inventory[n].amount -= amount;
|
|
|
sd->weight -= sd->inventory_data[n]->weight*amount ;
|
|
|
- if( sd->status.inventory[n].amount <= 0 ){
|
|
|
- if(sd->status.inventory[n].equip)
|
|
|
+ if( sd->inventory.u.items_inventory[n].amount <= 0 ){
|
|
|
+ if(sd->inventory.u.items_inventory[n].equip)
|
|
|
pc_unequipitem(sd,n,3);
|
|
|
- memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
|
|
|
+ memset(&sd->inventory.u.items_inventory[n],0,sizeof(sd->inventory.u.items_inventory[0]));
|
|
|
sd->inventory_data[n] = NULL;
|
|
|
}
|
|
|
if(!(type&1))
|
|
@@ -4465,9 +4445,9 @@ bool pc_dropitem(struct map_session_data *sd,int n,int amount)
|
|
|
if(amount <= 0)
|
|
|
return false;
|
|
|
|
|
|
- if(sd->status.inventory[n].nameid <= 0 ||
|
|
|
- sd->status.inventory[n].amount <= 0 ||
|
|
|
- sd->status.inventory[n].amount < amount ||
|
|
|
+ if(sd->inventory.u.items_inventory[n].nameid <= 0 ||
|
|
|
+ sd->inventory.u.items_inventory[n].amount <= 0 ||
|
|
|
+ sd->inventory.u.items_inventory[n].amount < amount ||
|
|
|
sd->state.trading || sd->state.vending ||
|
|
|
!sd->inventory_data[n] //pc_delitem would fail on this case.
|
|
|
)
|
|
@@ -4479,13 +4459,13 @@ bool pc_dropitem(struct map_session_data *sd,int n,int amount)
|
|
|
return false; //Can't drop items in nodrop mapflag maps.
|
|
|
}
|
|
|
|
|
|
- if( !pc_candrop(sd,&sd->status.inventory[n]) )
|
|
|
+ if( !pc_candrop(sd,&sd->inventory.u.items_inventory[n]) )
|
|
|
{
|
|
|
clif_displaymessage (sd->fd, msg_txt(sd,263));
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2, 0))
|
|
|
+ if (!map_addflooritem(&sd->inventory.u.items_inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2, 0))
|
|
|
return false;
|
|
|
|
|
|
pc_delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER);
|
|
@@ -4582,7 +4562,7 @@ bool pc_isUseitem(struct map_session_data *sd,int n)
|
|
|
nullpo_ret(sd);
|
|
|
|
|
|
item = sd->inventory_data[n];
|
|
|
- nameid = sd->status.inventory[n].nameid;
|
|
|
+ nameid = sd->inventory.u.items_inventory[n].nameid;
|
|
|
|
|
|
if( item == NULL )
|
|
|
return false;
|
|
@@ -4775,7 +4755,7 @@ int pc_useitem(struct map_session_data *sd,int n)
|
|
|
return 0;
|
|
|
#endif
|
|
|
}
|
|
|
- item = sd->status.inventory[n];
|
|
|
+ item = sd->inventory.u.items_inventory[n];
|
|
|
id = sd->inventory_data[n];
|
|
|
|
|
|
if (item.nameid == 0 || item.amount <= 0)
|
|
@@ -4889,17 +4869,14 @@ unsigned char pc_cart_additem(struct map_session_data *sd,struct item *item,int
|
|
|
if( (w = data->weight*amount) + sd->cart_weight > sd->cart_weight_max )
|
|
|
return 1;
|
|
|
|
|
|
- // ID no longer points to inventory/kafra ID. While we get a new one we don't want to mess up vending creation.
|
|
|
- item->id = 0;
|
|
|
-
|
|
|
i = MAX_CART;
|
|
|
if( itemdb_isstackable2(data) && !item->expire_time )
|
|
|
{
|
|
|
for (i = 0; i < MAX_CART; i++) {
|
|
|
- if (sd->status.cart[i].nameid == item->nameid
|
|
|
- && sd->status.cart[i].bound == item->bound
|
|
|
- && sd->status.cart[i].unique_id == item->unique_id
|
|
|
- && memcmp(sd->status.cart[i].card, item->card, sizeof(item->card)) == 0
|
|
|
+ if (sd->cart.u.items_cart[i].nameid == item->nameid
|
|
|
+ && sd->cart.u.items_cart[i].bound == item->bound
|
|
|
+ && sd->cart.u.items_cart[i].unique_id == item->unique_id
|
|
|
+ && memcmp(sd->cart.u.items_cart[i].card, item->card, sizeof(item->card)) == 0
|
|
|
)
|
|
|
break;
|
|
|
}
|
|
@@ -4907,25 +4884,25 @@ unsigned char pc_cart_additem(struct map_session_data *sd,struct item *item,int
|
|
|
|
|
|
if( i < MAX_CART )
|
|
|
{// item already in cart, stack it
|
|
|
- if( amount > MAX_AMOUNT - sd->status.cart[i].amount || ( data->stack.cart && amount > data->stack.amount - sd->status.cart[i].amount ) )
|
|
|
+ if( amount > MAX_AMOUNT - sd->cart.u.items_cart[i].amount || ( data->stack.cart && amount > data->stack.amount - sd->cart.u.items_cart[i].amount ) )
|
|
|
return 2; // no slot
|
|
|
|
|
|
- sd->status.cart[i].amount+=amount;
|
|
|
+ sd->cart.u.items_cart[i].amount += amount;
|
|
|
clif_cart_additem(sd,i,amount,0);
|
|
|
}
|
|
|
else
|
|
|
{// item not stackable or not present, add it
|
|
|
- ARR_FIND( 0, MAX_CART, i, sd->status.cart[i].nameid == 0 );
|
|
|
+ ARR_FIND( 0, MAX_CART, i, sd->cart.u.items_cart[i].nameid == 0 );
|
|
|
if( i == MAX_CART )
|
|
|
return 2; // no slot
|
|
|
|
|
|
- memcpy(&sd->status.cart[i],item,sizeof(sd->status.cart[0]));
|
|
|
- sd->status.cart[i].amount=amount;
|
|
|
+ memcpy(&sd->cart.u.items_cart[i],item,sizeof(sd->cart.u.items_cart[0]));
|
|
|
+ sd->cart.u.items_cart[i].amount = amount;
|
|
|
sd->cart_num++;
|
|
|
clif_cart_additem(sd,i,amount,0);
|
|
|
}
|
|
|
- sd->status.cart[i].favorite = 0;/* clear */
|
|
|
- log_pick_pc(sd, log_type, amount, &sd->status.cart[i]);
|
|
|
+ sd->cart.u.items_cart[i].favorite = 0; // clear
|
|
|
+ log_pick_pc(sd, log_type, amount, &sd->cart.u.items_cart[i]);
|
|
|
|
|
|
sd->cart_weight += w;
|
|
|
clif_updatestatus(sd,SP_CARTINFO);
|
|
@@ -4940,16 +4917,16 @@ void pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log
|
|
|
{
|
|
|
nullpo_retv(sd);
|
|
|
|
|
|
- if(sd->status.cart[n].nameid == 0 ||
|
|
|
- sd->status.cart[n].amount<amount)
|
|
|
+ if(sd->cart.u.items_cart[n].nameid == 0 ||
|
|
|
+ sd->cart.u.items_cart[n].amount < amount)
|
|
|
return;
|
|
|
|
|
|
- log_pick_pc(sd, log_type, -amount, &sd->status.cart[n]);
|
|
|
+ log_pick_pc(sd, log_type, -amount, &sd->cart.u.items_cart[n]);
|
|
|
|
|
|
- sd->status.cart[n].amount -= amount;
|
|
|
- sd->cart_weight -= itemdb_weight(sd->status.cart[n].nameid)*amount ;
|
|
|
- if(sd->status.cart[n].amount <= 0){
|
|
|
- memset(&sd->status.cart[n],0,sizeof(sd->status.cart[0]));
|
|
|
+ sd->cart.u.items_cart[n].amount -= amount;
|
|
|
+ sd->cart_weight -= itemdb_weight(sd->cart.u.items_cart[n].nameid) * amount;
|
|
|
+ if(sd->cart.u.items_cart[n].amount <= 0) {
|
|
|
+ memset(&sd->cart.u.items_cart[n],0,sizeof(sd->cart.u.items_cart[0]));
|
|
|
sd->cart_num--;
|
|
|
}
|
|
|
if(!type) {
|
|
@@ -4971,7 +4948,7 @@ void pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
|
|
|
if (idx < 0 || idx >= MAX_INVENTORY) //Invalid index check [Skotlex]
|
|
|
return;
|
|
|
|
|
|
- item_data = &sd->status.inventory[idx];
|
|
|
+ item_data = &sd->inventory.u.items_inventory[idx];
|
|
|
|
|
|
if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
|
|
|
return;
|
|
@@ -4996,7 +4973,7 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount)
|
|
|
|
|
|
nullpo_retr(-1, sd);
|
|
|
|
|
|
- item_data = &sd->status.cart[idx];
|
|
|
+ item_data = &sd->cart.u.items_cart[idx];
|
|
|
if( item_data->nameid == 0 || item_data->amount == 0 )
|
|
|
return -1;
|
|
|
|
|
@@ -5016,7 +4993,7 @@ void pc_getitemfromcart(struct map_session_data *sd,int idx,int amount)
|
|
|
if (idx < 0 || idx >= MAX_CART) //Invalid index check [Skotlex]
|
|
|
return;
|
|
|
|
|
|
- item_data=&sd->status.cart[idx];
|
|
|
+ item_data=&sd->cart.u.items_cart[idx];
|
|
|
|
|
|
if(item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
|
|
|
return;
|
|
@@ -5038,9 +5015,9 @@ void pc_getitemfromcart(struct map_session_data *sd,int idx,int amount)
|
|
|
*------------------------------------------*/
|
|
|
int pc_bound_chk(TBL_PC *sd,enum bound_type type,int *idxlist)
|
|
|
{
|
|
|
- int i=0, j=0;
|
|
|
- for(i=0;i<MAX_INVENTORY;i++){
|
|
|
- if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0 && sd->status.inventory[i].bound == type) {
|
|
|
+ int i = 0, j = 0;
|
|
|
+ for(i = 0; i < MAX_INVENTORY; i++) {
|
|
|
+ if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].amount > 0 && sd->inventory.u.items_inventory[i].bound == type) {
|
|
|
idxlist[j] = i;
|
|
|
j++;
|
|
|
}
|
|
@@ -5603,7 +5580,7 @@ bool pc_checkequip2(struct map_session_data *sd, unsigned short nameid, int min,
|
|
|
if(equip_pos[i]) {
|
|
|
int idx = sd->equip_index[i];
|
|
|
|
|
|
- if (sd->status.inventory[idx].nameid == nameid)
|
|
|
+ if (sd->inventory.u.items_inventory[idx].nameid == nameid)
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -7602,8 +7579,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|
|
|
int eq_num=0,eq_n[MAX_INVENTORY];
|
|
|
memset(eq_n,0,sizeof(eq_n));
|
|
|
for(i=0;i<MAX_INVENTORY;i++) {
|
|
|
- if( (type == 1 && !sd->status.inventory[i].equip)
|
|
|
- || (type == 2 && sd->status.inventory[i].equip)
|
|
|
+ if( (type == 1 && !sd->inventory.u.items_inventory[i].equip)
|
|
|
+ || (type == 2 && sd->inventory.u.items_inventory[i].equip)
|
|
|
|| type == 3)
|
|
|
{
|
|
|
int l;
|
|
@@ -7617,7 +7594,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|
|
|
if(eq_num > 0){
|
|
|
int n = eq_n[rnd()%eq_num];
|
|
|
if(rnd()%10000 < per) {
|
|
|
- if(sd->status.inventory[n].equip)
|
|
|
+ if(sd->inventory.u.items_inventory[n].equip)
|
|
|
pc_unequipitem(sd,n,3);
|
|
|
pc_dropitem(sd,n,1);
|
|
|
}
|
|
@@ -7625,12 +7602,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|
|
|
}
|
|
|
else if(id > 0) {
|
|
|
for(i=0;i<MAX_INVENTORY;i++){
|
|
|
- if(sd->status.inventory[i].nameid == id
|
|
|
+ if(sd->inventory.u.items_inventory[i].nameid == id
|
|
|
&& rnd()%10000 < per
|
|
|
- && ((type == 1 && !sd->status.inventory[i].equip)
|
|
|
- || (type == 2 && sd->status.inventory[i].equip)
|
|
|
+ && ((type == 1 && !sd->inventory.u.items_inventory[i].equip)
|
|
|
+ || (type == 2 && sd->inventory.u.items_inventory[i].equip)
|
|
|
|| type == 3) ){
|
|
|
- if(sd->status.inventory[i].equip)
|
|
|
+ if(sd->inventory.u.items_inventory[i].equip)
|
|
|
pc_unequipitem(sd,i,3);
|
|
|
pc_dropitem(sd,i,1);
|
|
|
break;
|
|
@@ -9216,16 +9193,16 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
|
|
|
continue;
|
|
|
}
|
|
|
combo_idx[j].idx = index;
|
|
|
- pos |= sd->status.inventory[index].equip;
|
|
|
+ pos |= sd->inventory.u.items_inventory[index].equip;
|
|
|
found = true;
|
|
|
break;
|
|
|
} else { //Cards
|
|
|
uint16 z;
|
|
|
- if ( sd->inventory_data[index]->slot == 0 || itemdb_isspecial(sd->status.inventory[index].card[0]) )
|
|
|
+ if ( sd->inventory_data[index]->slot == 0 || itemdb_isspecial(sd->inventory.u.items_inventory[index].card[0]) )
|
|
|
continue;
|
|
|
for (z = 0; z < sd->inventory_data[index]->slot; z++) {
|
|
|
bool do_continue=false;
|
|
|
- if (sd->status.inventory[index].card[z] != id)
|
|
|
+ if (sd->inventory.u.items_inventory[index].card[z] != id)
|
|
|
continue;
|
|
|
if(j>0){
|
|
|
int c1, c2;
|
|
@@ -9244,7 +9221,7 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
|
|
|
continue;
|
|
|
combo_idx[j].idx = index;
|
|
|
combo_idx[j].card[z] = id;
|
|
|
- pos |= sd->status.inventory[index].equip;
|
|
|
+ pos |= sd->inventory.u.items_inventory[index].equip;
|
|
|
found = true;
|
|
|
break;
|
|
|
}
|
|
@@ -9350,13 +9327,13 @@ int pc_load_combo(struct map_session_data *sd) {
|
|
|
continue;
|
|
|
if( id->combos_count )
|
|
|
ret += pc_checkcombo(sd,id);
|
|
|
- if(!itemdb_isspecial(sd->status.inventory[idx].card[0])) {
|
|
|
+ if(!itemdb_isspecial(sd->inventory.u.items_inventory[idx].card[0])) {
|
|
|
struct item_data *data;
|
|
|
int j;
|
|
|
for( j = 0; j < id->slot; j++ ) {
|
|
|
- if (!sd->status.inventory[idx].card[j])
|
|
|
+ if (!sd->inventory.u.items_inventory[idx].card[j])
|
|
|
continue;
|
|
|
- if ( ( data = itemdb_exists(sd->status.inventory[idx].card[j]) ) != NULL ) {
|
|
|
+ if ( ( data = itemdb_exists(sd->inventory.u.items_inventory[idx].card[j]) ) != NULL ) {
|
|
|
if( data->combos_count )
|
|
|
ret += pc_checkcombo(sd,data);
|
|
|
}
|
|
@@ -9391,14 +9368,14 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
|
pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
|
|
|
|
|
|
if(battle_config.battle_log)
|
|
|
- ShowInfo("equip %hu(%d) %x:%x\n",sd->status.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))) {
|
|
|
clif_equipitemack(sd,n,0,res); // fail
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (!(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.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
|
|
|
return false;
|
|
|
}
|
|
@@ -9440,8 +9417,8 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (id->flag.bindOnEquip && !sd->status.inventory[n].bound) {
|
|
|
- sd->status.inventory[n].bound = (char)battle_config.default_bind_on_equip;
|
|
|
+ if (id->flag.bindOnEquip && !sd->inventory.u.items_inventory[n].bound) {
|
|
|
+ sd->inventory.u.items_inventory[n].bound = (char)battle_config.default_bind_on_equip;
|
|
|
clif_notify_bindOnEquip(sd,n);
|
|
|
}
|
|
|
|
|
@@ -9488,7 +9465,7 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
|
else
|
|
|
clif_equipitemack(sd,n,pos,ITEM_EQUIP_ACK_OK);
|
|
|
|
|
|
- sd->status.inventory[n].equip=pos;
|
|
|
+ sd->inventory.u.items_inventory[n].equip = pos;
|
|
|
|
|
|
if(pos & EQP_HAND_R) {
|
|
|
if(id)
|
|
@@ -9576,14 +9553,14 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
|
/* check for combos (MUST be before status_calc_pc) */
|
|
|
if( id->combos_count )
|
|
|
pc_checkcombo(sd,id);
|
|
|
- if(itemdb_isspecial(sd->status.inventory[n].card[0]))
|
|
|
+ if(itemdb_isspecial(sd->inventory.u.items_inventory[n].card[0]))
|
|
|
; //No cards
|
|
|
else {
|
|
|
for( i = 0; i < id->slot; i++ ) {
|
|
|
struct item_data *data;
|
|
|
- if (!sd->status.inventory[n].card[i])
|
|
|
+ if (!sd->inventory.u.items_inventory[n].card[i])
|
|
|
continue;
|
|
|
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
|
|
|
+ if ( ( data = itemdb_exists(sd->inventory.u.items_inventory[n].card[i]) ) != NULL ) {
|
|
|
if( data->combos_count )
|
|
|
pc_checkcombo(sd,data);
|
|
|
}
|
|
@@ -9599,14 +9576,14 @@ bool pc_equipitem(struct map_session_data *sd,short n,int req_pos)
|
|
|
//only run the script if item isn't restricted
|
|
|
if (id->equip_script && (pc_has_permission(sd,PC_PERM_USE_ALL_EQUIPMENT) || !itemdb_isNoEquip(id,sd->bl.m)))
|
|
|
run_script(id->equip_script,0,sd->bl.id,fake_nd->bl.id);
|
|
|
- if(itemdb_isspecial(sd->status.inventory[n].card[0]))
|
|
|
+ if(itemdb_isspecial(sd->inventory.u.items_inventory[n].card[0]))
|
|
|
; //No cards
|
|
|
else {
|
|
|
for( i = 0; i < id->slot; i++ ) {
|
|
|
struct item_data *data;
|
|
|
- if (!sd->status.inventory[n].card[i])
|
|
|
+ if (!sd->inventory.u.items_inventory[n].card[i])
|
|
|
continue;
|
|
|
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
|
|
|
+ if ( ( data = itemdb_exists(sd->inventory.u.items_inventory[n].card[i]) ) != NULL ) {
|
|
|
if (data->equip_script && (pc_has_permission(sd,PC_PERM_USE_ALL_EQUIPMENT) || !itemdb_isNoEquip(data,sd->bl.m)))
|
|
|
run_script(data->equip_script,0,sd->bl.id,fake_nd->bl.id);
|
|
|
}
|
|
@@ -9636,7 +9613,7 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
clif_unequipitemack(sd,0,0,0);
|
|
|
return false;
|
|
|
}
|
|
|
- if (!sd->status.inventory[n].equip) {
|
|
|
+ if (!sd->inventory.u.items_inventory[n].equip) {
|
|
|
clif_unequipitemack(sd,n,0,0);
|
|
|
return false; //Nothing to unequip
|
|
|
}
|
|
@@ -9654,14 +9631,18 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
}
|
|
|
|
|
|
if (battle_config.battle_log)
|
|
|
- ShowInfo("unequip %d %x:%x\n",n,pc_equippoint(sd,n),sd->status.inventory[n].equip);
|
|
|
+ ShowInfo("unequip %d %x:%x\n",n,pc_equippoint(sd,n),sd->inventory.u.items_inventory[n].equip);
|
|
|
|
|
|
+ if (!sd->inventory.u.items_inventory[n].equip) { //Nothing to unequip
|
|
|
+ clif_unequipitemack(sd, n, 0, 0);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
for(i = 0; i < EQI_MAX; i++) {
|
|
|
- if (sd->status.inventory[n].equip & equip_pos[i])
|
|
|
+ if (sd->inventory.u.items_inventory[n].equip & equip_pos[i])
|
|
|
sd->equip_index[i] = -1;
|
|
|
}
|
|
|
|
|
|
- if(sd->status.inventory[n].equip & EQP_HAND_R) {
|
|
|
+ if(sd->inventory.u.items_inventory[n].equip & EQP_HAND_R) {
|
|
|
sd->weapontype1 = 0;
|
|
|
sd->status.weapon = sd->weapontype2;
|
|
|
pc_calcweapontype(sd);
|
|
@@ -9669,57 +9650,57 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
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) {
|
|
|
+ if(sd->inventory.u.items_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 ) {
|
|
|
+ if(sd->inventory.u.items_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 ) {
|
|
|
+ if(sd->inventory.u.items_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 ) {
|
|
|
+ if(sd->inventory.u.items_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) {
|
|
|
+ if(sd->inventory.u.items_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) {
|
|
|
+ if(sd->inventory.u.items_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) {
|
|
|
+ if(sd->inventory.u.items_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);
|
|
|
}
|
|
|
|
|
|
- if(sd->status.inventory[n].equip & EQP_SHOES)
|
|
|
+ if(sd->inventory.u.items_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) {
|
|
|
+ if(sd->inventory.u.items_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) {
|
|
|
+ if(sd->inventory.u.items_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,1);
|
|
|
+ clif_unequipitemack(sd,n,sd->inventory.u.items_inventory[n].equip,1);
|
|
|
|
|
|
status_change_end(&sd->bl,SC_HEAT_BARREL,INVALID_TIMER);
|
|
|
// On weapon change (right and left hand)
|
|
|
- if ((sd->status.inventory[n].equip & EQP_ARMS) && sd->inventory_data[n]->type == IT_WEAPON) {
|
|
|
+ if ((sd->inventory.u.items_inventory[n].equip & EQP_ARMS) && sd->inventory_data[n]->type == IT_WEAPON) {
|
|
|
if (!sd->sc.data[SC_SEVENWIND] || sd->sc.data[SC_ASPERSIO]) //Check for seven wind (but not level seven!)
|
|
|
skill_enchant_elemental_end(&sd->bl, SC_NONE);
|
|
|
status_change_end(&sd->bl, SC_FEARBREEZE, INVALID_TIMER);
|
|
@@ -9728,7 +9709,7 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
}
|
|
|
|
|
|
// On armor change
|
|
|
- if (sd->status.inventory[n].equip & EQP_ARMOR) {
|
|
|
+ if (sd->inventory.u.items_inventory[n].equip & EQP_ARMOR) {
|
|
|
if (sd->sc.data[SC_HOVERING] && sd->inventory_data[n]->nameid == ITEMID_HOVERING_BOOSTER)
|
|
|
status_change_end(&sd->bl, SC_HOVERING, INVALID_TIMER);
|
|
|
//status_change_end(&sd->bl, SC_BENEDICTIO, INVALID_TIMER); // No longer is removed? Need confirmation
|
|
@@ -9739,10 +9720,10 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
if (sd->inventory_data[n]->type == IT_AMMO)
|
|
|
status_change_end(&sd->bl, SC_P_ALTER, INVALID_TIMER);
|
|
|
|
|
|
- if( sd->state.autobonus&sd->status.inventory[n].equip )
|
|
|
- sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish]
|
|
|
+ if (sd->state.autobonus&sd->inventory.u.items_inventory[n].equip)
|
|
|
+ sd->state.autobonus &= ~sd->inventory.u.items_inventory[n].equip; //Check for activated autobonus [Inkfish]
|
|
|
|
|
|
- sd->status.inventory[n].equip = 0;
|
|
|
+ sd->inventory.u.items_inventory[n].equip = 0;
|
|
|
iflag = sd->npc_item_flag;
|
|
|
|
|
|
/* check for combos (MUST be before status_calc_pc) */
|
|
@@ -9750,15 +9731,15 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
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]))
|
|
|
+ } if(itemdb_isspecial(sd->inventory.u.items_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 (!sd->inventory.u.items_inventory[n].card[i])
|
|
|
continue;
|
|
|
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
|
|
|
+ if ( ( data = itemdb_exists(sd->inventory.u.items_inventory[n].card[i]) ) != NULL ) {
|
|
|
if( data->combos_count ) {
|
|
|
if( pc_removecombo(sd,data) )
|
|
|
status_cacl = true;
|
|
@@ -9780,15 +9761,15 @@ bool pc_unequipitem(struct map_session_data *sd, int n, int flag) {
|
|
|
if (sd->inventory_data[n]) {
|
|
|
if (sd->inventory_data[n]->unequip_script)
|
|
|
run_script(sd->inventory_data[n]->unequip_script,0,sd->bl.id,fake_nd->bl.id);
|
|
|
- if(itemdb_isspecial(sd->status.inventory[n].card[0]))
|
|
|
+ if(itemdb_isspecial(sd->inventory.u.items_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 (!sd->inventory.u.items_inventory[n].card[i])
|
|
|
continue;
|
|
|
|
|
|
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
|
|
|
+ if ( ( data = itemdb_exists(sd->inventory.u.items_inventory[n].card[i]) ) != NULL ) {
|
|
|
if( data->unequip_script )
|
|
|
run_script(data->unequip_script,0,sd->bl.id,fake_nd->bl.id);
|
|
|
}
|
|
@@ -9814,10 +9795,10 @@ void pc_checkitem(struct map_session_data *sd) {
|
|
|
if( sd->state.vending ) //Avoid reorganizing items when we are vending, as that leads to exploits (pointed out by End of Exam)
|
|
|
return;
|
|
|
|
|
|
- pc_check_available_item(sd); // Check for invalid(ated) items.
|
|
|
+ pc_check_available_item(sd, ITMCHK_NONE); // Check for invalid(ated) items.
|
|
|
|
|
|
for( i = 0; i < MAX_INVENTORY; i++ ) {
|
|
|
- it = sd->status.inventory[i];
|
|
|
+ it = sd->inventory.u.items_inventory[i];
|
|
|
|
|
|
if( it.nameid == 0 )
|
|
|
continue;
|
|
@@ -9844,8 +9825,13 @@ void pc_checkitem(struct map_session_data *sd) {
|
|
|
|
|
|
/*==========================================
|
|
|
* Checks for unavailable items and removes them.
|
|
|
+ * @param sd: Player data
|
|
|
+ * @param type Forced check:
|
|
|
+ * 1 - Inventory
|
|
|
+ * 2 - Cart
|
|
|
+ * 4 - Storage
|
|
|
*------------------------------------------*/
|
|
|
-void pc_check_available_item(struct map_session_data *sd)
|
|
|
+void pc_check_available_item(struct map_session_data *sd, uint8 type)
|
|
|
{
|
|
|
int i;
|
|
|
unsigned short nameid;
|
|
@@ -9853,57 +9839,57 @@ void pc_check_available_item(struct map_session_data *sd)
|
|
|
|
|
|
nullpo_retv(sd);
|
|
|
|
|
|
- if (battle_config.item_check&0x1) { // Check for invalid(ated) items in inventory.
|
|
|
+ if (battle_config.item_check&ITMCHK_INVENTORY || type&ITMCHK_INVENTORY) { // Check for invalid(ated) items in inventory.
|
|
|
for(i = 0; i < MAX_INVENTORY; i++) {
|
|
|
- nameid = sd->status.inventory[i].nameid;
|
|
|
+ nameid = sd->inventory.u.items_inventory[i].nameid;
|
|
|
|
|
|
if (!nameid)
|
|
|
continue;
|
|
|
if (!itemdb_available(nameid)) {
|
|
|
sprintf(output, msg_txt(sd, 709), nameid); // Item %hu has been removed from your inventory.
|
|
|
clif_displaymessage(sd->fd, output);
|
|
|
- ShowWarning("Removed invalid/disabled item id %hu from inventory (amount=%d, char_id=%d).\n", nameid, sd->status.inventory[i].amount, sd->status.char_id);
|
|
|
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
|
|
|
+ ShowWarning("Removed invalid/disabled item (ID: %hu, amount: %d) from inventory (char_id: %d).\n", nameid, sd->inventory.u.items_inventory[i].amount, sd->status.char_id);
|
|
|
+ pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
|
|
|
continue;
|
|
|
}
|
|
|
- if (!sd->status.inventory[i].unique_id && !itemdb_isstackable(nameid))
|
|
|
- sd->status.inventory[i].unique_id = pc_generate_unique_id(sd);
|
|
|
+ if (!sd->inventory.u.items_inventory[i].unique_id && !itemdb_isstackable(nameid))
|
|
|
+ sd->inventory.u.items_inventory[i].unique_id = pc_generate_unique_id(sd);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (battle_config.item_check&0x2) { // Check for invalid(ated) items in cart.
|
|
|
+ if (battle_config.item_check&ITMCHK_CART || type&ITMCHK_CART) { // Check for invalid(ated) items in cart.
|
|
|
for(i = 0; i < MAX_CART; i++) {
|
|
|
- nameid = sd->status.cart[i].nameid;
|
|
|
+ nameid = sd->cart.u.items_cart[i].nameid;
|
|
|
|
|
|
if (!nameid)
|
|
|
continue;
|
|
|
if (!itemdb_available(nameid)) {
|
|
|
sprintf(output, msg_txt(sd, 710), nameid); // Item %hu has been removed from your cart.
|
|
|
clif_displaymessage(sd->fd, output);
|
|
|
- ShowWarning("Removed invalid/disabled item id %hu from cart (amount=%d, char_id=%d).\n", nameid, sd->status.cart[i].amount, sd->status.char_id);
|
|
|
- pc_cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER);
|
|
|
+ ShowWarning("Removed invalid/disabled item (ID: %hu, amount: %d) from cart (char_id: %d).\n", nameid, sd->cart.u.items_cart[i].amount, sd->status.char_id);
|
|
|
+ pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 0, LOG_TYPE_OTHER);
|
|
|
continue;
|
|
|
}
|
|
|
- if (!sd->status.cart[i].unique_id && !itemdb_isstackable(nameid))
|
|
|
- sd->status.cart[i].unique_id = pc_generate_unique_id(sd);
|
|
|
+ if (!sd->cart.u.items_cart[i].unique_id && !itemdb_isstackable(nameid))
|
|
|
+ sd->cart.u.items_cart[i].unique_id = pc_generate_unique_id(sd);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (battle_config.item_check&0x4) { // Check for invalid(ated) items in storage.
|
|
|
+ if (battle_config.item_check&ITMCHK_STORAGE || type&ITMCHK_STORAGE) { // Check for invalid(ated) items in storage.
|
|
|
for(i = 0; i < sd->storage_size; i++) {
|
|
|
- nameid = sd->status.storage.items[i].nameid;
|
|
|
+ nameid = sd->storage.u.items_storage[i].nameid;
|
|
|
|
|
|
if (!nameid)
|
|
|
continue;
|
|
|
if (!itemdb_available(nameid)) {
|
|
|
sprintf(output, msg_txt(sd, 711), nameid); // Item %hu has been removed from your storage.
|
|
|
clif_displaymessage(sd->fd, output);
|
|
|
- ShowWarning("Removed invalid/disabled item id %hu from storage (amount=%d, char_id=%d).\n", nameid, sd->status.storage.items[i].amount, sd->status.char_id);
|
|
|
- storage_delitem(sd, i, sd->status.storage.items[i].amount);
|
|
|
+ ShowWarning("Removed invalid/disabled item (ID: %hu, amount: %d) from storage (char_id: %d).\n", nameid, sd->storage.u.items_storage[i].amount, sd->status.char_id);
|
|
|
+ storage_delitem(sd, i, sd->storage.u.items_storage[i].amount);
|
|
|
continue;
|
|
|
}
|
|
|
- if (!sd->status.storage.items[i].unique_id && !itemdb_isstackable(nameid))
|
|
|
- sd->status.storage.items[i].unique_id = pc_generate_unique_id(sd);
|
|
|
+ if (!sd->storage.u.items_storage[i].unique_id && !itemdb_isstackable(nameid))
|
|
|
+ sd->storage.u.items_storage[i].unique_id = pc_generate_unique_id(sd);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -10026,9 +10012,9 @@ bool pc_divorce(struct map_session_data *sd)
|
|
|
p_sd->status.partner_id = 0;
|
|
|
for( i = 0; i < MAX_INVENTORY; i++ )
|
|
|
{
|
|
|
- if( sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F )
|
|
|
+ if( sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_M || sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_F )
|
|
|
pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
|
|
|
- if( p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F )
|
|
|
+ if( p_sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_M || p_sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_F )
|
|
|
pc_delitem(p_sd, i, 1, 0, 0, LOG_TYPE_OTHER);
|
|
|
}
|
|
|
|