/*========================================== * Retrieve an item from the storage. *------------------------------------------ */ int storage_storageget(struct map_session_data *sd,int index,int amount) { struct storage *stor; int flag; nullpo_retr(0, sd); nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if(index<0 || index>=MAX_STORAGE) return 0; if(stor->storage_[index].nameid <= 0) return 0; //Nothing there if(amount < 1 || amount > stor->storage_[index].amount) return 0; if((flag = pc_additem(sd,&stor->storage_[index],amount)) == 0) storage_delitem(sd,stor,index,amount); else clif_additem(sd,0,0,flag); // log_fromstorage(sd, index, 0); return 1; }
/*========================================== * Add an item to the storage from the inventory. *------------------------------------------ */ int storage_storageadd(struct map_session_data *sd,int index,int amount) { struct storage *stor; nullpo_retr(0, sd); nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if((stor->storage_amount > MAX_STORAGE) || !stor->storage_status) return 0; // storage full / storage closed if(index<0 || index>=MAX_INVENTORY) return 0; if(sd->status.inventory[index].nameid <= 0) return 0; //No item on that spot if(amount < 1 || amount > sd->status.inventory[index].amount) return 0; // log_tostorage(sd, index, 0); if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0) // remove item from inventory pc_delitem(sd,index,amount,0); return 1; }
void storage_storage_dirty(struct map_session_data *sd) { struct storage *stor; stor=account2storage2(sd->status.account_id); if(stor) stor->dirty = 1; }
/*========================================== * When quitting the game. *------------------------------------------ */ int storage_storage_quit(struct map_session_data *sd, int flag) { struct storage *stor; nullpo_retr(0, sd); nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if (stor->storage_status) { if (save_settings&4) chrif_save(sd, flag); //Invokes the storage saving as well. else storage_storage_save(sd->status.account_id, flag); } stor->storage_status = 0; sd->state.storage_flag = 0; return 0; }
/*========================================== * Get from Storage to the Cart *------------------------------------------ */ int storage_storagegettocart(struct map_session_data *sd,int index,int amount) { struct storage *stor; nullpo_retr(0, sd); nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if(!stor->storage_status) return 0; if(index< 0 || index>=MAX_STORAGE) return 0; if(stor->storage_[index].nameid <= 0) return 0; //Nothing there. if(amount < 1 || amount > stor->storage_[index].amount) return 0; if(pc_cart_additem(sd,&stor->storage_[index],amount)==0) storage_delitem(sd,stor,index,amount); return 1; }
/*========================================== * Move an item from cart to storage. *------------------------------------------ */ int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount) { struct storage *stor; nullpo_retr(0, sd); nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if(stor->storage_amount > MAX_STORAGE || !stor->storage_status) return 0; // storage full / storage closed if(index< 0 || index>=MAX_CART) return 0; if(sd->status.cart[index].nameid <= 0) return 0; //No item there. if(amount < 1 || amount > sd->status.cart[index].amount) return 0; if(storage_additem(sd,stor,&sd->status.cart[index],amount)==0) pc_cart_delitem(sd,index,amount,0); return 1; }
void storage_storage_dirty(struct map_session_data *sd) { struct storage *stor; stor=account2storage2(sd->status.account_id); if(stor) stor->dirty = 1; } int storage_storage_save(int account_id, int final) { struct storage *stor; stor=account2storage2(account_id); if(!stor) return 0; if(stor->dirty) { if (final) { stor->dirty = 2; stor->storage_status = 0; //To prevent further manipulation of it. } intif_send_storage(stor); return 1; } if (final) { //Clear storage from memory. Nothing to save. storage_delete(account_id); return 1;
static void ladmin_itemfrob_c2(dumb_ptr<block_list> bl, ItemNameId source_id, ItemNameId dest_id) { #define IFIX(v) if (v == source_id) {v = dest_id; } #define FIX(item) ladmin_itemfrob_fix_item(source_id, dest_id, &item) if (!bl) return; switch (bl->bl_type) { case BL::PC: { dumb_ptr<map_session_data> pc = bl->is_player(); for (IOff0 j : IOff0::iter()) IFIX(pc->status.inventory[j].nameid); // cart is no longer supported // IFIX(pc->status.weapon); IFIX(pc->status.shield); IFIX(pc->status.head_top); IFIX(pc->status.head_mid); IFIX(pc->status.head_bottom); Option<P<Storage>> stor_ = account2storage2(pc->status_key.account_id); if OPTION_IS_SOME(stor, stor_) { for (SOff0 j : SOff0::iter()) FIX(stor->storage_[j]); } for (IOff0 j : IOff0::iter()) { P<struct item_data> item = TRY_UNWRAP(pc->inventory_data[j], continue); if (item->nameid == source_id) { item->nameid = dest_id; if (bool(item->equip)) pc_unequipitem(pc, j, CalcStatus::NOW); item->nameid = dest_id; } } break; } case BL::MOB: { dumb_ptr<mob_data> mob = bl->is_mob(); for (Item& itm : mob->lootitemv) FIX(itm); break; } case BL::ITEM: { dumb_ptr<flooritem_data> item = bl->is_item(); FIX(item->item_data); break; } } #undef FIX #undef IFIX }