MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / addToBags

Method addToBags

source/game/StarPlayerInventory.cpp:231–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231ItemPtr PlayerInventory::addToBags(ItemPtr items) {
232 if (!items || items->empty())
233 return {};
234
235 for (auto pair : m_bags) {
236 if (!itemAllowedInBag(items, pair.first))
237 continue;
238
239 items = pair.second->stackItems(items);
240 if (!items)
241 break;
242
243 for (unsigned i = 0; i < pair.second->size(); ++i) {
244 if (!pair.second->at(i)) {
245 pair.second->setItem(i, take(items));
246 autoAddToCustomBar(BagSlot(pair.first, i));
247 break;
248 }
249 }
250 }
251
252 return items;
253}
254
255uint64_t PlayerInventory::itemsCanFit(ItemPtr const& items) const {
256 if (!items || items->empty())

Callers 1

nakedMethod · 0.80

Calls 6

takeFunction · 0.85
stackItemsMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
setItemMethod · 0.45

Tested by

no test coverage detected