diff --git a/contributors.md b/contributors.md index 1345cc3cdc..5455a3cf60 100644 --- a/contributors.md +++ b/contributors.md @@ -76,6 +76,7 @@ The following people are not part of the development team, but have been contrib * Nicolas Hawrysh (xp4xbox) - Various (ride) sprite improvements. * Albert Morgese (Fusxfaranto) - Shop auto-rotation, unicode uppercasing. * Olivier Wervers (oli414) - Remove unused objects command, various bugfixes +* Christian Schubert (Osmodium) - Ensuring custom user content folders. ## Bug fixes * (halfbro) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 58393ac505..a09ac2a5cb 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -359,6 +359,8 @@ namespace OpenRCT2 _uiContext->CreateWindow(); } + EnsureUserContentDirectoriesExist(); + // TODO Ideally we want to delay this until we show the title so that we can // still open the game window and draw a progress screen for the creation // of the object cache. @@ -947,6 +949,35 @@ namespace OpenRCT2 _uiContext->Update(); } + /** + * Ensure that the custom user content folders are present + */ + void EnsureUserContentDirectoriesExist() + { + EnsureDirectoriesExist( + DIRBASE::USER, + { + DIRID::OBJECT, + DIRID::SAVE, + DIRID::SCENARIO, + DIRID::TRACK, + DIRID::LANDSCAPE, + DIRID::HEIGHTMAP, + DIRID::THEME, + DIRID::SEQUENCE, + }); + } + + void EnsureDirectoriesExist(const DIRBASE dirBase, const std::initializer_list& dirIds) + { + for (const auto& dirId : dirIds) + { + auto path = _env->GetDirectoryPath(dirBase, dirId); + if (!platform_ensure_directory_exists(path.c_str())) + log_error("Unable to create directory '%s'.", path.c_str()); + } + } + /** * Copy saved games and landscapes to user directory */ diff --git a/src/openrct2/PlatformEnvironment.cpp b/src/openrct2/PlatformEnvironment.cpp index ab548645a2..cf3a560ea7 100644 --- a/src/openrct2/PlatformEnvironment.cpp +++ b/src/openrct2/PlatformEnvironment.cpp @@ -209,6 +209,7 @@ const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] = "shaders", // SHADER "themes", // THEME "track", // TRACK + "heightmap", // HEIGHTMAP }; const char * PlatformEnvironment::FileNames[] = diff --git a/src/openrct2/PlatformEnvironment.h b/src/openrct2/PlatformEnvironment.h index 65f457ac3e..3dd3c8775c 100644 --- a/src/openrct2/PlatformEnvironment.h +++ b/src/openrct2/PlatformEnvironment.h @@ -45,6 +45,7 @@ namespace OpenRCT2 SHADER, // Contains OpenGL shaders. THEME, // Contains interface themes. TRACK, // Contains track designs. + HEIGHTMAP, // Contains heightmap data. }; enum class PATHID