86 {
87 if (!player)
88 {
90 }
91
92 if (!player)
93 {
96 return false;
97 }
98
99 Player* target = player->GetConnectedPlayer();
100 if (!target)
101 {
104 return false;
105 }
106
107 std::array<uint32, MAX_ITEM_SUBCLASS_CONTAINER> freeSlotsInBags = { };
108 uint32 freeSlotsForBags = 0;
109 bool haveFreeSlot = false;
110
111
113 {
115 {
116 haveFreeSlot = true;
118 }
119 }
120
121
123 {
125 {
126 if (
ItemTemplate const* bagTemplate = bag->GetTemplate())
127 {
129 {
130 haveFreeSlot = true;
131 freeSlotsInBags[bagTemplate->SubClass] += bag->GetFreeSlots();
132 }
133 }
134 }
135 else
136 {
137 ++freeSlotsForBags;
138 }
139 }
140
141 std::ostringstream str;
142
143 if (haveFreeSlot)
144 {
145 str <<
"Player " << target->
GetName() <<
" have ";
146 bool initialize = true;
147
149 {
150 if (
uint32 freeSlots = freeSlotsInBags[i])
151 {
153 if (!initialize)
154 {
155 str << ", ";
156 }
157
158 str << "|c";
160 str << freeSlots << " in " << bagSpecString << " bags|r";
161
162 initialize = false;
163 }
164 }
165 }
166 else
167 {
168 str <<
"Player " << target->
GetName() <<
" does not have free slots in their bags";
169 }
170
171 if (freeSlotsForBags)
172 {
173 str << " and also has " << freeSlotsForBags << " free slots for bags";
174 }
175
176 str << ".";
177
179
180 return true;
181 }
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
@ ITEM_SUBCLASS_CONTAINER
Definition: ItemTemplate.h:338
#define MAX_ITEM_SUBCLASS_CONTAINER
Definition: ItemTemplate.h:349
@ ITEM_CLASS_QUIVER
Definition: ItemTemplate.h:311
@ ITEM_CLASS_CONTAINER
Definition: ItemTemplate.h:301
@ INVENTORY_SLOT_ITEM_START
Definition: Player.h:706
@ INVENTORY_SLOT_ITEM_END
Definition: Player.h:707
@ INVENTORY_SLOT_BAG_START
Definition: Player.h:700
@ INVENTORY_SLOT_BAG_END
Definition: Player.h:701
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:671
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
constexpr std::array< uint32, MAX_ITEM_SUBCLASS_CONTAINER > bagSpecsColors
Definition: cs_inventory.cpp:37
constexpr std::array< const char *, MAX_ITEM_SUBCLASS_CONTAINER > bagSpecsToString
Definition: cs_inventory.cpp:24
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:189
Definition: ItemTemplate.h:628
std::string const & GetName() const
Definition: Object.h:446
Definition: Player.h:1046
Bag * GetBagByPos(uint8 slot) const
Definition: PlayerStorage.cpp:488
Item * GetItemByPos(uint16 pos) const
Definition: PlayerStorage.cpp:472