MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / LoadStash

Function LoadStash

Source/loadsave.cpp:2265–2309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2263constexpr uint8_t StashVersion = 0;
2264
2265void LoadStash()
2266{
2267 const char *filename;
2268 if (!gbIsMultiplayer)
2269 filename = "spstashitems";
2270 else
2271 filename = "mpstashitems";
2272
2273 Stash = {};
2274
2275 LoadHelper file(OpenStashArchive(), filename);
2276 if (!file.IsValid())
2277 return;
2278
2279 auto version = file.NextLE<uint8_t>();
2280 if (version > StashVersion) {
2281 EventPlrMsg(_("Stash version invalid. If you attempt to access your stash, data will be overwritten!!"), UiFlags::ColorRed);
2282 return;
2283 }
2284
2285 Stash.gold = file.NextLE<uint32_t>();
2286
2287 auto pages = file.NextLE<uint32_t>();
2288 for (unsigned i = 0; i < pages; i++) {
2289 auto page = file.NextLE<uint32_t>();
2290 for (auto &row : Stash.stashGrids[page]) {
2291 for (uint16_t &cell : row) {
2292 cell = file.NextLE<uint16_t>();
2293 }
2294 }
2295 }
2296
2297 auto itemCount = file.NextLE<uint32_t>();
2298 if (!IsStashSizeValid(file.Size(), pages, itemCount)) {
2299 Stash = {};
2300 EventPlrMsg(_("Stash size invalid. If you attempt to access your stash, data will be overwritten!!"), UiFlags::ColorRed);
2301 return;
2302 }
2303 Stash.stashList.resize(itemCount);
2304 for (unsigned i = 0; i < itemCount; i++) {
2305 LoadAndValidateItemData(file, Stash.stashList[i]);
2306 }
2307
2308 Stash.SetPage(file.NextLE<uint32_t>());
2309}
2310
2311void RemoveEmptyInventory(Player &player)
2312{

Callers 1

LoadGameLevelFunction · 0.85

Calls 7

OpenStashArchiveFunction · 0.85
EventPlrMsgFunction · 0.85
IsStashSizeValidFunction · 0.85
LoadAndValidateItemDataFunction · 0.85
SetPageMethod · 0.80
IsValidMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected