コード例 #1
0
/*==========================================
 * Internal del-item function
 *------------------------------------------*/
int storage_delitem(struct map_session_data* sd, int n, int amount)
{
	if( sd->status.storage.items[n].nameid == 0 || sd->status.storage.items[n].amount < amount )
		return 1;

	sd->status.storage.items[n].amount -= amount;

	if(log_config.enable_logs&0x800)
		log_pick_pc(sd, "R", sd->status.storage.items[n].nameid, amount, &sd->status.storage.items[n], sd->status.storage.items[n].serial);

	if( sd->status.storage.items[n].amount == 0 )
	{
		memset(&sd->status.storage.items[n],0,sizeof(sd->status.storage.items[0]));
		sd->status.storage.storage_amount--;
		if( sd->state.storage_flag == 1 ) clif_updatestorageamount(sd,sd->status.storage.storage_amount);
	}
	if( sd->state.storage_flag == 1 ) clif_storageitemremoved(sd,n,amount);
	return 0;
}
コード例 #2
0
ファイル: storage.c プロジェクト: milky-milk/ro-server-repos
/*==========================================
 * Internal del-item function
 *------------------------------------------*/
static int storage_delitem(struct map_session_data *sd,struct storage *stor,int n,int amount)
{

	if(stor->storage_[n].nameid==0 || stor->storage_[n].amount<amount)
		return 1;

	stor->storage_[n].amount-=amount;
	if(log_config.enable_logs&0x800)
		log_pick_pc(sd, "R", stor->storage_[n].nameid, amount, &stor->storage_[n]);
	if(stor->storage_[n].amount==0){
		memset(&stor->storage_[n],0,sizeof(stor->storage_[0]));
		stor->storage_amount--;
		clif_updatestorageamount(sd,stor);
	}
	clif_storageitemremoved(sd,n,amount);

	stor->dirty = 1;
	return 0;
}
コード例 #3
0
ファイル: storage.c プロジェクト: Escada28/rathena
/**
 * Retrieve an item from the storage into inventory
 * @param sd : player
 * @param index : storage index to take the item from
 * @param amount : number of item to take
 * @return 0:fail, 1:success
 */
void storage_storageget(struct map_session_data* sd, int index, int amount)
{
	unsigned char flag = 0;

	if( index < 0 || index >= sd->storage_size )
		return;

	if( sd->status.storage.items[index].nameid <= 0 )
		return; //Nothing there

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

	if( (flag = pc_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
		storage_delitem(sd,index,amount);
	else {
		clif_storageitemremoved(sd,index,0);
		clif_additem(sd,0,0,flag);
	}
}
コード例 #4
0
ファイル: storage.c プロジェクト: Lilystar/Auriga
/*==========================================
 * ギルド倉庫からアイテムを減らす
 *------------------------------------------
 */
static void storage_guild_delitem(struct map_session_data *sd,struct guild_storage *stor,int n,int amount)
{
	nullpo_retv(sd);
	nullpo_retv(stor);

	if(stor->store_item[n].nameid == 0 || stor->store_item[n].amount < amount)
		return;

	stor->store_item[n].amount -= amount;
	if(stor->store_item[n].amount == 0) {
		memset(&stor->store_item[n],0,sizeof(stor->store_item[0]));
		stor->store_item[n].id = 0;
		stor->storage_amount--;
		clif_updateguildstorageamount(sd,stor);
	}
	stor->dirty = 1;
	clif_storageitemremoved(sd,n,amount);

	return;
}
コード例 #5
0
int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* stor, int n, int amount)
{
	nullpo_retr(1, sd);
	nullpo_retr(1, stor);

	if(stor->items[n].nameid==0 || stor->items[n].amount<amount)
		return 1;

	stor->items[n].amount-=amount;
	if(log_config.enable_logs&0x1000)
		log_pick_pc(sd, "G", stor->items[n].nameid, amount, &stor->items[n], stor->items[n].serial);
	if(stor->items[n].amount==0){
		memset(&stor->items[n],0,sizeof(stor->items[0]));
		stor->storage_amount--;
		clif_updateguildstorageamount(sd,stor->storage_amount);
	}
	clif_storageitemremoved(sd,n,amount);
	stor->dirty = 1;
	return 0;
}
コード例 #6
0
ファイル: storage.c プロジェクト: newmessage/rathena
/**
 * Attempt to delete an item in guild storage, then refresh it
 * @param sd : player
 * @param stor : guild_storage
 * @param n : index of item in guild storage
 * @param amount : number of item to delete
 * @return True : success, False : fail
 */
bool gstorage_delitem(struct map_session_data* sd, struct guild_storage* stor, int n, int amount)
{
	nullpo_retr(1, sd);
	nullpo_retr(1, stor);

	if(stor->items[n].nameid == 0 || stor->items[n].amount < amount)
		return false;

	stor->items[n].amount -= amount;

	if(stor->items[n].amount == 0) {
		memset(&stor->items[n],0,sizeof(stor->items[0]));
		stor->storage_amount--;
		clif_updatestorageamount(sd, stor->storage_amount, MAX_GUILD_STORAGE);
	}

	clif_storageitemremoved(sd,n,amount);
	stor->dirty = true;
	return true;
}
コード例 #7
0
ファイル: storage.c プロジェクト: newmessage/rathena
/**
 * Make a player delete an item from his storage
 * @param sd : player
 * @param n : idx on storage to remove the item from
 * @param amount :number of item to remove
 * @return 0:sucess, 1:fail
 */
int storage_delitem(struct map_session_data* sd, int n, int amount)
{
	if( sd->status.storage.items[n].nameid == 0 || sd->status.storage.items[n].amount < amount )
		return 1;

	sd->status.storage.items[n].amount -= amount;

	if( sd->status.storage.items[n].amount == 0 ) {
		memset(&sd->status.storage.items[n],0,sizeof(sd->status.storage.items[0]));
		sd->status.storage.storage_amount--;

		if( sd->state.storage_flag == 1 )
			clif_updatestorageamount(sd, sd->status.storage.storage_amount, sd->storage_size);
	}

	if( sd->state.storage_flag == 1 )
		clif_storageitemremoved(sd,n,amount);

	return 0;
}
コード例 #8
0
ファイル: storage.c プロジェクト: AtlantisRO/rathena
/**
 * Make a player delete an item from his storage
 * @param sd : player
 * @param n : idx on storage to remove the item from
 * @param amount :number of item to remove
 * @return 0:sucess, 1:fail
 */
int storage_delitem(struct map_session_data* sd, struct s_storage *stor, int index, int amount)
{
	if( stor->u.items_storage[index].nameid == 0 || stor->u.items_storage[index].amount < amount )
		return 1;

	stor->u.items_storage[index].amount -= amount;
	stor->dirty = true;

	if( stor->u.items_storage[index].amount == 0 ) {
		memset(&stor->u.items_storage[index],0,sizeof(stor->u.items_storage[0]));
		stor->amount--;
		if( sd->state.storage_flag == 1 || sd->state.storage_flag == 3 )
			clif_updatestorageamount(sd, stor->amount, sd->storage.max_amount);
	}

	if( sd->state.storage_flag == 1 || sd->state.storage_flag == 3 )
		clif_storageitemremoved(sd,index,amount);

	return 0;
}
コード例 #9
0
ファイル: storage.c プロジェクト: Escada28/rathena
/**
 * Get from Storage to the Cart inventory
 * @param sd : player
 * @param index : storage index to take the item from
 * @param amount : number of item to take
 * @return 0:fail, 1:success
 */
void storage_storagegettocart(struct map_session_data* sd, int index, int amount)
{
	unsigned char flag;
	nullpo_retv(sd);

	if( index < 0 || index >= sd->storage_size )
		return;

	if( sd->status.storage.items[index].nameid <= 0 )
		return; //Nothing there.

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

	if( (flag = pc_cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
		storage_delitem(sd,index,amount);
	else {
		clif_storageitemremoved(sd,index,0);
		clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
	}
}
コード例 #10
0
ファイル: storage.c プロジェクト: Escada28/rathena
/**
 * 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);
	}
}
コード例 #11
0
ファイル: storage.c プロジェクト: Escada28/rathena
/**
 * 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
 */
void storage_storageadd(struct map_session_data* sd, int index, int amount)
{
	nullpo_retv(sd);

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

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

	if( sd->status.inventory[index].nameid <= 0 )
		return; // No item on that spot

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

	if( storage_additem(sd,&sd->status.inventory[index],amount) == 0 )
		pc_delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
	else {
		clif_storageitemremoved(sd,index,0);
		clif_dropitem(sd,index,0);
	}
}
コード例 #12
0
ファイル: storage.c プロジェクト: DingWeizhe/rathena
/**
 * 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_CART);
	if (result == STORAGE_ADD_INVALID)
		return;
	else if (result == STORAGE_ADD_OK) {
		switch( storage_additem(sd, stor, &sd->cart.u.items_cart[index], amount) ){
			case 0:
				pc_cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);
				return;
			case 1:
				break;
			case 2:
				result = STORAGE_ADD_NOROOM;
				break;
		}
	}

	clif_storageitemremoved(sd,index,0);
	clif_dropitem(sd,index,0);
}