MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / readScenarioOptions

Function readScenarioOptions

src/OpenLoco/src/S5/S5.cpp:815–844  ·  view source on GitHub ↗

0x00442AFC

Source from the content-addressed store, hash-verified

813
814 // 0x00442AFC
815 std::unique_ptr<Scenario::Options> readScenarioOptions(const fs::path& path)
816 {
817 FileStream stream(path, StreamMode::read);
818 SawyerStreamReader fs(stream);
819 if (!fs.validateChecksum())
820 {
821 return nullptr;
822 }
823
824 Header s5Header{};
825
826 // Read header
827 fs.readChunk(&s5Header, sizeof(s5Header));
828
829 if (s5Header.version != kCurrentVersion)
830 {
831 return nullptr;
832 }
833
834 if (s5Header.type == S5Type::scenario)
835 {
836 // 0x009DA285 = 1
837 // 0x009CCA54 _previewOptions
838
839 auto s5Options = std::make_unique<S5::Options>();
840 fs.readChunk(s5Options.get(), sizeof(S5::Options));
841 return std::make_unique<Scenario::Options>(importOptions(*s5Options));
842 }
843 return nullptr;
844 }
845}

Callers 2

loadFileDetailsFunction · 0.85
createIndexFunction · 0.85

Calls 4

importOptionsFunction · 0.85
validateChecksumMethod · 0.80
readChunkMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected