Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. bool CHARACTER::StackItem(LPITEM item)
  2. {
  3. if (!item)
  4. return true;
  5.  
  6. if (!item->IsStackable() || IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7. return false;
  8.  
  9. for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
  10. {
  11. LPITEM item2 = GetInventoryItem(i);
  12.  
  13. if (!item2)
  14. continue;
  15.  
  16. if (item2->IsExchanging() || item2->isLocked())
  17. continue;
  18.  
  19. if (item2->GetVnum() == item->GetVnum())
  20. {
  21. int j;
  22.  
  23. for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
  24. if (item2->GetSocket(j) != item->GetSocket(j))
  25. break;
  26.  
  27. if (j != ITEM_SOCKET_MAX_NUM)
  28. continue;
  29.  
  30. WORD wStackCount = MIN(ITEM_MAX_COUNT - item2->GetCount(), item->GetCount());
  31.  
  32. item->SetCount(item->GetCount() - wStackCount);
  33. item2->SetCount(item2->GetCount() + wStackCount);
  34.  
  35. if (item->GetCount() == 0)
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41.  
  42. return false;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement