mirror of https://github.com/OpenTTD/OpenTTD
std::filesystem::path does not expect UTF-8 strings, so they must be converted to native format first (and back to utf-8 after.)pull/12771/head
parent
fce9361bf2
commit
b4b2fad8e0
|
@ -489,7 +489,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] c
|
|||
|
||||
_tar_list[this->subdir][filename] = std::string{};
|
||||
|
||||
std::string filename_base = std::filesystem::path(filename).filename().string();
|
||||
std::string filename_base = FS2OTTD(std::filesystem::path(OTTD2FS(filename)).filename());
|
||||
SimplifyFileName(filename_base);
|
||||
|
||||
TarHeader th;
|
||||
|
|
|
@ -386,7 +386,7 @@ void ReconsiderGameScriptLanguage()
|
|||
{
|
||||
if (_current_data == nullptr) return;
|
||||
|
||||
std::string language = _current_language->file.stem().string();
|
||||
std::string language = FS2OTTD(_current_language->file.stem());
|
||||
for (auto &p : _current_data->compiled_strings) {
|
||||
if (p.language == language) {
|
||||
_current_data->cur_language = &p;
|
||||
|
|
|
@ -578,7 +578,7 @@ int openttd_main(std::span<char * const> arguments)
|
|||
if (mgo.opt != nullptr) {
|
||||
_file_to_saveload.name = mgo.opt;
|
||||
|
||||
std::string extension = std::filesystem::path(_file_to_saveload.name).extension().string();
|
||||
std::string extension = FS2OTTD(std::filesystem::path(OTTD2FS(_file_to_saveload.name)).extension());
|
||||
auto [ft, _] = FiosGetSavegameListCallback(SLO_LOAD, _file_to_saveload.name, extension);
|
||||
if (ft == FIOS_TYPE_INVALID) {
|
||||
std::tie(ft, _) = FiosGetScenarioListCallback(SLO_LOAD, _file_to_saveload.name, extension);
|
||||
|
@ -612,7 +612,7 @@ int openttd_main(std::span<char * const> arguments)
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::string extension = std::filesystem::path(mgo.opt).extension().string();
|
||||
std::string extension = FS2OTTD(std::filesystem::path(OTTD2FS(mgo.opt)).extension());
|
||||
auto [_, title] = FiosGetSavegameListCallback(SLO_LOAD, mgo.opt, extension);
|
||||
|
||||
_load_check_data.Clear();
|
||||
|
|
|
@ -245,7 +245,7 @@ static bool _ValidateSignatureFile(const std::string &filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string dirname = std::filesystem::path(filename).parent_path().string();
|
||||
std::string dirname = FS2OTTD(std::filesystem::path(OTTD2FS(filename)).parent_path());
|
||||
|
||||
for (auto &signature : signatures["files"]) {
|
||||
const std::string sig_filename = dirname + PATHSEPCHAR + signature["filename"].get<std::string>();
|
||||
|
|
|
@ -1904,7 +1904,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
|
|||
{
|
||||
/* Current language pack */
|
||||
size_t len = 0;
|
||||
std::unique_ptr<LanguagePack, LanguagePackDeleter> lang_pack(reinterpret_cast<LanguagePack *>(ReadFileToMem(lang->file.string(), len, 1U << 20).release()));
|
||||
std::unique_ptr<LanguagePack, LanguagePackDeleter> lang_pack(reinterpret_cast<LanguagePack *>(ReadFileToMem(FS2OTTD(lang->file), len, 1U << 20).release()));
|
||||
if (!lang_pack) return false;
|
||||
|
||||
/* End of read data (+ terminating zero added in ReadFileToMem()) */
|
||||
|
@ -1953,7 +1953,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
|
|||
|
||||
_current_language = lang;
|
||||
_current_text_dir = (TextDirection)_current_language->text_dir;
|
||||
_config_language_file = _current_language->file.filename().string();
|
||||
_config_language_file = FS2OTTD(_current_language->file.filename());
|
||||
SetCurrentGrfLangID(_current_language->newgrflangid);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -2079,13 +2079,13 @@ static void FillLanguageList(const std::string &path)
|
|||
if (dir_entry.path().extension() != ".lng") continue;
|
||||
|
||||
LanguageMetadata lmd;
|
||||
lmd.file = FS2OTTD(dir_entry.path());
|
||||
lmd.file = dir_entry.path();
|
||||
|
||||
/* Check whether the file is of the correct version */
|
||||
if (!GetLanguageFileHeader(lmd.file.string(), &lmd)) {
|
||||
Debug(misc, 3, "{} is not a valid language file", lmd.file);
|
||||
if (!GetLanguageFileHeader(FS2OTTD(lmd.file), &lmd)) {
|
||||
Debug(misc, 3, "{} is not a valid language file", FS2OTTD(lmd.file));
|
||||
} else if (GetLanguage(lmd.newgrflangid) != nullptr) {
|
||||
Debug(misc, 3, "{}'s language ID is already known", lmd.file);
|
||||
Debug(misc, 3, "{}'s language ID is already known", FS2OTTD(lmd.file));
|
||||
} else {
|
||||
_languages.push_back(lmd);
|
||||
}
|
||||
|
@ -2119,7 +2119,7 @@ void InitializeLanguagePacks()
|
|||
/* We are trying to find a default language. The priority is by
|
||||
* configuration file, local environment and last, if nothing found,
|
||||
* English. */
|
||||
if (_config_language_file == lng.file.filename()) {
|
||||
if (_config_language_file == FS2OTTD(lng.file.filename())) {
|
||||
chosen_language = &lng;
|
||||
break;
|
||||
}
|
||||
|
@ -2139,7 +2139,7 @@ void InitializeLanguagePacks()
|
|||
chosen_language = (language_fallback != nullptr) ? language_fallback : en_GB_fallback;
|
||||
}
|
||||
|
||||
if (!ReadLanguagePack(chosen_language)) UserError("Can't read language pack '{}'", chosen_language->file);
|
||||
if (!ReadLanguagePack(chosen_language)) UserError("Can't read language pack '{}'", FS2OTTD(chosen_language->file));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -258,7 +258,7 @@ void SurveyConfiguration(nlohmann::json &survey)
|
|||
{
|
||||
survey["network"] = _networking ? (_network_server ? "server" : "client") : "no";
|
||||
if (_current_language != nullptr) {
|
||||
survey["language"]["filename"] = _current_language->file.filename().string();
|
||||
survey["language"]["filename"] = FS2OTTD(_current_language->file.filename());
|
||||
survey["language"]["name"] = _current_language->name;
|
||||
survey["language"]["isocode"] = _current_language->isocode;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue