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

Method store

source/game/StarPlayerInventory.cpp:856–895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854}
855
856Json PlayerInventory::store() const {
857 auto itemDatabase = Root::singleton().itemDatabase();
858
859 JsonArray customBar;
860 for (size_t i = 0; i < m_customBar.size(0); ++i) {
861 JsonArray customBarGroup;
862 for (size_t j = 0; j < m_customBar.size(1); ++j) {
863 auto const& cbl = m_customBar.at(i, j);
864 customBarGroup.append(JsonArray{jsonFromMaybe(cbl.first, jsonFromInventorySlot), jsonFromMaybe(cbl.second, jsonFromInventorySlot)});
865 }
866 customBar.append(take(customBarGroup));
867 }
868
869 JsonObject itemBags;
870 for (auto& bag : m_bags)
871 itemBags.add(bag.first, bag.second->diskStore());
872
873 auto data = JsonObject{
874 {"itemBags", itemBags},
875 {"swapSlot", itemDatabase->diskStore(m_swapSlot)},
876 {"trashSlot", itemDatabase->diskStore(m_trashSlot)},
877 {"currencies", jsonFromMap(m_currencies)},
878 {"customBarGroup", m_customBarGroup},
879 {"customBar", std::move(customBar)},
880 {"selectedActionBar", jsonFromSelectedActionBarLocation(m_selectedActionBar)},
881 {"beamAxe", itemDatabase->diskStore(m_essential.value(EssentialItem::BeamAxe))},
882 {"wireTool", itemDatabase->diskStore(m_essential.value(EssentialItem::WireTool))},
883 {"paintTool", itemDatabase->diskStore(m_essential.value(EssentialItem::PaintTool))},
884 {"inspectionTool", itemDatabase->diskStore(m_essential.value(EssentialItem::InspectionTool))}
885 };
886
887 for (auto& equipment : m_equipment) {
888 if (equipment.first <= EquipmentSlot::BackCosmetic || equipment.second)
889 data.set(strf("{}Slot", EquipmentSlotNames.getRight(equipment.first)), itemDatabase->diskStore(equipment.second));
890 }
891
892 data.set("equipmentVisibilityMask", m_equipmentVisibilityMask);
893
894 return data;
895}
896
897void PlayerInventory::forEveryItem(function<void(InventorySlot const&, ItemPtr&)> function) {
898 auto checkedFunction = [function = std::move(function)](InventorySlot const& slot, ItemPtr& item) {

Callers

nothing calls this directly

Calls 14

singletonClass · 0.85
jsonFromMaybeFunction · 0.85
takeFunction · 0.85
jsonFromMapFunction · 0.85
strfFunction · 0.85
itemDatabaseMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
appendMethod · 0.45
addMethod · 0.45
diskStoreMethod · 0.45

Tested by

no test coverage detected