Use std::string for LanguageMetadata::file
This commit is contained in:
@@ -246,7 +246,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
|
|||||||
BlitterFactory::GetCurrentBlitter() == nullptr ? "none" : BlitterFactory::GetCurrentBlitter()->GetName(),
|
BlitterFactory::GetCurrentBlitter() == nullptr ? "none" : BlitterFactory::GetCurrentBlitter()->GetName(),
|
||||||
BaseGraphics::GetUsedSet() == nullptr ? "none" : BaseGraphics::GetUsedSet()->name.c_str(),
|
BaseGraphics::GetUsedSet() == nullptr ? "none" : BaseGraphics::GetUsedSet()->name.c_str(),
|
||||||
BaseGraphics::GetUsedSet() == nullptr ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
|
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(),
|
MusicDriver::GetInstance() == nullptr ? "none" : MusicDriver::GetInstance()->GetName(),
|
||||||
BaseMusic::GetUsedSet() == nullptr ? "none" : BaseMusic::GetUsedSet()->name.c_str(),
|
BaseMusic::GetUsedSet() == nullptr ? "none" : BaseMusic::GetUsedSet()->name.c_str(),
|
||||||
BaseMusic::GetUsedSet() == nullptr ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
|
BaseMusic::GetUsedSet() == nullptr ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
|
||||||
|
@@ -403,7 +403,7 @@ void ReconsiderGameScriptLanguage()
|
|||||||
if (_current_data == nullptr) return;
|
if (_current_data == nullptr) return;
|
||||||
|
|
||||||
char temp[MAX_PATH];
|
char temp[MAX_PATH];
|
||||||
strecpy(temp, _current_language->file, lastof(temp));
|
strecpy(temp, _current_language->file.c_str(), lastof(temp));
|
||||||
|
|
||||||
/* Remove the extension */
|
/* Remove the extension */
|
||||||
char *l = strrchr(temp, '.');
|
char *l = strrchr(temp, '.');
|
||||||
|
@@ -91,7 +91,7 @@ static_assert(sizeof(LanguagePackHeader) % 4 == 0);
|
|||||||
|
|
||||||
/** Metadata about a single language. */
|
/** Metadata about a single language. */
|
||||||
struct LanguageMetadata : public LanguagePackHeader {
|
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. */
|
/** 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;
|
if (extension == nullptr || strcmp(extension, ".lng") != 0) continue;
|
||||||
|
|
||||||
LanguageMetadata lmd;
|
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 */
|
/* Check whether the file is of the correct version */
|
||||||
if (!GetLanguageFileHeader(lmd.file, &lmd)) {
|
if (!GetLanguageFileHeader(lmd.file.c_str(), &lmd)) {
|
||||||
DEBUG(misc, 3, "%s is not a valid language file", lmd.file);
|
DEBUG(misc, 3, "%s is not a valid language file", lmd.file.c_str());
|
||||||
} else if (GetLanguage(lmd.newgrflangid) != nullptr) {
|
} 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 {
|
} else {
|
||||||
_languages.push_back(lmd);
|
_languages.push_back(lmd);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user