Beispiel #1
0
/**
 * Add an item to the storage from the inventory.
 * @param sd : player
 * @param index : inventory index to take the item from
 * @param amount : number of item to take
 * @return 0:fail, 1:success
 */
int storage_storageadd(struct map_session_data* sd, int index, int amount)
{
	nullpo_ret(sd);

	if( sd->status.storage.storage_amount > sd->storage_size )
		return 0; // storage full

	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;

	if( storage_additem(sd,&sd->status.inventory[index],amount) == 0 )
		pc_delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
	else {
		clif_dropitem(sd,index,0);
		return 0;
	}

	return 1;
}
Beispiel #2
0
/*==========================================
 * 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;
}
Beispiel #3
0
/**
 * Add an item to the storage from the inventory.
 * @param sd : player
 * @param stor : Storage data
 * @param index : inventory index to take the item from
 * @param amount : number of item to take
 * @return 0:fail, 1:success
 */
void storage_storageadd(struct map_session_data* sd, struct s_storage *stor, int index, int amount)
{
	enum e_storage_add result;

	nullpo_retv(sd);

	result = storage_canAddItem(stor, index, sd->inventory.u.items_inventory, amount, MAX_INVENTORY);
	if (result == STORAGE_ADD_INVALID)
		return;
	else if (result == STORAGE_ADD_OK) {
		switch( storage_additem(sd, stor, &sd->inventory.u.items_inventory[index], amount) ){
			case 0:
				pc_delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
				return;
			case 1:
				break;
			case 2:
				result = STORAGE_ADD_NOROOM;
				break;
		}
	}

	clif_storageitemremoved(sd,index,0);
	clif_dropitem(sd,index,0);
}
Beispiel #4
0
/*==========================================
 * Add an item to the storage
 *------------------------------------------*/
int storage_additem2(struct map_session_data *sd, struct item* item_data, int amount)
{
	nullpo_ret(sd);
	nullpo_ret(item_data);

	if( sd->status.storage.storage_amount > MAX_STORAGE )
		return 0;
	if( item_data->nameid <= 0 || amount <= 0 )
		return 0;
	if( amount > MAX_AMOUNT )
		return 0;
	if( storage_additem(sd,item_data,amount,0) == 0 )
		return 1;

	return 0;
}
Beispiel #5
0
/**
 * Move an item from cart to storage.
 * @param sd : player
 * @param stor : Storage data
 * @param index : cart index to take the item from
 * @param amount : number of item to take
 * @return 0:fail, 1:success
 */
void storage_storageaddfromcart(struct map_session_data *sd, struct s_storage *stor, int index, int amount)
{
	enum e_storage_add result;
	nullpo_retv(sd);

	result = storage_canAddItem(stor, index, sd->cart.u.items_inventory, amount, MAX_INVENTORY);
	if (result == STORAGE_ADD_INVALID)
		return;
	else if (result == STORAGE_ADD_OK && storage_additem(sd,stor,&sd->cart.u.items_cart[index],amount) == 0) {
		pc_cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);
		return;
	}

	clif_storageitemremoved(sd,index,0);
	clif_dropitem(sd,index,0);
}
Beispiel #6
0
/*==========================================
 * Move an item from cart to storage.
 * @index : cart inventory index
 * return
 *	0 : fail
 *	1 : success
 *------------------------------------------*/
int storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
	nullpo_ret(sd);

	if( sd->status.storage.storage_amount > MAX_STORAGE )
  		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,&sd->status.cart[index],amount) == 0 )
		pc_cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);

	return 1;
}
Beispiel #7
0
/*==========================================
 * カプラ倉庫へカートから入れる
 *------------------------------------------
 */
void storage_storageaddfromcart(struct map_session_data *sd, int idx, int amount)
{
	struct storage *stor;

	nullpo_retv(sd);
	nullpo_retv(stor = (struct storage *)numdb_search(storage_db,sd->status.account_id));

	if(!stor->storage_status)
		return;
	if(idx < 0 || idx >= MAX_CART)
		return;
	if(itemdb_isstorageable(sd->status.cart[idx].nameid) == 0)
		return;
	if(amount < 1 || amount > sd->status.cart[idx].amount)
		return;

	if(storage_additem(sd, stor, &sd->status.cart[idx], amount) == 0)
		pc_cart_delitem(sd, idx, amount, 0);

	return;
}
Beispiel #8
0
/**
 * Move an item from cart to storage.
 * @param sd : player
 * @param index : cart index to take the item from
 * @param amount : number of item to take
 * @return 0:fail, 1:success
 */
void storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
	nullpo_retv(sd);

	if( sd->status.storage.storage_amount > sd->storage_size )
		return; // storage full / storage closed

	if( index < 0 || index >= MAX_CART )
		return;

	if( sd->status.cart[index].nameid <= 0 )
		return; //No item there.

	if( amount < 1 || amount > sd->status.cart[index].amount )
		return;

	if( storage_additem(sd,&sd->status.cart[index],amount) == 0 )
		pc_cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);
	else {
		clif_storageitemremoved(sd,index,0);
		clif_dropitem(sd,index,0);
	}
}
Beispiel #9
0
/*==========================================
 * 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;
}