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

Method netElementsNeedLoad

source/game/StarPlayerInventory.cpp:1077–1115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1075}
1076
1077void PlayerInventory::netElementsNeedLoad(bool) {
1078 auto itemDatabase = Root::singleton().itemDatabase();
1079
1080 auto deserializeItem = [&itemDatabase](NetElementData<ItemDescriptor>& netState, ItemPtr& item) {
1081 if (netState.pullUpdated())
1082 itemDatabase->loadItem(netState.get(), item);
1083 };
1084
1085 auto deserializeItemList = [&](List<NetElementData<ItemDescriptor>>& netStatesList, List<ItemPtr>& itemList) {
1086 for (size_t i = 0; i < netStatesList.size(); ++i)
1087 deserializeItem(netStatesList[i], itemList[i]);
1088 };
1089
1090 auto deserializeItemMap = [&](auto& netStatesMap, auto& itemMap) {
1091 for (auto k : netStatesMap.keys())
1092 deserializeItem(netStatesMap[k], itemMap[k]);
1093 };
1094
1095 deserializeItemMap(m_equipmentNetState, m_equipment);
1096
1097 for (auto bagType : m_bagsNetState.keys())
1098 deserializeItemList(m_bagsNetState[bagType], m_bags[bagType]->items());
1099
1100 deserializeItem(m_swapSlotNetState, m_swapSlot);
1101 deserializeItem(m_trashSlotNetState, m_trashSlot);
1102
1103 m_currencies = m_currenciesNetState.get();
1104
1105 m_customBarGroup = m_customBarGroupNetState.get();
1106 m_customBarNetState.forEach([&](auto const& index, auto& ns) {
1107 m_customBar.at(index) = ns.get();
1108 });
1109
1110 m_selectedActionBar = m_selectedActionBarNetState.get();
1111
1112 deserializeItemMap(m_essentialNetState, m_essential);
1113
1114 cleanup();
1115}
1116
1117void PlayerInventory::netElementsNeedStore() {
1118 cleanup();

Callers

nothing calls this directly

Calls 10

singletonClass · 0.85
itemDatabaseMethod · 0.80
loadItemMethod · 0.80
itemsMethod · 0.80
pullUpdatedMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
keysMethod · 0.45
forEachMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected