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

Method putItems

source/game/StarItemBag.cpp:114–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114ItemPtr ItemBag::putItems(size_t pos, ItemPtr items) {
115 if (!items || items->empty())
116 return {};
117
118 auto& storedItem = at(pos);
119
120 if (storedItem) {
121 // Try to stack with an item that is already there
122 storedItem->stackWith(items);
123 if (!items->empty())
124 return items;
125 else
126 return {};
127 } else {
128 // Otherwise just put the items there and return nothing.
129 storedItem = items;
130
131 return {};
132 }
133}
134
135ItemPtr ItemBag::takeItems(size_t pos, uint64_t count) {
136 if (auto& storedItem = at(pos)) {

Callers 1

updateMethod · 0.45

Calls 2

emptyMethod · 0.45
stackWithMethod · 0.45

Tested by

no test coverage detected