int enchantLevel = 0;
InventoryUpdate buyerupdate = new InventoryUpdate();
InventoryUpdate sellerupdate = new InventoryUpdate();
ItemTable itemTable = ItemTable.getInstance();
int amount = 0;
int x = 0;
int y = 0;
List<SystemMessage> sysmsgs = new FastList<SystemMessage>();
SystemMessage msg = null;
for(TradeItem buyerItem : buyerslist)
{
for(x=0 ; x < sellerslist.size(); x++)//find in sellerslist
{
temp2 = sellerslist.get(x);
if (temp2.getItemId() == buyerItem.getItemId())
{
sellerItem = sellerInv.getItemByItemId(buyerItem.getItemId());
break;
}
}
if (sellerItem !=null)
{
if (buyerItem.getCount()> temp2.getCount())
{
amount = temp2.getCount();
}
if (buyerItem.getCount()> sellerItem.getCount())
{
amount = sellerItem.getCount();
}
else
{
amount = buyerItem.getCount();
}
if (buyerItem.getCount() > Integer.MAX_VALUE / buyerItem.getOwnersPrice())
{
_log.warning("Integer Overflow on Cost. Possible Exploit attempt between "+buyer.getName()+" and "+seller.getName()+".");
return;
}
//int cost = amount * buyerItem.getOwnersPrice();
enchantLevel = sellerItem.getEnchantLevel();
sellerItem = sellerInv.destroyItem("", sellerItem.getObjectId(),amount, null, null);
// buyer.reduceAdena(cost);
// seller.addAdena(cost);
newitem = itemTable.createItem("L2TradeList", sellerItem.getItemId(), amount, buyer, seller);
newitem.setEnchantLevel(enchantLevel);
temp = buyerInv.addItem("", newitem, null, null);
if (amount == 1)//system msg stuff
{
msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S2);