MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Load

Method Load

src/saveload/cheat_sl.cpp:52–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 }
51
52 void Load() const override
53 {
54 std::vector<SaveLoad> slt = SlCompatTableHeader(_cheats_desc, _cheats_sl_compat);
55
56 if (IsSavegameVersionBefore(SLV_TABLE_CHUNKS)) {
57 size_t count = SlGetFieldLength();
58 std::vector<SaveLoad> oslt;
59
60 /* Cheats were added over the years without a savegame bump. They are
61 * stored as 2 SLE_BOOLs per entry. "count" indicates how many SLE_BOOLs
62 * are stored for this savegame. So read only "count" SLE_BOOLs (and in
63 * result "count / 2" cheats). */
64 for (auto &sld : slt) {
65 count--;
66 oslt.push_back(sld);
67
68 if (count == 0) break;
69 }
70 slt = std::move(oslt);
71 }
72
73 if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
74 SlObject(&_cheats, slt);
75 if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many CHTS entries");
76 }
77};
78
79static const CHTSChunkHandler CHTS;

Callers

nothing calls this directly

Calls 7

SlCompatTableHeaderFunction · 0.85
IsSavegameVersionBeforeFunction · 0.85
SlGetFieldLengthFunction · 0.85
SlIterateArrayFunction · 0.85
SlObjectFunction · 0.85
SlErrorCorruptFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected