53 {
54 if (args.empty())
55 {
56 return false;
57 }
58
60 if (!player)
61 {
62 return false;
63 }
64
67 {
69 {
70 itemQuality = i;
71 break;
72 }
73 }
74
76 {
77 return false;
78 }
79
80 std::array<uint32, MAX_ITEM_QUALITY> removedItems = { };
81
82
84 {
86 {
87 if (
ItemTemplate const* itemTemplate = item->GetTemplate())
88 {
89 if (itemTemplate->Quality <= itemQuality)
90 {
92 ++removedItems[itemTemplate->Quality];
93 }
94 }
95 }
96 }
97
98
100 {
102 {
103 for (
uint32 j = 0; j < bag->GetBagSize(); j++)
104 {
105 if (
Item* item = bag->GetItemByPos(j))
106 {
107 if (
ItemTemplate const* itemTemplate = item->GetTemplate())
108 {
109 if (itemTemplate->Quality <= itemQuality)
110 {
112 ++removedItems[itemTemplate->Quality];
113 }
114 }
115 }
116 }
117 }
118 }
119
120 std::ostringstream str;
121 str << "Removed ";
123 {
124 str << "all";
125 }
126 else
127 {
128 bool initialize = true;
130 {
131 if (
uint32 itemCount = removedItems[i])
132 {
134
135 if (!initialize)
136 {
137 str << ", ";
138 }
139
140 str << "|c";
142 str << itemCount << " " << itemQualityString << "|r";
143
144 initialize = false;
145 }
146 }
147 }
148
149 str << " items from your bags.";
150
152
153 return true;
154 };
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
constexpr std::array< std::string_view, MAX_ITEM_QUALITY > itemQualityToString
Definition: cs_bag.cpp:23
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition: SharedDefines.h:353
@ ITEM_QUALITY_HEIRLOOM
Definition: SharedDefines.h:336
@ ITEM_QUALITY_POOR
Definition: SharedDefines.h:329
#define MAX_ITEM_QUALITY
Definition: SharedDefines.h:339
@ INVENTORY_SLOT_ITEM_START
Definition: Player.h:710
@ INVENTORY_SLOT_ITEM_END
Definition: Player.h:711
@ INVENTORY_SLOT_BAG_START
Definition: Player.h:704
@ INVENTORY_SLOT_BAG_END
Definition: Player.h:705
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:675
WorldSession * GetSession()
Definition: Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
Definition: ItemTemplate.h:619
Definition: Player.h:1081
Bag * GetBagByPos(uint8 slot) const
Definition: PlayerStorage.cpp:457
Item * GetItemByPos(uint16 pos) const
Definition: PlayerStorage.cpp:441
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition: PlayerStorage.cpp:3023
Player * GetPlayer() const
Definition: WorldSession.h:362