Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ACMD (do_sort_special_storage)
- {
- char arg1[256];
- one_argument(argument, arg1, sizeof(arg1));
- BYTE inventoryNumber = 0;
- str_to_number(inventoryNumber, arg1);
- if(inventoryNumber < 0 || inventoryNumber > 3)
- return;
- if (ch->IsDead() || ch->GetExchange() || ch->GetViewingShopOwner() || ch->IsShop() || ch->IsOpenSafebox() || ch->IsCubeOpen())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't sort your inventory with those windows open."));
- return;
- }
- int lastSortSpecialStoragePulse = ch->GetSortSpecialStoragePulse(inventoryNumber);
- int currentPulse = thecore_pulse();
- if (lastSortSpecialStoragePulse > currentPulse) {
- int deltaInSeconds = ((lastSortSpecialStoragePulse / PASSES_PER_SEC(1)) - (currentPulse / PASSES_PER_SEC(1)));
- int minutes = deltaInSeconds / 60;
- int seconds = (deltaInSeconds - (minutes * 60));
- if(minutes > 0)
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can sort your inventory again in %02d minutes and %02d seconds."), minutes, seconds);
- else
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can sort your inventory again in %02d seconds."), seconds);
- return;
- }
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item;
- switch(inventoryNumber)
- {
- case 0:
- item = ch->GetUpgradeInventoryItem(i);
- break;
- case 1:
- item = ch->GetBookInventoryItem(i);
- break;
- case 2:
- item = ch->GetStoneInventoryItem(i);
- break;
- case 3:
- item = ch->GetChestInventoryItem(i);
- break;
- default:
- item = ch->GetUpgradeInventoryItem(i);
- break;
- }
- if(!item)
- continue;
- if(item->isLocked())
- continue;
- if(item->GetCount() == g_bItemCountLimit)
- continue;
- if ((item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK)))
- {
- for (int j = i + 1; j < SPECIAL_INVENTORY_MAX_NUM; ++j)
- {
- LPITEM item2;
- switch(inventoryNumber)
- {
- case 0:
- item2 = ch->GetUpgradeInventoryItem(j);
- break;
- case 1:
- item2 = ch->GetBookInventoryItem(j);
- break;
- case 2:
- item2 = ch->GetStoneInventoryItem(j);
- break;
- case 3:
- item2 = ch->GetChestInventoryItem(j);
- break;
- default:
- item2 = ch->GetUpgradeInventoryItem(j);
- break;
- }
- if(!item2)
- continue;
- if(item2->isLocked())
- continue;
- if(item->GetID() == item2->GetID()) // sanity check
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- {
- bool bStopSockets = false;
- for (int k = 0; k < ITEM_SOCKET_MAX_NUM; ++k)
- {
- if (item2->GetSocket(k) != item->GetSocket(k))
- {
- bStopSockets = true;
- break;
- }
- }
- if(bStopSockets)
- continue;
- BYTE bAddCount = MIN(g_bItemCountLimit - item->GetCount(), item2->GetCount());
- item->SetCount(item->GetCount() + bAddCount);
- item2->SetCount(item2->GetCount() - bAddCount);
- }
- continue;
- }
- }
- }
- }
- ch->SetNextSortSpecialStoragePulse(inventoryNumber, thecore_pulse() + PASSES_PER_SEC(69));
- }
Advertisement
Add Comment
Please, Sign In to add comment