From e996c83b70a58164750d3493e4d85cfc67a99d3e Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 10 Feb 2018 21:37:06 +0000 Subject: [PATCH 1/3] Create config directory if it doesn't exist --- src/openrct2/config/Config.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 77d54e3732..f6105db2ec 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -572,6 +572,9 @@ namespace Config { try { + auto directory = Path::GetDirectory(path); + Path::CreateDirectory(directory); + auto fs = FileStream(path, FILE_MODE_WRITE); auto writer = std::unique_ptr(CreateIniWriter(&fs)); WriteGeneral(writer.get()); From 3c29b15de98b5cf81cea8f2084cfda57ddc719b6 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 10 Feb 2018 21:37:25 +0000 Subject: [PATCH 2/3] Fix segfault if no RCT2 install path --- src/openrct2/interface/Window.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 09a4b14764..9fc4822ed2 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -818,6 +818,11 @@ void window_close_top() */ void window_close_all() { + if (gWindowNextSlot == nullptr) + { + return; + } + window_close_by_class(WC_DROPDOWN); for (rct_window * w = RCT2_LAST_WINDOW; w >= g_window_list; w--) @@ -2667,11 +2672,7 @@ void window_reset_visibilities() void window_init_all() { - if (gWindowNextSlot != nullptr) - { - window_close_all(); - } - + window_close_all(); gWindowNextSlot = g_window_list; } From 0f00659c8ec33e878e16be1cd3e9bba90eba23d9 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 10 Feb 2018 21:43:14 +0000 Subject: [PATCH 3/3] Do not show file index error if it doesn't exist --- src/openrct2/core/FileIndex.hpp | 58 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/openrct2/core/FileIndex.hpp b/src/openrct2/core/FileIndex.hpp index 91ad4b0638..ba5682cb9a 100644 --- a/src/openrct2/core/FileIndex.hpp +++ b/src/openrct2/core/FileIndex.hpp @@ -196,7 +196,6 @@ private: items.push_back(std::get<1>(item)); } } - Console::WriteLine(); WriteIndexFile(scanResult.Stats, items); @@ -210,41 +209,44 @@ private: { bool loadedItems = false; std::vector items; - try + if (File::Exists(_indexPath)) { - log_verbose("FileIndex:Loading index: '%s'", _indexPath.c_str()); - auto fs = FileStream(_indexPath, FILE_MODE_OPEN); + try + { + log_verbose("FileIndex:Loading index: '%s'", _indexPath.c_str()); + auto fs = FileStream(_indexPath, FILE_MODE_OPEN); - // Read header, check if we need to re-scan - auto header = fs.ReadValue(); - if (header.HeaderSize == sizeof(FileIndexHeader) && - header.MagicNumber == _magicNumber && - header.VersionA == FILE_INDEX_VERSION && - header.VersionB == _version && - header.LanguageId == gCurrentLanguage && - header.Stats.TotalFiles == stats.TotalFiles && - header.Stats.TotalFileSize == stats.TotalFileSize && - header.Stats.FileDateModifiedChecksum == stats.FileDateModifiedChecksum && - header.Stats.PathChecksum == stats.PathChecksum) - { - // Directory is the same, just read the saved items - for (uint32 i = 0; i < header.NumItems; i++) + // Read header, check if we need to re-scan + auto header = fs.ReadValue(); + if (header.HeaderSize == sizeof(FileIndexHeader) && + header.MagicNumber == _magicNumber && + header.VersionA == FILE_INDEX_VERSION && + header.VersionB == _version && + header.LanguageId == gCurrentLanguage && + header.Stats.TotalFiles == stats.TotalFiles && + header.Stats.TotalFileSize == stats.TotalFileSize && + header.Stats.FileDateModifiedChecksum == stats.FileDateModifiedChecksum && + header.Stats.PathChecksum == stats.PathChecksum) { - auto item = Deserialise(&fs); - items.push_back(item); + // Directory is the same, just read the saved items + for (uint32 i = 0; i < header.NumItems; i++) + { + auto item = Deserialise(&fs); + items.push_back(item); + } + loadedItems = true; + } + else + { + Console::WriteLine("%s out of date", _name.c_str()); } - loadedItems = true; } - else + catch (const std::exception &e) { - Console::WriteLine("%s out of date", _name.c_str()); + Console::Error::WriteLine("Unable to load index: '%s'.", _indexPath.c_str()); + Console::Error::WriteLine("%s", e.what()); } } - catch (const std::exception &e) - { - Console::Error::WriteLine("Unable to load index: '%s'.", _indexPath.c_str()); - Console::Error::WriteLine("%s", e.what()); - } return std::make_tuple(loadedItems, items); }