Rename DIRBASE and its members

This commit is contained in:
Gymnasiast committed 2025-03-25 22:47:09 +01:00
1 parent 0437329690
commit 622a8dc525
33 files changed
+123 -123

No files matched your search

@@ -59,7 +59,7 @@ GLuint OpenGLShader::GetShaderId()
std::string OpenGLShader::GetPath(const std::string& name)
{
auto env = GetContext()->GetPlatformEnvironment();
auto shadersPath = env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::SHADER);
auto shadersPath = env->GetDirectoryPath(DirBase::openrct2, DIRID::SHADER);
auto path = Path::Combine(shadersPath, name);
if (_type == GL_VERTEX_SHADER)
{
+2 -2
View File
@@ -146,9 +146,9 @@ namespace OpenRCT2::Ui::FileBrowser
auto env = GetContext()->GetPlatformEnvironment();
if (subdir.has_value())
return env->GetDirectoryPath(DIRBASE::USER, subdir.value());
return env->GetDirectoryPath(DirBase::user, subdir.value());
else
return env->GetDirectoryPath(DIRBASE::USER);
return env->GetDirectoryPath(DirBase::user);
}
const char* GetFilterPatternByType(const LoadSaveType type, const bool isSave)
+1 -1
View File
@@ -688,7 +688,7 @@ static constexpr UIThemeWindowEntry PredefinedThemeRCT1_Entries[] =
{
auto context = GetContext();
auto env = context->GetPlatformEnvironment();
return env->GetDirectoryPath(DIRBASE::USER, DIRID::THEME);
return env->GetDirectoryPath(DirBase::user, DIRID::THEME);
}
} // namespace ThemeManager
+1 -1
View File
@@ -368,7 +368,7 @@ namespace OpenRCT2::Ui::Windows
void InstallTrackDesign()
{
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
auto destPath = env->GetDirectoryPath(OpenRCT2::DIRBASE::USER, OpenRCT2::DIRID::TRACK);
auto destPath = env->GetDirectoryPath(OpenRCT2::DirBase::user, OpenRCT2::DIRID::TRACK);
if (!Path::CreateDirectory(destPath))
{
LOG_ERROR("Unable to create directory '%s'", destPath.c_str());
+1 -1
View File
@@ -2207,7 +2207,7 @@ namespace OpenRCT2::Ui::Windows
static bool IsRCT1TitleMusicAvailable()
{
auto env = GetContext()->GetPlatformEnvironment();
auto rct1path = env->GetDirectoryPath(DIRBASE::RCT1);
auto rct1path = env->GetDirectoryPath(DirBase::rct1);
return !rct1path.empty();
}
+1 -1
View File
@@ -246,7 +246,7 @@ namespace OpenRCT2::Ui::Windows
auto context = OpenRCT2::GetContext();
auto env = context->GetPlatformEnvironment();
auto uiContext = context->GetUiContext();
uiContext->OpenFolder(env->GetDirectoryPath(OpenRCT2::DIRBASE::USER));
uiContext->OpenFolder(env->GetDirectoryPath(OpenRCT2::DirBase::user));
break;
}
default:
+2 -2
View File
@@ -70,10 +70,10 @@ void AssetPackManager::Scan()
auto context = GetContext();
auto env = context->GetPlatformEnvironment();
auto openrct2Dir = fs::u8path(env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::ASSET_PACK));
auto openrct2Dir = fs::u8path(env->GetDirectoryPath(DirBase::openrct2, DIRID::ASSET_PACK));
Scan(openrct2Dir);
auto userDirectory = fs::u8path(env->GetDirectoryPath(DIRBASE::USER, DIRID::ASSET_PACK));
auto userDirectory = fs::u8path(env->GetDirectoryPath(DirBase::user, DIRID::ASSET_PACK));
Path::CreateDirectory(userDirectory.u8string());
Scan(userDirectory);
}
+5 -5
View File
@@ -459,7 +459,7 @@ namespace OpenRCT2
{
return false;
}
_env->SetBasePath(DIRBASE::RCT2, rct2InstallPath);
_env->SetBasePath(DirBase::rct2, rct2InstallPath);
}
// The repositories are all dependent on the RCT2 path being set,
@@ -1429,7 +1429,7 @@ namespace OpenRCT2
void EnsureUserContentDirectoriesExist()
{
EnsureDirectoriesExist(
DIRBASE::USER,
DirBase::user,
{
DIRID::OBJECT,
DIRID::SAVE,
@@ -1446,7 +1446,7 @@ namespace OpenRCT2
});
}
void EnsureDirectoriesExist(const DIRBASE dirBase, const std::initializer_list<DIRID>& dirIds)
void EnsureDirectoriesExist(const DirBase dirBase, const std::initializer_list<DIRID>& dirIds)
{
for (const auto& dirId : dirIds)
{
@@ -1467,8 +1467,8 @@ namespace OpenRCT2
void CopyOriginalUserFilesOver(DIRID dirid, const std::string& pattern)
{
auto src = _env->GetDirectoryPath(DIRBASE::RCT2, dirid);
auto dst = _env->GetDirectoryPath(DIRBASE::USER, dirid);
auto src = _env->GetDirectoryPath(DirBase::rct2, dirid);
auto dst = _env->GetDirectoryPath(DirBase::user, dirid);
CopyOriginalUserFilesOver(src, dst, pattern);
}
+5 -5
View File
@@ -475,7 +475,7 @@ void SaveGameCmd(u8string_view name /* = {} */)
else
{
auto env = GetContext()->GetPlatformEnvironment();
auto savePath = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE), u8string(name) + u8".park");
auto savePath = Path::Combine(env->GetDirectoryPath(DirBase::user, DIRID::SAVE), u8string(name) + u8".park");
SaveGameWithName(savePath);
}
}
@@ -518,11 +518,11 @@ static void LimitAutosaveCount(const size_t numberOfFilesToKeep, bool processLan
size_t numAutosavesToDelete = 0;
auto environment = GetContext()->GetPlatformEnvironment();
auto folderDirectory = environment->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE);
auto folderDirectory = environment->GetDirectoryPath(DirBase::user, DIRID::SAVE);
char const* fileFilter = "autosave_*.park";
if (processLandscapeFolder)
{
folderDirectory = environment->GetDirectoryPath(DIRBASE::USER, DIRID::LANDSCAPE);
folderDirectory = environment->GetDirectoryPath(DirBase::user, DIRID::LANDSCAPE);
fileFilter = "autosave_*.park";
}
@@ -596,7 +596,7 @@ void GameAutosave()
LimitAutosaveCount(autosavesToKeep - 1, isInEditorMode());
auto env = GetContext()->GetPlatformEnvironment();
auto autosaveDir = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, subDirectory), u8"autosave");
auto autosaveDir = Path::Combine(env->GetDirectoryPath(DirBase::user, subDirectory), u8"autosave");
Path::CreateDirectory(autosaveDir);
auto path = Path::Combine(autosaveDir, timeName);
@@ -711,7 +711,7 @@ void GameLoadOrQuitNoSavePrompt()
void StartSilentRecord()
{
std::string name = Path::Combine(
OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(OpenRCT2::DIRBASE::USER), u8"debug_replay.parkrep");
OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(OpenRCT2::DirBase::user), u8"debug_replay.parkrep");
auto* replayManager = OpenRCT2::GetContext()->GetReplayManager();
if (replayManager->StartRecording(name, OpenRCT2::k_MaxReplayTicks, OpenRCT2::IReplayManager::RecordType::SILENT))
{
+41 -41
View File
@@ -87,7 +87,7 @@ private:
bool _usingRCTClassic{};
public:
explicit PlatformEnvironment(DIRBASE_VALUES basePaths)
explicit PlatformEnvironment(DirBaseValues basePaths)
{
for (size_t i = 0; i < kDirBaseCount; i++)
{
@@ -95,27 +95,27 @@ public:
}
}
u8string GetDirectoryPath(DIRBASE base) const override
u8string GetDirectoryPath(DirBase base) const override
{
return _basePath[EnumValue(base)];
}
u8string GetDirectoryPath(DIRBASE base, DIRID did) const override
u8string GetDirectoryPath(DirBase base, DIRID did) const override
{
auto basePath = GetDirectoryPath(base);
u8string_view directoryName;
switch (base)
{
default:
case DIRBASE::RCT1:
case DirBase::rct1:
directoryName = kDirectoryNamesRCT2[EnumValue(did)];
break;
case DIRBASE::RCT2:
case DirBase::rct2:
directoryName = _usingRCTClassic ? "Assets" : kDirectoryNamesRCT2[EnumValue(did)];
break;
case DIRBASE::OPENRCT2:
case DIRBASE::USER:
case DIRBASE::CONFIG:
case DirBase::openrct2:
case DirBase::user:
case DirBase::config:
directoryName = kDirectoryNamesOpenRCT2[EnumValue(did)];
break;
}
@@ -131,12 +131,12 @@ public:
return Path::Combine(basePath, fileName);
}
u8string FindFile(DIRBASE base, DIRID did, u8string_view fileName) const override
u8string FindFile(DirBase base, DIRID did, u8string_view fileName) const override
{
auto dataPath = GetDirectoryPath(base, did);
std::string alternativeFilename;
if (_usingRCTClassic && base == DIRBASE::RCT2 && did == DIRID::DATA)
if (_usingRCTClassic && base == DirBase::rct2 && did == DIRID::DATA)
{
// Special case, handle RCT Classic css ogg files
if (String::startsWith(fileName, "css", true) && String::endsWith(fileName, ".dat", true))
@@ -148,7 +148,7 @@ public:
}
auto path = Path::ResolveCasing(Path::Combine(dataPath, fileName));
if (base == DIRBASE::RCT1 && did == DIRID::DATA && !File::Exists(path))
if (base == DirBase::rct1 && did == DIRID::DATA && !File::Exists(path))
{
// Special case, handle RCT1 steam layout where some data files are under a CD root
auto basePath = GetDirectoryPath(base);
@@ -162,11 +162,11 @@ public:
return path;
}
void SetBasePath(DIRBASE base, u8string_view path) override
void SetBasePath(DirBase base, u8string_view path) override
{
_basePath[EnumValue(base)] = path;
if (base == DIRBASE::RCT2)
if (base == DirBase::rct2)
{
_usingRCTClassic = Platform::IsRCTClassicPath(path);
}
@@ -178,35 +178,35 @@ public:
}
private:
static DIRBASE GetDefaultBaseDirectory(PATHID pathid)
static DirBase GetDefaultBaseDirectory(PATHID pathid)
{
switch (pathid)
{
case PATHID::CONFIG:
case PATHID::CONFIG_SHORTCUTS_LEGACY:
case PATHID::CONFIG_SHORTCUTS:
return DIRBASE::CONFIG;
return DirBase::config;
case PATHID::CACHE_OBJECTS:
case PATHID::CACHE_TRACKS:
case PATHID::CACHE_SCENARIOS:
return DIRBASE::CACHE;
return DirBase::cache;
case PATHID::SCORES_RCT2:
return DIRBASE::RCT2;
return DirBase::rct2;
case PATHID::CHANGELOG:
case PATHID::CONTRIBUTORS:
return DIRBASE::DOCUMENTATION;
return DirBase::documentation;
case PATHID::NETWORK_GROUPS:
case PATHID::NETWORK_SERVERS:
case PATHID::NETWORK_USERS:
case PATHID::SCORES:
case PATHID::SCORES_LEGACY:
default:
return DIRBASE::USER;
return DirBase::user;
}
}
};
std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment(DIRBASE_VALUES basePaths)
std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment(DirBaseValues basePaths)
{
return std::make_unique<PlatformEnvironment>(basePaths);
}
@@ -226,35 +226,35 @@ std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment()
// Set default paths
std::string basePaths[kDirBaseCount];
basePaths[EnumValue(DIRBASE::OPENRCT2)] = Platform::GetInstallPath();
basePaths[EnumValue(DIRBASE::USER)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_DATA), subDirectory);
basePaths[EnumValue(DIRBASE::CONFIG)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CONFIG), subDirectory);
basePaths[EnumValue(DIRBASE::CACHE)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CACHE), subDirectory);
basePaths[EnumValue(DIRBASE::DOCUMENTATION)] = Platform::GetDocsPath();
basePaths[EnumValue(DirBase::openrct2)] = Platform::GetInstallPath();
basePaths[EnumValue(DirBase::user)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_DATA), subDirectory);
basePaths[EnumValue(DirBase::config)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CONFIG), subDirectory);
basePaths[EnumValue(DirBase::cache)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CACHE), subDirectory);
basePaths[EnumValue(DirBase::documentation)] = Platform::GetDocsPath();
// Override paths that have been specified via the command line
if (!gCustomRCT1DataPath.empty())
{
basePaths[EnumValue(DIRBASE::RCT1)] = gCustomRCT1DataPath;
basePaths[EnumValue(DirBase::rct1)] = gCustomRCT1DataPath;
}
if (!gCustomRCT2DataPath.empty())
{
basePaths[EnumValue(DIRBASE::RCT2)] = gCustomRCT2DataPath;
basePaths[EnumValue(DirBase::rct2)] = gCustomRCT2DataPath;
}
if (!gCustomOpenRCT2DataPath.empty())
{
basePaths[EnumValue(DIRBASE::OPENRCT2)] = gCustomOpenRCT2DataPath;
basePaths[EnumValue(DirBase::openrct2)] = gCustomOpenRCT2DataPath;
}
if (!gCustomUserDataPath.empty())
{
basePaths[EnumValue(DIRBASE::USER)] = gCustomUserDataPath;
basePaths[EnumValue(DIRBASE::CONFIG)] = gCustomUserDataPath;
basePaths[EnumValue(DIRBASE::CACHE)] = gCustomUserDataPath;
basePaths[EnumValue(DirBase::user)] = gCustomUserDataPath;
basePaths[EnumValue(DirBase::config)] = gCustomUserDataPath;
basePaths[EnumValue(DirBase::cache)] = gCustomUserDataPath;
}
if (basePaths[EnumValue(DIRBASE::DOCUMENTATION)].empty())
if (basePaths[EnumValue(DirBase::documentation)].empty())
{
basePaths[EnumValue(DIRBASE::DOCUMENTATION)] = basePaths[EnumValue(DIRBASE::OPENRCT2)];
basePaths[EnumValue(DirBase::documentation)] = basePaths[EnumValue(DirBase::openrct2)];
}
auto env = OpenRCT2::CreatePlatformEnvironment(basePaths);
@@ -268,20 +268,20 @@ std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment()
}
if (gCustomRCT1DataPath.empty())
{
env->SetBasePath(DIRBASE::RCT1, Config::Get().general.RCT1Path);
env->SetBasePath(DirBase::rct1, Config::Get().general.RCT1Path);
}
if (gCustomRCT2DataPath.empty())
{
env->SetBasePath(DIRBASE::RCT2, Config::Get().general.RCT2Path);
env->SetBasePath(DirBase::rct2, Config::Get().general.RCT2Path);
}
// Log base paths
LOG_VERBOSE("DIRBASE::RCT1 : %s", env->GetDirectoryPath(DIRBASE::RCT1).c_str());
LOG_VERBOSE("DIRBASE::RCT2 : %s", env->GetDirectoryPath(DIRBASE::RCT2).c_str());
LOG_VERBOSE("DIRBASE::OPENRCT2: %s", env->GetDirectoryPath(DIRBASE::OPENRCT2).c_str());
LOG_VERBOSE("DIRBASE::USER : %s", env->GetDirectoryPath(DIRBASE::USER).c_str());
LOG_VERBOSE("DIRBASE::CONFIG : %s", env->GetDirectoryPath(DIRBASE::CONFIG).c_str());
LOG_VERBOSE("DIRBASE::CACHE : %s", env->GetDirectoryPath(DIRBASE::CACHE).c_str());
LOG_VERBOSE("DirBase::rct1 : %s", env->GetDirectoryPath(DirBase::rct1).c_str());
LOG_VERBOSE("DirBase::rct2 : %s", env->GetDirectoryPath(DirBase::rct2).c_str());
LOG_VERBOSE("DirBase::openrct2: %s", env->GetDirectoryPath(DirBase::openrct2).c_str());
LOG_VERBOSE("DirBase::user : %s", env->GetDirectoryPath(DirBase::user).c_str());
LOG_VERBOSE("DirBase::config : %s", env->GetDirectoryPath(DirBase::config).c_str());
LOG_VERBOSE("DirBase::cache : %s", env->GetDirectoryPath(DirBase::cache).c_str());
return env;
}
+14 -14
View File
@@ -16,18 +16,18 @@
namespace OpenRCT2
{
enum class DIRBASE : size_t
enum class DirBase : size_t
{
RCT1, // Base directory for original RollerCoaster Tycoon 1 content.
RCT2, // Base directory for original RollerCoaster Tycoon 2 content.
OPENRCT2, // Base directory for OpenRCT2 installation.
USER, // Base directory for OpenRCT2 user content.
CONFIG, // Base directory for OpenRCT2 configuration.
CACHE, // Base directory for OpenRCT2 cache files.
DOCUMENTATION, // Base directory for OpenRCT2 doc files.
rct1, // Base directory for original RollerCoaster Tycoon 1 content.
rct2, // Base directory for original RollerCoaster Tycoon 2 content.
openrct2, // Base directory for OpenRCT2 installation.
user, // Base directory for OpenRCT2 user content.
config, // Base directory for OpenRCT2 configuration.
cache, // Base directory for OpenRCT2 cache files.
documentation, // Base directory for OpenRCT2 doc files.
};
constexpr size_t kDirBaseCount = 7;
using DIRBASE_VALUES = u8string[kDirBaseCount];
using DirBaseValues = u8string[kDirBaseCount];
enum class DIRID
{
@@ -80,15 +80,15 @@ namespace OpenRCT2
{
virtual ~IPlatformEnvironment() = default;
virtual u8string GetDirectoryPath(DIRBASE base) const = 0;
virtual u8string GetDirectoryPath(DIRBASE base, DIRID did) const = 0;
virtual u8string GetDirectoryPath(DirBase base) const = 0;
virtual u8string GetDirectoryPath(DirBase base, DIRID did) const = 0;
virtual u8string GetFilePath(PATHID pathid) const = 0;
virtual u8string FindFile(DIRBASE base, DIRID did, u8string_view fileName) const = 0;
virtual void SetBasePath(DIRBASE base, u8string_view path) = 0;
virtual u8string FindFile(DirBase base, DIRID did, u8string_view fileName) const = 0;
virtual void SetBasePath(DirBase base, u8string_view path) = 0;
virtual bool IsUsingClassic() const = 0;
};
[[nodiscard]] std::unique_ptr<IPlatformEnvironment> CreatePlatformEnvironment(DIRBASE_VALUES basePaths);
[[nodiscard]] std::unique_ptr<IPlatformEnvironment> CreatePlatformEnvironment(DirBaseValues basePaths);
[[nodiscard]] std::unique_ptr<IPlatformEnvironment> CreatePlatformEnvironment();
} // namespace OpenRCT2
+2 -2
View File
@@ -414,7 +414,7 @@ namespace OpenRCT2
if (res != cmpData.spriteChanges.end())
{
std::string outputPath = GetContext()->GetPlatformEnvironment()->GetDirectoryPath(
DIRBASE::USER, DIRID::LOG_DESYNCS);
DirBase::user, DIRID::LOG_DESYNCS);
char uniqueFileName[128] = {};
snprintf(uniqueFileName, sizeof(uniqueFileName), "replay_desync_%u.txt", currentTicks);
@@ -624,7 +624,7 @@ namespace OpenRCT2
fileName += ".parkrep";
}
std::string outPath = GetContext()->GetPlatformEnvironment()->GetDirectoryPath(DIRBASE::USER, DIRID::REPLAY);
std::string outPath = GetContext()->GetPlatformEnvironment()->GetDirectoryPath(DirBase::user, DIRID::REPLAY);
std::string outFile = Path::Combine(outPath, fileName);
bool loaded = false;
+1 -1
View File
@@ -253,7 +253,7 @@ namespace OpenRCT2::Audio
static bool IsRCT1TitleMusicAvailable()
{
auto env = GetContext()->GetPlatformEnvironment();
auto rct1path = env->GetDirectoryPath(DIRBASE::RCT1);
auto rct1path = env->GetDirectoryPath(DirBase::rct1);
return !rct1path.empty();
}
+2 -2
View File
@@ -819,7 +819,7 @@ namespace OpenRCT2::Config
u8string GetDefaultPath()
{
auto env = GetContext()->GetPlatformEnvironment();
return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"config.ini");
return Path::Combine(env->GetDirectoryPath(DirBase::user), u8"config.ini");
}
bool SaveToPath(u8string_view path)
@@ -903,7 +903,7 @@ namespace OpenRCT2::Config
}
const std::string dest = Path::Combine(
GetContext()->GetPlatformEnvironment()->GetDirectoryPath(DIRBASE::CONFIG), "rct2");
GetContext()->GetPlatformEnvironment()->GetDirectoryPath(DirBase::config), "rct2");
while (true)
{
+2 -2
View File
@@ -451,7 +451,7 @@ bool GfxLoadG1(const IPlatformEnvironment& env)
LOG_VERBOSE("GfxLoadG1(...)");
try
{
auto path = env.FindFile(DIRBASE::RCT2, DIRID::DATA, u8"g1.dat");
auto path = env.FindFile(DirBase::rct2, DIRID::DATA, u8"g1.dat");
auto fs = FileStream(path, FileMode::open);
_g1.header = fs.ReadValue<RCTG1Header>();
@@ -528,7 +528,7 @@ bool GfxLoadG2()
auto env = GetContext()->GetPlatformEnvironment();
std::string path = Path::Combine(env->GetDirectoryPath(DIRBASE::OPENRCT2), u8"g2.dat");
std::string path = Path::Combine(env->GetDirectoryPath(DirBase::openrct2), u8"g2.dat");
try
{
@@ -1318,7 +1318,7 @@ static void ConsoleCommandLoadPark([[maybe_unused]] InteractiveConsole& console,
{
// no / or \ was included. File should be in save dir.
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
auto directory = env->GetDirectoryPath(OpenRCT2::DIRBASE::USER, OpenRCT2::DIRID::SAVE);
auto directory = env->GetDirectoryPath(OpenRCT2::DirBase::user, OpenRCT2::DIRID::SAVE);
savePath = Path::Combine(directory, argv[0]);
}
else
@@ -1391,7 +1391,7 @@ static void ConsoleCommandReplayStartRecord(InteractiveConsole& console, const a
name += ".parkrep";
}
std::string outPath = OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(
OpenRCT2::DIRBASE::USER, OpenRCT2::DIRID::REPLAY);
OpenRCT2::DirBase::user, OpenRCT2::DIRID::REPLAY);
name = Path::Combine(outPath, name);
// If ticks are specified by user use that otherwise maximum ticks specified by const.
@@ -1517,7 +1517,7 @@ static void ConsoleCommandReplayNormalise(InteractiveConsole& console, const arg
outputFile += ".parkrep";
}
std::string outPath = OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(
OpenRCT2::DIRBASE::USER, OpenRCT2::DIRID::REPLAY);
OpenRCT2::DirBase::user, OpenRCT2::DIRID::REPLAY);
outputFile = Path::Combine(outPath, outputFile);
auto* replayManager = OpenRCT2::GetContext()->GetReplayManager();
+1 -1
View File
@@ -118,7 +118,7 @@ static std::string ScreenshotGetParkName()
static std::string ScreenshotGetDirectory()
{
auto env = GetContext()->GetPlatformEnvironment();
return env->GetDirectoryPath(DIRBASE::USER, DIRID::SCREENSHOT);
return env->GetDirectoryPath(DirBase::user, DIRID::SCREENSHOT);
}
static std::pair<RealWorldDate, RealWorldTime> ScreenshotGetDateTime()
@@ -70,7 +70,7 @@ const char* LocalisationService::GetString(StringId id) const
std::string LocalisationService::GetLanguagePath(uint32_t languageId) const
{
auto locale = std::string(LanguagesDescriptors[languageId].locale);
auto languageDirectory = _env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::LANGUAGE);
auto languageDirectory = _env->GetDirectoryPath(DirBase::openrct2, DIRID::LANGUAGE);
auto languagePath = Path::Combine(languageDirectory, locale + u8".txt");
return languagePath;
}
+6 -6
View File
@@ -1019,7 +1019,7 @@ void NetworkBase::SaveGroups()
if (GetMode() == NETWORK_MODE_SERVER)
{
auto env = GetContext().GetPlatformEnvironment();
auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"groups.json");
auto path = Path::Combine(env->GetDirectoryPath(DirBase::user), u8"groups.json");
json_t jsonGroups = json_t::array();
for (auto& group : group_list)
@@ -1079,7 +1079,7 @@ void NetworkBase::LoadGroups()
group_list.clear();
auto env = GetContext().GetPlatformEnvironment();
auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"groups.json");
auto path = Path::Combine(env->GetDirectoryPath(DirBase::user), u8"groups.json");
json_t jsonGroupConfig;
if (File::Exists(path))
@@ -1166,7 +1166,7 @@ void NetworkBase::AppendLog(std::ostream& fs, std::string_view s)
void NetworkBase::BeginChatLog()
{
auto env = GetContext().GetPlatformEnvironment();
auto directory = env->GetDirectoryPath(DIRBASE::USER, DIRID::LOG_CHAT);
auto directory = env->GetDirectoryPath(DirBase::user, DIRID::LOG_CHAT);
_chatLogPath = BeginLog(directory, "", _chatLogFilenameFormat);
_chat_log_fs.open(fs::u8path(_chatLogPath), std::ios::out | std::ios::app);
}
@@ -1187,7 +1187,7 @@ void NetworkBase::CloseChatLog()
void NetworkBase::BeginServerLog()
{
auto env = GetContext().GetPlatformEnvironment();
auto directory = env->GetDirectoryPath(DIRBASE::USER, DIRID::LOG_SERVER);
auto directory = env->GetDirectoryPath(DirBase::user, DIRID::LOG_SERVER);
_serverLogPath = BeginLog(directory, ServerName, _serverLogFilenameFormat);
_server_log_fs.open(fs::u8path(_serverLogPath), std::ios::out | std::ios::app | std::ios::binary);
@@ -2556,7 +2556,7 @@ void NetworkBase::Client_Handle_GAMESTATE(NetworkConnection& connection, Network
{
GameStateCompareData cmpData = snapshots->Compare(serverSnapshot, *desyncSnapshot);
std::string outputPath = GetContext().GetPlatformEnvironment()->GetDirectoryPath(DIRBASE::USER, DIRID::LOG_DESYNCS);
std::string outputPath = GetContext().GetPlatformEnvironment()->GetDirectoryPath(DirBase::user, DIRID::LOG_DESYNCS);
Path::CreateDirectory(outputPath);
@@ -4011,7 +4011,7 @@ void NetworkAppendServerLog(const utf8* text)
static u8string NetworkGetKeysDirectory()
{
auto env = GetContext()->GetPlatformEnvironment();
return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"keys");
return Path::Combine(env->GetDirectoryPath(DirBase::user), u8"keys");
}
static u8string NetworkGetPrivateKeyPath(u8string_view playerName)
+1 -1
View File
@@ -213,7 +213,7 @@ NetworkUser* NetworkUserManager::GetOrAddUser(const std::string& hash)
u8string NetworkUserManager::GetStorePath()
{
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
return Path::Combine(env->GetDirectoryPath(OpenRCT2::DIRBASE::USER), kUserStoreFilename);
return Path::Combine(env->GetDirectoryPath(OpenRCT2::DirBase::user), kUserStoreFilename);
}
#endif
+1 -1
View File
@@ -243,7 +243,7 @@ bool ServerList::WriteFavourites(const std::vector<ServerListEntry>& entries) co
LOG_VERBOSE("server_list_write(%d, 0x%p)", entries.size(), entries.data());
auto env = GetContext()->GetPlatformEnvironment();
auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"servers.cfg");
auto path = Path::Combine(env->GetDirectoryPath(DirBase::user), u8"servers.cfg");
try
{
+1 -1
View File
@@ -380,7 +380,7 @@ std::vector<int32_t> ImageTable::ParseRange(std::string s)
std::string ImageTable::FindLegacyObject(const std::string& name)
{
const auto env = GetContext()->GetPlatformEnvironment();
auto objectsPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::OBJECT);
auto objectsPath = env->GetDirectoryPath(DirBase::rct2, DIRID::OBJECT);
auto objectPath = Path::Combine(objectsPath, name);
if (File::Exists(objectPath))
{
+1 -1
View File
@@ -227,7 +227,7 @@ ObjectAsset MusicObject::GetAsset(IReadObjectContext& context, std::string_view
if (path.find("$RCT2:DATA/") == 0)
{
auto env = GetContext()->GetPlatformEnvironment();
auto path2 = env->FindFile(DIRBASE::RCT2, DIRID::DATA, path.substr(11));
auto path2 = env->FindFile(DirBase::rct2, DIRID::DATA, path.substr(11));
return ObjectAsset(path2);
}
+3 -3
View File
@@ -86,8 +86,8 @@ public:
: FileIndex(
"object index", MAGIC_NUMBER, VERSION, env.GetFilePath(PATHID::CACHE_OBJECTS), std::string(PATTERN),
std::vector<std::string>{
env.GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
env.GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT),
env.GetDirectoryPath(DirBase::openrct2, DIRID::OBJECT),
env.GetDirectoryPath(DirBase::user, DIRID::OBJECT),
})
, _objectRepository(objectRepository)
{
@@ -586,7 +586,7 @@ private:
std::string GetPathForNewObject(ObjectGeneration generation, std::string_view name)
{
// Get object directory and create it if it doesn't exist
auto userObjPath = _env->GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT);
auto userObjPath = _env->GetDirectoryPath(DirBase::user, DIRID::OBJECT);
Path::CreateDirectory(userObjPath);
// Find a unique file name
+7 -7
View File
@@ -79,34 +79,34 @@ ResourceTable::SourceInfo ResourceTable::ParseSource(std::string_view source)
else if (String::startsWith(base, "$G1"))
{
auto env = GetContext()->GetPlatformEnvironment();
auto dataPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA);
auto dataPath = env->GetDirectoryPath(DirBase::rct2, DIRID::DATA);
info.Kind = SourceKind::G1;
// info.Path = env->FindFile(DIRBASE::RCT2, DIRID::DATA, "g1.dat");
// info.Path = env->FindFile(DirBase::rct2, DIRID::DATA, "g1.dat");
}
else if (String::startsWith(base, "$CSG"))
{
auto env = GetContext()->GetPlatformEnvironment();
auto dataPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA);
auto dataPath = env->GetDirectoryPath(DirBase::rct2, DIRID::DATA);
info.Kind = SourceKind::Csg;
// info.Path = env->FindFile(DIRBASE::RCT2, DIRID::DATA, "g1.dat");
// info.Path = env->FindFile(DirBase::rct2, DIRID::DATA, "g1.dat");
}
else if (String::startsWith(base, "$RCT1:DATA/"))
{
auto env = GetContext()->GetPlatformEnvironment();
info.Kind = SourceKind::Data;
info.Path = env->FindFile(DIRBASE::RCT1, DIRID::DATA, fileName);
info.Path = env->FindFile(DirBase::rct1, DIRID::DATA, fileName);
}
else if (String::startsWith(base, "$RCT2:DATA/"))
{
auto env = GetContext()->GetPlatformEnvironment();
info.Kind = SourceKind::Data;
info.Path = env->FindFile(DIRBASE::RCT2, DIRID::DATA, fileName);
info.Path = env->FindFile(DirBase::rct2, DIRID::DATA, fileName);
}
else if (String::startsWith(base, "$RCT2:OBJDATA/"))
{
auto env = GetContext()->GetPlatformEnvironment();
info.Kind = SourceKind::ObjData;
info.Path = env->FindFile(DIRBASE::RCT2, DIRID::OBJECT, fileName);
info.Path = env->FindFile(DirBase::rct2, DIRID::OBJECT, fileName);
}
else if (!String::startsWith(base, "$"))
{
+1 -1
View File
@@ -317,7 +317,7 @@ static bool OnCrash(
static std::wstring GetDumpDirectory()
{
auto env = GetContext()->GetPlatformEnvironment();
auto crashPath = env->GetDirectoryPath(DIRBASE::USER, DIRID::CRASH);
auto crashPath = env->GetDirectoryPath(DirBase::user, DIRID::CRASH);
auto result = String::toWideChar(crashPath);
return result;
+1 -1
View File
@@ -683,7 +683,7 @@ static u8string getScenarioSHA256(u8string_view scenarioPath)
static u8string GetPatchFileName(u8string_view scenarioHash)
{
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
auto scenarioPatches = env->GetDirectoryPath(OpenRCT2::DIRBASE::OPENRCT2, OpenRCT2::DIRID::SCENARIO_PATCHES);
auto scenarioPatches = env->GetDirectoryPath(OpenRCT2::DirBase::openrct2, OpenRCT2::DIRID::SCENARIO_PATCHES);
auto scenarioPatchFile = OpenRCT2::Path::WithExtension(scenarioHash.substr(0, 7), ".parkpatch");
return OpenRCT2::Path::Combine(scenarioPatches, scenarioPatchFile);
}
+4 -4
View File
@@ -62,9 +62,9 @@ public:
: FileIndex(
"track design index", MAGIC_NUMBER, VERSION, env.GetFilePath(PATHID::CACHE_TRACKS), std::string(PATTERN),
std::vector<std::string>({
env.GetDirectoryPath(DIRBASE::RCT1, DIRID::TRACK),
env.GetDirectoryPath(DIRBASE::RCT2, DIRID::TRACK),
env.GetDirectoryPath(DIRBASE::USER, DIRID::TRACK),
env.GetDirectoryPath(DirBase::rct1, DIRID::TRACK),
env.GetDirectoryPath(DirBase::rct2, DIRID::TRACK),
env.GetDirectoryPath(DirBase::user, DIRID::TRACK),
}))
{
}
@@ -257,7 +257,7 @@ public:
std::string Install(const std::string& path, const std::string& name) override
{
std::string result;
std::string installDir = _env->GetDirectoryPath(DIRBASE::USER, DIRID::TRACK);
std::string installDir = _env->GetDirectoryPath(DirBase::user, DIRID::TRACK);
std::string newPath = Path::Combine(installDir, name + Path::GetExtension(path));
if (File::Copy(path, newPath, false))
+1 -1
View File
@@ -121,7 +121,7 @@ void ScenarioReset(GameState_t& gameState)
// Set the last saved game path
auto env = GetContext()->GetPlatformEnvironment();
auto savePath = env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE);
auto savePath = env->GetDirectoryPath(DirBase::user, DIRID::SAVE);
gScenarioSavePath = Path::Combine(savePath, gameState.park.Name + u8".park");
gameState.currentExpenditure = 0;
+5 -5
View File
@@ -132,9 +132,9 @@ public:
: FileIndex(
"scenario index", MAGIC_NUMBER, VERSION, env.GetFilePath(PATHID::CACHE_SCENARIOS), std::string(PATTERN),
std::vector<std::string>({
env.GetDirectoryPath(DIRBASE::RCT1, DIRID::SCENARIO),
env.GetDirectoryPath(DIRBASE::RCT2, DIRID::SCENARIO),
env.GetDirectoryPath(DIRBASE::USER, DIRID::SCENARIO),
env.GetDirectoryPath(DirBase::rct1, DIRID::SCENARIO),
env.GetDirectoryPath(DirBase::rct2, DIRID::SCENARIO),
env.GetDirectoryPath(DirBase::user, DIRID::SCENARIO),
}))
{
}
@@ -437,10 +437,10 @@ private:
*/
void ImportMegaPark()
{
auto mpdatPath = _env->FindFile(DIRBASE::RCT1, DIRID::DATA, "mp.dat");
auto mpdatPath = _env->FindFile(DirBase::rct1, DIRID::DATA, "mp.dat");
if (File::Exists(mpdatPath))
{
auto scenarioDirectory = _env->GetDirectoryPath(DIRBASE::USER, DIRID::SCENARIO);
auto scenarioDirectory = _env->GetDirectoryPath(DirBase::user, DIRID::SCENARIO);
auto expectedSc21Path = Path::Combine(scenarioDirectory, "sc21.sc4");
auto sc21Path = Path::ResolveCasing(expectedSc21Path);
if (!File::Exists(sc21Path))
@@ -255,13 +255,13 @@ namespace OpenRCT2::TitleSequenceManager
static std::string GetDataSequencesPath()
{
auto env = GetContext()->GetPlatformEnvironment();
return env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::SEQUENCE);
return env->GetDirectoryPath(DirBase::openrct2, DIRID::SEQUENCE);
}
static std::string GetUserSequencesPath()
{
auto env = GetContext()->GetPlatformEnvironment();
return env->GetDirectoryPath(DIRBASE::USER, DIRID::SEQUENCE);
return env->GetDirectoryPath(DirBase::user, DIRID::SEQUENCE);
}
static bool IsNameReserved(const std::string& name)
+2 -2
View File
@@ -592,7 +592,7 @@ std::vector<std::string> ScriptEngine::GetPluginFiles() const
{
// Scan for .js files in plugin directory
std::vector<std::string> pluginFiles;
auto base = _env.GetDirectoryPath(DIRBASE::USER, DIRID::PLUGIN);
auto base = _env.GetDirectoryPath(DirBase::user, DIRID::PLUGIN);
if (Path::DirectoryExists(base))
{
auto pattern = Path::Combine(base, u8"*.js");
@@ -794,7 +794,7 @@ void ScriptEngine::SetupHotReloading()
{
try
{
auto base = _env.GetDirectoryPath(DIRBASE::USER, DIRID::PLUGIN);
auto base = _env.GetDirectoryPath(DirBase::user, DIRID::PLUGIN);
if (Path::DirectoryExists(base))
{
_pluginFileWatcher = std::make_unique<FileWatcher>(base);
+1 -1
View File
@@ -32,7 +32,7 @@ TEST(FetchAndApplyScenarioPatch, expected_json_format)
ASSERT_TRUE(initialised);
auto env = context->GetPlatformEnvironment();
auto scenarioPatches = env->GetDirectoryPath(OpenRCT2::DIRBASE::OPENRCT2, OpenRCT2::DIRID::SCENARIO_PATCHES);
auto scenarioPatches = env->GetDirectoryPath(OpenRCT2::DirBase::openrct2, OpenRCT2::DIRID::SCENARIO_PATCHES);
std::error_code ec;
OpenRCT2::RCT12::SetDryRun(true);