Example #1
0
/**
 * Attempt to add an item in guild storage from cart, then refresh it
 * @param sd : player
 * @param index : index of item in cart
 * @param amount : number of item to transfer
 */
void gstorage_storageaddfromcart(struct map_session_data *sd, int index, int amount)
{
	struct guild_storage *stor;

	nullpo_retv(sd);
	nullpo_retv(stor = gstorage_get_storage(sd->status.guild_id));

	if (!stor->opened || stor->opened != sd->status.char_id || stor->storage_amount > MAX_GUILD_STORAGE)
		return;

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

	if (!(sd->status.cart[index].nameid))
		return;

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

	if (gstorage_additem(sd, stor, &sd->status.cart[index], amount))
		pc_cart_delitem(sd, index, amount, 0, LOG_TYPE_GSTORAGE);
	else {
		clif_storageitemremoved(sd, index, 0);
		clif_dropitem(sd, index, 0);
	}
}
Example #2
0
/**
 * Attempt to add an item in guild storage from inventory, then refresh it
 * @param sd : player
 * @param amount : number of item to delete
 */
void gstorage_storageadd(struct map_session_data* sd, int index, int amount)
{
	struct guild_storage *stor;

	nullpo_retv(sd);
	nullpo_retv(stor = gstorage_get_storage(sd->status.guild_id));

	if( !stor->opened || stor->opened != sd->status.char_id || stor->storage_amount > MAX_GUILD_STORAGE )
		return;

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

	if( sd->status.inventory[index].nameid == 0 )
		return;

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

	if( stor->locked ) {
		gstorage_storageclose(sd);
		return;
	}

	if(gstorage_additem(sd,stor,&sd->status.inventory[index],amount))
		pc_delitem(sd,index,amount,0,4,LOG_TYPE_GSTORAGE);
	else {
		clif_storageitemremoved(sd,index,0);
		clif_dropitem(sd,index,0);
	}
}