1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-11 10:02:27 +01:00

Use u8 strings when dealing with file paths

This commit is contained in:
Hielke Morsink
2022-02-27 22:23:35 +01:00
parent 55c71b0c74
commit 6ba0a3bd49
27 changed files with 115 additions and 120 deletions

View File

@@ -531,7 +531,7 @@ namespace ThemeManager
NumPredefinedThemes++; NumPredefinedThemes++;
} }
auto themesPattern = Path::Combine(GetThemePath(), "*.json"); auto themesPattern = Path::Combine(GetThemePath(), u8"*.json");
auto scanner = Path::ScanDirectory(themesPattern, true); auto scanner = Path::ScanDirectory(themesPattern, true);
while (scanner->Next()) while (scanner->Next())
{ {
@@ -633,7 +633,7 @@ namespace ThemeManager
std::string GetThemeFileName(const std::string& name) std::string GetThemeFileName(const std::string& name)
{ {
auto themeDirectory = GetThemePath(); auto themeDirectory = GetThemePath();
auto themePath = Path::Combine(themeDirectory, name + ".json"); auto themePath = Path::Combine(themeDirectory, name + u8".json");
return themePath; return themePath;
} }

View File

@@ -439,7 +439,7 @@ static void WindowInstallTrackDesign(rct_window* w)
return; return;
} }
destPath = Path::Combine(destPath, _trackName + ".td6"); destPath = Path::Combine(destPath, _trackName + u8".td6");
if (File::Exists(destPath)) if (File::Exists(destPath))
{ {

View File

@@ -333,18 +333,18 @@ namespace OpenRCT2
if (!(_env->GetDirectoryPath(DIRBASE::RCT1).empty())) if (!(_env->GetDirectoryPath(DIRBASE::RCT1).empty()))
{ {
auto dataPath = _env->GetDirectoryPath(DIRBASE::RCT1, DIRID::DATA); auto dataPath = _env->GetDirectoryPath(DIRBASE::RCT1, DIRID::DATA);
result = Path::ResolveCasing(Path::Combine(dataPath, "css17.dat")); result = Path::ResolveCasing(Path::Combine(dataPath, u8"css17.dat"));
if (!File::Exists(result)) if (!File::Exists(result))
{ {
auto rct1Path = _env->GetDirectoryPath(DIRBASE::RCT1); auto rct1Path = _env->GetDirectoryPath(DIRBASE::RCT1);
result = Path::ResolveCasing(Path::Combine(rct1Path, "RCTdeluxe_install", "Data", "css17.dat")); result = Path::ResolveCasing(Path::Combine(rct1Path, u8"RCTdeluxe_install", u8"Data", u8"css17.dat"));
} }
} }
else else
{ {
auto dataPath = _env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA); auto dataPath = _env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA);
result = Path::ResolveCasing(Path::Combine(dataPath, "css50.dat")); result = Path::ResolveCasing(Path::Combine(dataPath, u8"css50.dat"));
} }
} }
else if (pathId >= 0 && pathId < PATH_ID_END) else if (pathId >= 0 && pathId < PATH_ID_END)

View File

@@ -560,7 +560,7 @@ void save_game_cmd(u8string_view name /* = {} */)
else else
{ {
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
auto savePath = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE), u8string(name) + ".park"); auto savePath = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE), u8string(name) + u8".park");
save_game_with_name(savePath); save_game_with_name(savePath);
} }
} }
@@ -686,11 +686,11 @@ void game_autosave()
limit_autosave_count(autosavesToKeep - 1, (gScreenFlags & SCREEN_FLAGS_EDITOR)); limit_autosave_count(autosavesToKeep - 1, (gScreenFlags & SCREEN_FLAGS_EDITOR));
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
auto autosaveDir = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, subDirectory), "autosave"); auto autosaveDir = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, subDirectory), u8"autosave");
Platform::EnsureDirectoryExists(autosaveDir.c_str()); Platform::EnsureDirectoryExists(autosaveDir.c_str());
auto path = Path::Combine(autosaveDir, timeName); auto path = Path::Combine(autosaveDir, timeName);
auto backupFileName = u8string("autosave") + fileExtension + ".bak"; auto backupFileName = u8string(u8"autosave") + fileExtension + u8".bak";
auto backupPath = Path::Combine(autosaveDir, backupFileName); auto backupPath = Path::Combine(autosaveDir, backupFileName);
if (File::Exists(path)) if (File::Exists(path))
@@ -764,7 +764,7 @@ void game_load_or_quit_no_save_prompt()
void start_silent_record() void start_silent_record()
{ {
std::string name = Path::Combine( std::string name = Path::Combine(
OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(OpenRCT2::DIRBASE::USER), "debug_replay.parkrep"); OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(OpenRCT2::DIRBASE::USER), u8"debug_replay.parkrep");
auto* replayManager = OpenRCT2::GetContext()->GetReplayManager(); auto* replayManager = OpenRCT2::GetContext()->GetReplayManager();
if (replayManager->StartRecording(name, OpenRCT2::k_MaxReplayTicks, OpenRCT2::IReplayManager::RecordType::SILENT)) if (replayManager->StartRecording(name, OpenRCT2::k_MaxReplayTicks, OpenRCT2::IReplayManager::RecordType::SILENT))
{ {

View File

@@ -39,7 +39,7 @@ public:
u8string GetDirectoryPath(DIRBASE base, DIRID did) const override u8string GetDirectoryPath(DIRBASE base, DIRID did) const override
{ {
auto basePath = GetDirectoryPath(base); auto basePath = GetDirectoryPath(base);
const utf8* directoryName; u8string_view directoryName;
switch (base) switch (base)
{ {
default: default:
@@ -72,8 +72,8 @@ public:
private: private:
static const char* DirectoryNamesRCT2[]; static const char* DirectoryNamesRCT2[];
static const char* DirectoryNamesOpenRCT2[]; static const u8string DirectoryNamesOpenRCT2[];
static const char* FileNames[]; static const u8string FileNames[];
static DIRBASE GetDefaultBaseDirectory(PATHID pathid) static DIRBASE GetDefaultBaseDirectory(PATHID pathid)
{ {
@@ -109,12 +109,12 @@ std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment(DIRBAS
return std::make_unique<PlatformEnvironment>(basePaths); return std::make_unique<PlatformEnvironment>(basePaths);
} }
static std::string GetOpenRCT2DirectoryName() static u8string GetOpenRCT2DirectoryName()
{ {
#if defined(__ANDROID__) #if defined(__ANDROID__)
return "openrct2-user"; return u8"openrct2-user";
#else #else
return "OpenRCT2"; return u8"OpenRCT2";
#endif #endif
} }
@@ -187,65 +187,60 @@ std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment()
return env; return env;
} }
// clang-format off const char* PlatformEnvironment::DirectoryNamesRCT2[] = {
const char * PlatformEnvironment::DirectoryNamesRCT2[] = "Data", // DATA
{ "Landscapes", // LANDSCAPE
"Data", // DATA nullptr, // LANGUAGE
"Landscapes", // LANDSCAPE nullptr, // LOG_CHAT
nullptr, // LANGUAGE nullptr, // LOG_SERVER
nullptr, // LOG_CHAT nullptr, // NETWORK_KEY
nullptr, // LOG_SERVER "ObjData", // OBJECT
nullptr, // NETWORK_KEY nullptr, // PLUGIN
"ObjData", // OBJECT "Saved Games", // SAVE
nullptr, // PLUGIN "Scenarios", // SCENARIO
"Saved Games", // SAVE nullptr, // SCREENSHOT
"Scenarios", // SCENARIO nullptr, // SEQUENCE
nullptr, // SCREENSHOT nullptr, // SHADER
nullptr, // SEQUENCE nullptr, // THEME
nullptr, // SHADER "Tracks", // TRACK
nullptr, // THEME
"Tracks", // TRACK
}; };
const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] = const u8string PlatformEnvironment::DirectoryNamesOpenRCT2[] = {
{ u8"data", // DATA
"data", // DATA u8"landscape", // LANDSCAPE
"landscape", // LANDSCAPE u8"language", // LANGUAGE
"language", // LANGUAGE u8"chatlogs", // LOG_CHAT
"chatlogs", // LOG_CHAT u8"serverlogs", // LOG_SERVER
"serverlogs", // LOG_SERVER u8"keys", // NETWORK_KEY
"keys", // NETWORK_KEY u8"object", // OBJECT
"object", // OBJECT u8"plugin", // PLUGIN
"plugin", // PLUGIN u8"save", // SAVE
"save", // SAVE u8"scenario", // SCENARIO
"scenario", // SCENARIO u8"screenshot", // SCREENSHOT
"screenshot", // SCREENSHOT u8"sequence", // SEQUENCE
"sequence", // SEQUENCE u8"shaders", // SHADER
"shaders", // SHADER u8"themes", // THEME
"themes", // THEME u8"track", // TRACK
"track", // TRACK u8"heightmap", // HEIGHTMAP
"heightmap", // HEIGHTMAP u8"replay", // REPLAY
"replay", // REPLAY u8"desyncs", // DESYNCS
"desyncs", // DESYNCS u8"crash", // CRASH
"crash", // CRASH
}; };
const char * PlatformEnvironment::FileNames[] = const u8string PlatformEnvironment::FileNames[] = {
{ u8"config.ini", // CONFIG
"config.ini", // CONFIG u8"hotkeys.dat", // CONFIG_SHORTCUTS_LEGACY
"hotkeys.dat", // CONFIG_SHORTCUTS_LEGACY u8"shortcuts.json", // CONFIG_SHORTCUTS
"shortcuts.json", // CONFIG_SHORTCUTS u8"objects.idx", // CACHE_OBJECTS
"objects.idx", // CACHE_OBJECTS u8"tracks.idx", // CACHE_TRACKS
"tracks.idx", // CACHE_TRACKS u8"scenarios.idx", // CACHE_SCENARIOS
"scenarios.idx", // CACHE_SCENARIOS u8"Data" PATH_SEPARATOR "mp.dat", // MP_DAT
"Data" PATH_SEPARATOR "mp.dat", // MP_DAT u8"groups.json", // NETWORK_GROUPS
"groups.json", // NETWORK_GROUPS u8"servers.cfg", // NETWORK_SERVERS
"servers.cfg", // NETWORK_SERVERS u8"users.json", // NETWORK_USERS
"users.json", // NETWORK_USERS u8"highscores.dat", // SCORES
"highscores.dat", // SCORES u8"scores.dat", // SCORES (LEGACY)
"scores.dat", // SCORES (LEGACY) u8"Saved Games" PATH_SEPARATOR "scores.dat", // SCORES (RCT2)
"Saved Games" PATH_SEPARATOR "scores.dat", // SCORES (RCT2) u8"changelog.txt", // CHANGELOG
"changelog.txt", // CHANGELOG u8"plugin.store.json" // PLUGIN_STORE
"plugin.store.json" // PLUGIN_STORE
}; };
// clang-format on

View File

@@ -356,7 +356,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator* enumerator)
// Check if g1.dat exists (naive but good check) // Check if g1.dat exists (naive but good check)
Console::WriteLine("Checking g1.dat..."); Console::WriteLine("Checking g1.dat...");
auto pathG1Check = Path::Combine(path, "Data", "g1.dat"); auto pathG1Check = Path::Combine(path, u8"Data", u8"g1.dat");
if (!File::Exists(pathG1Check)) if (!File::Exists(pathG1Check))
{ {
Console::Error::WriteLine("RCT2 path not valid."); Console::Error::WriteLine("RCT2 path not valid.");

View File

@@ -793,7 +793,7 @@ void config_release()
u8string config_get_default_path() u8string config_get_default_path()
{ {
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), "config.ini"); return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"config.ini");
} }
bool config_save_default() bool config_save_default()
@@ -892,7 +892,7 @@ bool config_find_or_browse_install_directory()
uiContext->ShowMessageBox(language_get_string(STR_NOT_THE_GOG_INSTALLER)); uiContext->ShowMessageBox(language_get_string(STR_NOT_THE_GOG_INSTALLER));
} }
installPath = Path::Combine(dest, "app"); installPath = Path::Combine(dest, u8"app");
} }
if (installPath.empty()) if (installPath.empty())
{ {
@@ -926,8 +926,8 @@ bool config_find_or_browse_install_directory()
std::string FindCsg1datAtLocation(u8string_view path) std::string FindCsg1datAtLocation(u8string_view path)
{ {
auto checkPath1 = Path::Combine(path, "Data", "CSG1.DAT"); auto checkPath1 = Path::Combine(path, u8"Data", u8"CSG1.DAT");
auto checkPath2 = Path::Combine(path, "Data", "CSG1.1"); auto checkPath2 = Path::Combine(path, u8"Data", u8"CSG1.1");
// Since Linux is case sensitive (and macOS sometimes too), make sure we handle case properly. // Since Linux is case sensitive (and macOS sometimes too), make sure we handle case properly.
std::string path1result = Path::ResolveCasing(checkPath1); std::string path1result = Path::ResolveCasing(checkPath1);
@@ -948,12 +948,12 @@ bool Csg1datPresentAtLocation(u8string_view path)
u8string FindCsg1idatAtLocation(u8string_view path) u8string FindCsg1idatAtLocation(u8string_view path)
{ {
auto result1 = Path::ResolveCasing(Path::Combine(path, "Data", "CSG1I.DAT")); auto result1 = Path::ResolveCasing(Path::Combine(path, u8"Data", u8"CSG1I.DAT"));
if (!result1.empty()) if (!result1.empty())
{ {
return result1; return result1;
} }
auto result2 = Path::ResolveCasing(Path::Combine(path, "RCTdeluxe_install", "Data", "CSG1I.DAT")); auto result2 = Path::ResolveCasing(Path::Combine(path, u8"RCTdeluxe_install", u8"Data", u8"CSG1I.DAT"));
return result2; return result2;
} }

View File

@@ -198,7 +198,7 @@ bool gfx_load_g1(const IPlatformEnvironment& env)
log_verbose("gfx_load_g1(...)"); log_verbose("gfx_load_g1(...)");
try try
{ {
auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), "g1.dat"); auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), u8"g1.dat");
auto fs = FileStream(path, FILE_MODE_OPEN); auto fs = FileStream(path, FILE_MODE_OPEN);
_g1.header = fs.ReadValue<rct_g1_header>(); _g1.header = fs.ReadValue<rct_g1_header>();
@@ -267,7 +267,7 @@ bool gfx_load_g2()
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
std::string path = Path::Combine(env->GetDirectoryPath(DIRBASE::OPENRCT2), "g2.dat"); std::string path = Path::Combine(env->GetDirectoryPath(DIRBASE::OPENRCT2), u8"g2.dat");
try try
{ {

View File

@@ -80,7 +80,7 @@ std::string LocalisationService::GetLanguagePath(uint32_t languageId) const
{ {
auto locale = std::string(LanguagesDescriptors[languageId].locale); 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 + ".txt"); auto languagePath = Path::Combine(languageDirectory, locale + u8".txt");
return languagePath; return languagePath;
} }

View File

@@ -3869,17 +3869,17 @@ void network_append_server_log(const utf8* text)
static u8string network_get_keys_directory() static u8string network_get_keys_directory()
{ {
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), "keys"); return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"keys");
} }
static u8string network_get_private_key_path(u8string_view playerName) static u8string network_get_private_key_path(u8string_view playerName)
{ {
return Path::Combine(network_get_keys_directory(), u8string(playerName) + ".privkey"); return Path::Combine(network_get_keys_directory(), u8string(playerName) + u8".privkey");
} }
static u8string network_get_public_key_path(u8string_view playerName, u8string_view hash) static u8string network_get_public_key_path(u8string_view playerName, u8string_view hash)
{ {
const auto filename = u8string(playerName) + "-" + u8string(hash) + ".pubkey"; const auto filename = u8string(playerName) + u8"-" + u8string(hash) + u8".pubkey";
return Path::Combine(network_get_keys_directory(), filename); return Path::Combine(network_get_keys_directory(), filename);
} }

View File

@@ -215,7 +215,7 @@ bool ServerList::WriteFavourites(const std::vector<ServerListEntry>& entries) co
log_verbose("server_list_write(%d, 0x%p)", entries.size(), entries.data()); log_verbose("server_list_write(%d, 0x%p)", entries.size(), entries.data());
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), "servers.cfg"); auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"servers.cfg");
try try
{ {

View File

@@ -325,7 +325,7 @@ std::string ImageTable::FindLegacyObject(const std::string& name)
if (!File::Exists(objectPath)) if (!File::Exists(objectPath))
{ {
// Search recursively for any file with the target name (case insensitive) // Search recursively for any file with the target name (case insensitive)
auto filter = Path::Combine(objectsPath, "*.dat;*.pob"); auto filter = Path::Combine(objectsPath, u8"*.dat;*.pob");
auto scanner = Path::ScanDirectory(filter, true); auto scanner = Path::ScanDirectory(filter, true);
while (scanner->Next()) while (scanner->Next())
{ {

View File

@@ -585,7 +585,7 @@ private:
// Find a unique file name // Find a unique file name
auto fileName = GetFileNameForNewObject(generation, name); auto fileName = GetFileNameForNewObject(generation, name);
auto extension = (generation == ObjectGeneration::DAT ? ".DAT" : ".parkobj"); auto extension = (generation == ObjectGeneration::DAT ? u8".DAT" : u8".parkobj");
auto fullPath = Path::Combine(userObjPath, fileName + extension); auto fullPath = Path::Combine(userObjPath, fileName + extension);
auto counter = 1U; auto counter = 1U;
while (File::Exists(fullPath)) while (File::Exists(fullPath))

View File

@@ -47,7 +47,7 @@ namespace Platform
if (path.empty()) if (path.empty())
{ {
auto home = GetFolderPath(SPECIAL_FOLDER::USER_HOME); auto home = GetFolderPath(SPECIAL_FOLDER::USER_HOME);
path = Path::Combine(home, ".config"); path = Path::Combine(home, u8".config");
} }
return path; return path;
} }
@@ -279,13 +279,13 @@ namespace Platform
const char* steamRoot = getenv("STEAMROOT"); const char* steamRoot = getenv("STEAMROOT");
if (steamRoot != nullptr) if (steamRoot != nullptr)
{ {
return Path::Combine(steamRoot, "ubuntu12_32/steamapps/content"); return Path::Combine(steamRoot, u8"ubuntu12_32/steamapps/content");
} }
const char* localSharePath = getenv("XDG_DATA_HOME"); const char* localSharePath = getenv("XDG_DATA_HOME");
if (localSharePath != nullptr) if (localSharePath != nullptr)
{ {
auto steamPath = Path::Combine(localSharePath, "Steam/ubuntu12_32/steamapps/content"); auto steamPath = Path::Combine(localSharePath, u8"Steam/ubuntu12_32/steamapps/content");
if (Path::DirectoryExists(steamPath)) if (Path::DirectoryExists(steamPath))
{ {
return steamPath; return steamPath;
@@ -298,13 +298,13 @@ namespace Platform
return {}; return {};
} }
auto steamPath = Path::Combine(homeDir, ".local/share/Steam/ubuntu12_32/steamapps/content"); auto steamPath = Path::Combine(homeDir, u8".local/share/Steam/ubuntu12_32/steamapps/content");
if (Path::DirectoryExists(steamPath)) if (Path::DirectoryExists(steamPath))
{ {
return steamPath; return steamPath;
} }
steamPath = Path::Combine(homeDir, ".steam/steam/ubuntu12_32/steamapps/content"); steamPath = Path::Combine(homeDir, u8".steam/steam/ubuntu12_32/steamapps/content");
if (Path::DirectoryExists(steamPath)) if (Path::DirectoryExists(steamPath))
{ {
return steamPath; return steamPath;

View File

@@ -171,7 +171,7 @@ namespace Platform
# endif # endif
if (!path.empty()) if (!path.empty())
{ {
path = Path::Combine(path, "DiscordGames\\RollerCoaster Tycoon 2 Triple Thrill Pack\\content\\Game"); path = Path::Combine(path, u8"DiscordGames\\RollerCoaster Tycoon 2 Triple Thrill Pack\\content\\Game");
} }
return path; return path;
} }
@@ -197,7 +197,7 @@ namespace Platform
else else
{ {
auto exeDirectory = GetCurrentExecutableDirectory(); auto exeDirectory = GetCurrentExecutableDirectory();
path = Path::Combine(exeDirectory, "data"); path = Path::Combine(exeDirectory, u8"data");
} }
return path; return path;
} }
@@ -862,7 +862,7 @@ namespace Platform
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
{ {
auto utf8SteamPath = String::ToUtf8(wSteamPath); auto utf8SteamPath = String::ToUtf8(wSteamPath);
outPath = Path::Combine(utf8SteamPath, "steamapps", "common"); outPath = Path::Combine(utf8SteamPath, u8"steamapps", u8"common");
} }
free(wSteamPath); free(wSteamPath);
RegCloseKey(hKey); RegCloseKey(hKey);
@@ -885,7 +885,7 @@ namespace Platform
return {}; return {};
# else # else
log_warning("Compatibility hack: falling back to C:\\Windows\\Fonts"); log_warning("Compatibility hack: falling back to C:\\Windows\\Fonts");
return Path::Combine("C:\\Windows\\Fonts\\", font.filename); return Path::Combine(u8"C:\\Windows\\Fonts\\", font.filename);
# endif # endif
} }

View File

@@ -90,7 +90,7 @@ namespace Platform
bool OriginalGameDataExists(std::string_view path) bool OriginalGameDataExists(std::string_view path)
{ {
std::string combinedPath = Path::ResolveCasing(Path::Combine(path, "Data", "g1.dat")); std::string combinedPath = Path::ResolveCasing(Path::Combine(path, u8"Data", u8"g1.dat"));
return File::Exists(combinedPath); return File::Exists(combinedPath);
} }

View File

@@ -137,7 +137,7 @@ void scenario_begin()
// Set the last saved game path // Set the last saved game path
auto env = GetContext()->GetPlatformEnvironment(); auto env = GetContext()->GetPlatformEnvironment();
auto savePath = env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE); auto savePath = env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE);
gScenarioSavePath = Path::Combine(savePath, park.Name + ".park"); gScenarioSavePath = Path::Combine(savePath, park.Name + u8".park");
gCurrentExpenditure = 0; gCurrentExpenditure = 0;
gCurrentProfit = 0; gCurrentProfit = 0;

View File

@@ -507,14 +507,14 @@ private:
{ {
auto mpdatPath = _env->GetFilePath(PATHID::MP_DAT); auto mpdatPath = _env->GetFilePath(PATHID::MP_DAT);
auto scenarioDirectory = _env->GetDirectoryPath(DIRBASE::USER, DIRID::SCENARIO); auto scenarioDirectory = _env->GetDirectoryPath(DIRBASE::USER, DIRID::SCENARIO);
auto expectedSc21Path = Path::Combine(scenarioDirectory, "sc21.sc4"); auto expectedSc21Path = Path::Combine(scenarioDirectory, u8"sc21.sc4");
auto sc21Path = Path::ResolveCasing(expectedSc21Path); auto sc21Path = Path::ResolveCasing(expectedSc21Path);
// If the user has a Steam installation. // If the user has a Steam installation.
if (!File::Exists(mpdatPath)) if (!File::Exists(mpdatPath))
{ {
mpdatPath = Path::ResolveCasing( mpdatPath = Path::ResolveCasing(
Path::Combine(_env->GetDirectoryPath(DIRBASE::RCT1), "RCTdeluxe_install", "Data", "mp.dat")); Path::Combine(_env->GetDirectoryPath(DIRBASE::RCT1), u8"RCTdeluxe_install", "Data", u8"mp.dat"));
} }
if (File::Exists(mpdatPath) && !File::Exists(sc21Path)) if (File::Exists(mpdatPath) && !File::Exists(sc21Path))

View File

@@ -456,7 +456,7 @@ void ScriptEngine::LoadPlugins()
auto base = _env.GetDirectoryPath(DIRBASE::USER, DIRID::PLUGIN); auto base = _env.GetDirectoryPath(DIRBASE::USER, DIRID::PLUGIN);
if (Path::DirectoryExists(base)) if (Path::DirectoryExists(base))
{ {
auto pattern = Path::Combine(base, "*.js"); auto pattern = Path::Combine(base, u8"*.js");
auto scanner = Path::ScanDirectory(pattern, true); auto scanner = Path::ScanDirectory(pattern, true);
while (scanner->Next()) while (scanner->Next())
{ {

View File

@@ -72,7 +72,7 @@ std::unique_ptr<TitleSequence> LoadTitleSequence(const std::string& path)
} }
else else
{ {
auto scriptPath = Path::Combine(path, "script.txt"); auto scriptPath = Path::Combine(path, u8"script.txt");
script = ReadScriptFile(scriptPath); script = ReadScriptFile(scriptPath);
if (script.empty()) if (script.empty())
{ {
@@ -157,7 +157,7 @@ bool TitleSequenceSave(const TitleSequence& seq)
} }
else else
{ {
auto scriptPath = Path::Combine(seq.Path, "script.txt"); auto scriptPath = Path::Combine(seq.Path, u8"script.txt");
File::WriteAllBytes(scriptPath, script.data(), script.size()); File::WriteAllBytes(scriptPath, script.data(), script.size());
} }
return true; return true;
@@ -291,7 +291,7 @@ static std::vector<std::string> GetSaves(const std::string& directory)
{ {
std::vector<std::string> saves; std::vector<std::string> saves;
auto pattern = Path::Combine(directory, "*.sc6;*.sv6;*.park;*.sv4;*.sc4"); auto pattern = Path::Combine(directory, u8"*.sc6;*.sv6;*.park;*.sv4;*.sc4");
auto scanner = Path::ScanDirectory(pattern, true); auto scanner = Path::ScanDirectory(pattern, true);
while (scanner->Next()) while (scanner->Next())
{ {

View File

@@ -209,7 +209,7 @@ namespace TitleSequenceManager
static void Scan(const std::string& directory) static void Scan(const std::string& directory)
{ {
auto pattern = Path::Combine(directory, "script.txt;*.parkseq"); auto pattern = Path::Combine(directory, u8"script.txt;*.parkseq");
auto fileScanner = Path::ScanDirectory(pattern, true); auto fileScanner = Path::ScanDirectory(pattern, true);
while (fileScanner->Next()) while (fileScanner->Next())
{ {
@@ -221,7 +221,7 @@ namespace TitleSequenceManager
{ {
TitleSequenceManagerItem item{}; TitleSequenceManagerItem item{};
if (String::Equals(Path::GetExtension(scanPath), ".txt", true)) if (String::Equals(Path::GetExtension(scanPath), u8".txt", true))
{ {
// If we are given a .txt file, set the path to the containing directory // If we are given a .txt file, set the path to the containing directory
item.Path = Path::GetDirectory(scanPath); item.Path = Path::GetDirectory(scanPath);

View File

@@ -13,27 +13,27 @@ class CommandLineTests : public testing::Test
public: public:
static std::string SpriteTestDataPath() static std::string SpriteTestDataPath()
{ {
return Path::Combine(TestData::GetBasePath(), "sprites"); return Path::Combine(TestData::GetBasePath(), u8"sprites");
} }
static std::string ManifestFilePath() static std::string ManifestFilePath()
{ {
return Path::Combine(SpriteTestDataPath(), "manifest.json"); return Path::Combine(SpriteTestDataPath(), u8"manifest.json");
} }
static std::string BadManifestFilePath() static std::string BadManifestFilePath()
{ {
return Path::Combine(SpriteTestDataPath(), "badManifest.json"); return Path::Combine(SpriteTestDataPath(), u8"badManifest.json");
} }
static std::string ExampleSpriteFilePath() static std::string ExampleSpriteFilePath()
{ {
return Path::Combine(SpriteTestDataPath(), "example.dat"); return Path::Combine(SpriteTestDataPath(), u8"example.dat");
} }
static std::string BuildOutputfilePath() static std::string BuildOutputfilePath()
{ {
return Path::Combine(SpriteTestDataPath(), "result.dat"); return Path::Combine(SpriteTestDataPath(), u8"result.dat");
} }
static bool CompareSpriteFiles(std::string original, std::string generated) static bool CompareSpriteFiles(std::string original, std::string generated)

View File

@@ -43,12 +43,12 @@ public:
std::string GetTestPrivateKeyPath() std::string GetTestPrivateKeyPath()
{ {
return Path::Combine(TestData::GetBasePath(), "keys", "Player.privkey"); return Path::Combine(TestData::GetBasePath(), u8"keys", u8"Player.privkey");
} }
std::string GetTestPublicKeyPath() std::string GetTestPublicKeyPath()
{ {
return Path::Combine(TestData::GetBasePath(), "keys", "Player-56f4afb74622a23bd2539ee701fe1b2c13d7e6ba.pubkey"); return Path::Combine(TestData::GetBasePath(), u8"keys", u8"Player-56f4afb74622a23bd2539ee701fe1b2c13d7e6ba.pubkey");
} }
}; };

View File

@@ -21,7 +21,7 @@ class ImageImporterTests : public testing::Test
public: public:
static std::string GetImagePath(const std::string& name) static std::string GetImagePath(const std::string& name)
{ {
return Path::Combine(TestData::GetBasePath(), "images", name.c_str()); return Path::Combine(TestData::GetBasePath(), u8"images", name.c_str());
} }
static uint32_t GetHash(void* buffer, size_t bufferLength) static uint32_t GetHash(void* buffer, size_t bufferLength)

View File

@@ -49,8 +49,8 @@ static std::vector<ReplayTestData> GetReplayFiles()
{ {
std::vector<ReplayTestData> res; std::vector<ReplayTestData> res;
std::string basePath = TestData::GetBasePath(); std::string basePath = TestData::GetBasePath();
std::string replayPath = Path::Combine(basePath, "replays"); std::string replayPath = Path::Combine(basePath, u8"replays");
std::string replayPathPattern = Path::Combine(replayPath, "*.parkrep"); std::string replayPathPattern = Path::Combine(replayPath, u8"*.parkrep");
std::vector<std::string> files; std::vector<std::string> files;
auto scanner = Path::ScanDirectory(replayPathPattern, true); auto scanner = Path::ScanDirectory(replayPathPattern, true);

View File

@@ -74,7 +74,7 @@ TEST_F(RideRatings, all)
CalculateRatingsForAllRides(); CalculateRatingsForAllRides();
// Load expected ratings // Load expected ratings
auto expectedDataPath = Path::Combine(TestData::GetBasePath(), "ratings", "bpb.sv6.txt"); auto expectedDataPath = Path::Combine(TestData::GetBasePath(), u8"ratings", u8"bpb.sv6.txt");
auto expectedRatings = File::ReadAllLines(expectedDataPath); auto expectedRatings = File::ReadAllLines(expectedDataPath);
// Check ride ratings // Check ride ratings

View File

@@ -20,7 +20,7 @@ namespace TestData
std::string GetParkPath(std::string name) std::string GetParkPath(std::string name)
{ {
std::string path = Path::Combine(GetBasePath(), "parks", name); std::string path = Path::Combine(GetBasePath(), u8"parks", name);
return path; return path;
} }
} // namespace TestData } // namespace TestData