- Localization helper code for level names that haven't been exported to the string table.

This commit is contained in:
Christoph Oelckers 2019-04-08 22:07:09 +02:00
parent d308a1223b
commit c788da46fb

View file

@ -1930,20 +1930,32 @@ level_info_t *FMapInfoParser::ParseMapHeader(level_info_t &defaultinfo)
} }
else else
{ {
levelinfo->LevelName = sc.String; // Workaround to allow localizazion of IWADs which do not have a string label here (e.g. HACX.WAD)
// This checks for a string labelled with the MapName and if that is identical to what got parsed here
if (HexenHack) // the string table entry will be used.
auto c = GStrings.GetLanguageString(levelinfo->MapName, FStringTable::default_table);
if (c && !strcmp(c, sc.String))
{ {
// Try to localize Hexen's map names. levelinfo->flags |= LEVEL_LOOKUPLEVELNAME;
int fileno = Wads.GetLumpFile(sc.LumpNum); levelinfo->LevelName = levelinfo->MapName;
auto fn = Wads.GetWadName(fileno); }
if (fn && (!stricmp(fn, "HEXEN.WAD") || !stricmp(fn, "HEXDD.WAD"))) else
{
levelinfo->LevelName = sc.String;
if (HexenHack)
{ {
FStringf key("TXT_%.5s_%s", fn, levelinfo->MapName.GetChars()); // Try to localize Hexen's map names. This does not use the above feature to allow these names to be unique.
if (GStrings.exists(key)) int fileno = Wads.GetLumpFile(sc.LumpNum);
auto fn = Wads.GetWadName(fileno);
if (fn && (!stricmp(fn, "HEXEN.WAD") || !stricmp(fn, "HEXDD.WAD")))
{ {
levelinfo->flags |= LEVEL_LOOKUPLEVELNAME; FStringf key("TXT_%.5s_%s", fn, levelinfo->MapName.GetChars());
levelinfo->LevelName = key; if (GStrings.exists(key))
{
levelinfo->flags |= LEVEL_LOOKUPLEVELNAME;
levelinfo->LevelName = key;
}
} }
} }
} }