Use std::string for LanguageMetadata::file

pull/621/head
Jonathan G Rennison 5 months ago
parent a573d065e1
commit 0460b820f3

@ -246,7 +246,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
BlitterFactory::GetCurrentBlitter() == nullptr ? "none" : BlitterFactory::GetCurrentBlitter()->GetName(),
BaseGraphics::GetUsedSet() == nullptr ? "none" : BaseGraphics::GetUsedSet()->name.c_str(),
BaseGraphics::GetUsedSet() == nullptr ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
_current_language == nullptr ? "none" : _current_language->file,
_current_language == nullptr ? "none" : _current_language->file.c_str(),
MusicDriver::GetInstance() == nullptr ? "none" : MusicDriver::GetInstance()->GetName(),
BaseMusic::GetUsedSet() == nullptr ? "none" : BaseMusic::GetUsedSet()->name.c_str(),
BaseMusic::GetUsedSet() == nullptr ? UINT32_MAX : BaseMusic::GetUsedSet()->version,

@ -403,7 +403,7 @@ void ReconsiderGameScriptLanguage()
if (_current_data == nullptr) return;
char temp[MAX_PATH];
strecpy(temp, _current_language->file, lastof(temp));
strecpy(temp, _current_language->file.c_str(), lastof(temp));
/* Remove the extension */
char *l = strrchr(temp, '.');

@ -91,7 +91,7 @@ static_assert(sizeof(LanguagePackHeader) % 4 == 0);
/** Metadata about a single language. */
struct LanguageMetadata : public LanguagePackHeader {
char file[MAX_PATH]; ///< Name of the file we read this data from.
std::string file; ///< Name of the file we read this data from.
};
/** Type for the list of language meta data. */

@ -2404,13 +2404,14 @@ static void GetLanguageList(const char *path)
if (extension == nullptr || strcmp(extension, ".lng") != 0) continue;
LanguageMetadata lmd;
seprintf(lmd.file, lastof(lmd.file), "%s%s", path, d_name.c_str());
lmd.file = path;
lmd.file += d_name;
/* Check whether the file is of the correct version */
if (!GetLanguageFileHeader(lmd.file, &lmd)) {
DEBUG(misc, 3, "%s is not a valid language file", lmd.file);
if (!GetLanguageFileHeader(lmd.file.c_str(), &lmd)) {
DEBUG(misc, 3, "%s is not a valid language file", lmd.file.c_str());
} else if (GetLanguage(lmd.newgrflangid) != nullptr) {
DEBUG(misc, 3, "%s's language ID is already known", lmd.file);
DEBUG(misc, 3, "%s's language ID is already known", lmd.file.c_str());
} else {
_languages.push_back(lmd);
}

Loading…
Cancel
Save