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()); 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); } 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; }