86 {
87 if (!player)
88 {
90 }
91
92 if (!player)
93 {
95 return false;
96 }
97
98 Player* target = player->GetConnectedPlayer();
99 if (!target)
100 {
102 return false;
103 }
104
105 std::array<uint32, MAX_ITEM_SUBCLASS_CONTAINER> freeSlotsInBags = { };
106 uint32 freeSlotsForBags = 0;
107 bool haveFreeSlot = false;
108
109
111 {
113 {
114 haveFreeSlot = true;
116 }
117 }
118
119
121 {
123 {
124 if (
ItemTemplate const* bagTemplate = bag->GetTemplate())
125 {
127 {
128 haveFreeSlot = true;
129 freeSlotsInBags[bagTemplate->SubClass] += bag->GetFreeSlots();
130 }
131 }
132 }
133 else
134 {
135 ++freeSlotsForBags;
136 }
137 }
138
139 std::ostringstream str;
140
141 if (haveFreeSlot)
142 {
143 str <<
"Player " << target->
GetName() <<
" have ";
144 bool initialize = true;
145
147 {
148 if (
uint32 freeSlots = freeSlotsInBags[i])
149 {
151 if (!initialize)
152 {
153 str << ", ";
154 }
155
156 str << "|c";
158 str << freeSlots << " in " << bagSpecString << " bags|r";
159
160 initialize = false;
161 }
162 }
163 }
164 else
165 {
166 str <<
"Player " << target->
GetName() <<
" does not have free slots in their bags";
167 }
168
169 if (freeSlotsForBags)
170 {
171 str << " and also has " << freeSlotsForBags << " free slots for bags";
172 }
173
174 str << ".";
175
177
178 return true;
179 }
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
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
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
@ INVENTORY_SLOT_ITEM_START
Definition: Player.h:705
@ INVENTORY_SLOT_ITEM_END
Definition: Player.h:706
@ INVENTORY_SLOT_BAG_START
Definition: Player.h:699
@ INVENTORY_SLOT_BAG_END
Definition: Player.h:700
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:670
@ ITEM_SUBCLASS_CONTAINER
Definition: ItemTemplate.h:329
#define MAX_ITEM_SUBCLASS_CONTAINER
Definition: ItemTemplate.h:340
@ ITEM_CLASS_QUIVER
Definition: ItemTemplate.h:302
@ ITEM_CLASS_CONTAINER
Definition: ItemTemplate.h:292
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184
Definition: ItemTemplate.h:619
std::string const & GetName() const
Definition: Object.h:458
Definition: Player.h:1064
Bag * GetBagByPos(uint8 slot) const
Definition: PlayerStorage.cpp:457
Item * GetItemByPos(uint16 pos) const
Definition: PlayerStorage.cpp:441