Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CHARACTER::StackItem(LPITEM item)
- {
- if (!item)
- return true;
- if (!item->IsStackable() || IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- return false;
- for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
- {
- LPITEM item2 = GetInventoryItem(i);
- if (!item2)
- continue;
- if (item2->IsExchanging() || item2->isLocked())
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- int j;
- for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
- if (item2->GetSocket(j) != item->GetSocket(j))
- break;
- if (j != ITEM_SOCKET_MAX_NUM)
- continue;
- WORD wStackCount = MIN(ITEM_MAX_COUNT - item2->GetCount(), item->GetCount());
- item->SetCount(item->GetCount() - wStackCount);
- item2->SetCount(item2->GetCount() + wStackCount);
- if (item->GetCount() == 0)
- {
- return true;
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement