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

Method stackTransfer

source/game/StarItemBag.cpp:347–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347uint64_t ItemBag::stackTransfer(ItemConstPtr const& to, ItemConstPtr const& from) {
348 if (!from)
349 return 0;
350 else if (!to)
351 return from->count();
352 else if (!to->stackableWith(from))
353 return 0;
354 else
355 return std::min(to->maxStack() - to->count(), from->count());
356}
357
358size_t ItemBag::bestSlotAvailable(ItemConstPtr const& item, bool stacksOnly, std::function<bool(size_t)> test) const {
359 // First look for any slots that can stack, before empty slots.

Callers

nothing calls this directly

Calls 3

stackableWithMethod · 0.80
countMethod · 0.45
maxStackMethod · 0.45

Tested by

no test coverage detected