From 6f7e571c081704ce75f26fad03044c5907facf72 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 20 Sep 2022 18:43:45 +0100 Subject: [PATCH] Fix crash when assetpack does not exist --- src/openrct2/AssetPackManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openrct2/AssetPackManager.cpp b/src/openrct2/AssetPackManager.cpp index afffc7f5e3..a291d42572 100644 --- a/src/openrct2/AssetPackManager.cpp +++ b/src/openrct2/AssetPackManager.cpp @@ -17,6 +17,7 @@ #include "core/FileSystem.hpp" #include "core/String.hpp" #include "object/AudioSampleTable.h" +#include "platform/Platform.h" #include @@ -67,7 +68,11 @@ void AssetPackManager::Scan() auto context = GetContext(); auto env = context->GetPlatformEnvironment(); auto assetPackDirectory = fs::u8path(env->GetDirectoryPath(DIRBASE::USER, DIRID::ASSET_PACK)); - for (const fs::directory_entry& entry : fs::recursive_directory_iterator(assetPackDirectory)) + Platform::EnsureDirectoryExists(assetPackDirectory.u8string()); + + // Recursively scan for .parkap files + std::error_code ec; + for (const fs::directory_entry& entry : fs::recursive_directory_iterator(assetPackDirectory, ec)) { if (!entry.is_directory()) {