1. ACMD (do_sort_special_storage)
  2. {
  3. if (ch->IsDead() || ch->GetExchange() || ch->IsShop() || ch->IsOpenSafebox() || ch->IsCubeOpen())
  4. {
  5. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bu sekilde bu islemi yapamazsin."));
  6. return;
  7. }
  8. int lastSortSpecialStoragePulse = ch->GetSortSpecialStoragePulse();
  9. int currentPulse = thecore_pulse();
  10. if (lastSortSpecialStoragePulse > currentPulse) {
  11. int deltaInSeconds = ((lastSortSpecialStoragePulse / PASSES_PER_SEC(1)) - (currentPulse / PASSES_PER_SEC(1)));
  12. int minutes = deltaInSeconds / 60;
  13. int seconds = (deltaInSeconds - (minutes * 60));
  14. // ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can sort your inventory again in %02d seconds.", seconds));
  15. return;
  16. }
  17. for (int m = 0; m < 3; m++)
  18. {
  19. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  20. {
  21. LPITEM item;
  22. switch(m)
  23. {
  24. case 0:
  25. item = ch->GetUpgradeInventoryItem(i);
  26. break;
  27. case 1:
  28. item = ch->GetBookInventoryItem(i);
  29. break;
  30. case 2:
  31. item = ch->GetStoneInventoryItem(i);
  32. break;
  33. default:
  34. item = ch->GetUpgradeInventoryItem(i);
  35. break;
  36. }
  37. if(!item)
  38. continue;
  39. if(item->isLocked())
  40. continue;
  41. if(item->GetCount() == ITEM_MAX_COUNT)
  42. continue;
  43. if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  44. {
  45. for (int j = i; j < SPECIAL_INVENTORY_MAX_NUM; ++j)
  46. {
  47. LPITEM item2;
  48. switch(m)
  49. {
  50. case 0:
  51. item2 = ch->GetUpgradeInventoryItem(j);
  52. break;
  53. case 1:
  54. item2 = ch->GetBookInventoryItem(j);
  55. break;
  56. case 2:
  57. item2 = ch->GetStoneInventoryItem(j);
  58. break;
  59. default:
  60. item2 = ch->GetUpgradeInventoryItem(j);
  61. break;
  62. }
  63. if(!item2)
  64. continue;
  65. if(item2->isLocked())
  66. continue;
  67. if (item2->GetVnum() == item->GetVnum())
  68. {
  69. bool bStopSockets = false;
  70. for (int k = 0; k < ITEM_SOCKET_MAX_NUM; ++k)
  71. {
  72. if (item2->GetSocket(k) != item->GetSocket(k))
  73. {
  74. bStopSockets = true;
  75. break;
  76. }
  77. }
  78. if(bStopSockets)
  79. continue;
  80. BYTE bAddCount = MIN(ITEM_MAX_COUNT - item->GetCount(), item2->GetCount());
  81. item->SetCount(item->GetCount() + bAddCount);
  82. item2->SetCount(item2->GetCount() - bAddCount);
  83. continue;
  84. }
  85. }
  86. }
  87. }
  88. }
  89. ch->SetNextSortSpecialStoragePulse(thecore_pulse() + PASSES_PER_SEC(60));
  90. }