ACMD(do_split_items) //SPLIT ITEMS
{
if (!ch)
return;
const char *line;
char arg1[256], arg2[256], arg3[256];
line = two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
one_argument(line, arg3, sizeof(arg3));
if (!*arg1 || !*arg2 || !*arg3)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Wrong command use.");
return;
}
if (!ch->CanWarp())
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Close all windows and wait a few seconds, before using this."));
return;
}
WORD count = 0; //zamien se to na bajta jak nie masz zwiekszonych slotów.
WORD cell = 0;
WORD destCell = 0;
str_to_number(cell, arg1);
str_to_number(count, arg2);
str_to_number(destCell, arg3);
LPITEM item = ch->GetInventoryItem(cell);
if (item != NULL)
{
WORD itemCount = item->GetCount(); //to tez se kurwa zamien na byte'a jak nie masz slotów zwiekszonych.
while (itemCount > 0)
{
if (count > itemCount)
count = itemCount;
int iEmptyPosition;
if (destCell >= SPECIAL_INVENTORY_SKILLBOOK_START && destCell < SPECIAL_INVENTORY_SKILLBOOK_END)
{
iEmptyPosition = ch->GetEmptyBookInventoryFromIndex(destCell, item->GetSize());
}
else if (destCell >= SPECIAL_INVENTORY_MATERIAL_START && destCell < SPECIAL_INVENTORY_MATERIAL_END)
{
iEmptyPosition = ch->GetEmptyUpgradeInventoryFromIndex(destCell, item->GetSize());
}
else {
iEmptyPosition = ch->GetEmptyInventoryFromIndex(destCell, item->GetSize());
}
//int iEmptyPosition = ch->GetEmptyInventoryFromIndex(destCell, item->GetSize());
if (iEmptyPosition == -1)
break;
itemCount -= count;
ch->MoveItem(TItemPos(INVENTORY, cell), TItemPos(INVENTORY, iEmptyPosition), count);
}
}
}