long adenaDeposit = 0;
slotsleft = Config.FREIGHT_SLOTS - freight.getSize();
int items = 0;
for (int i = 0; i < _count; i++)
{
ItemInstance item = inventory.getItemByObjectId(_items[i]);
if ((item == null) || (item.getCount() < _itemQ[i]) || !item.getTemplate().isFreightable())
{
_items[i] = 0;
_itemQ[i] = 0L;
continue;
}
if (!item.isStackable() || (freight.getItemByItemId(item.getItemId()) == null))
{
if (slotsleft <= 0)
{
_items[i] = 0;
_itemQ[i] = 0L;
continue;
}
slotsleft--;
}
if (item.getItemId() == ItemTemplate.ITEM_ID_ADENA)
{
adenaDeposit = _itemQ[i];
}
items++;
}
if (slotsleft <= 0)
{
player.sendPacket(SystemMsg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
}
if (items == 0)
{
player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
return;
}
long fee = SafeMath.mulAndCheck(items, _FREIGHT_FEE);
if ((fee + adenaDeposit) > player.getAdena())
{
player.sendPacket(SystemMsg.YOU_LACK_THE_FUNDS_NEEDED_TO_PAY_FOR_THIS_TRANSACTION);
return;
}
if (!player.reduceAdena(fee, true))
{
player.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
for (int i = 0; i < _count; i++)
{
if (_items[i] == 0)
{
continue;
}
ItemInstance item = inventory.removeItemByObjectId(_items[i], _itemQ[i]);
Log.LogItem(player, Log.FreightDeposit, item);
freight.addItem(item);
}
}
catch (ArithmeticException ae)