- fixed string prioritization when a mod replaces the default language for a given string.

In this case it must override all localized content from previously loaded WADs because that is no longer matching the original text.
This commit is contained in:
Christoph Oelckers 2019-04-22 00:21:01 +02:00
parent 5b6bae409e
commit 68c33a6e43

View file

@ -277,6 +277,8 @@ void FStringTable::LoadLanguage (int lumpnum, const TArray<uint8_t> &buffer)
bool errordone = false; bool errordone = false;
TArray<uint32_t> activeMaps; TArray<uint32_t> activeMaps;
FScanner sc; FScanner sc;
bool hasDefaultEntry = false;
sc.OpenMem("LANGUAGE", buffer); sc.OpenMem("LANGUAGE", buffer);
sc.SetCMode (true); sc.SetCMode (true);
while (sc.GetString ()) while (sc.GetString ())
@ -306,6 +308,7 @@ void FStringTable::LoadLanguage (int lumpnum, const TArray<uint8_t> &buffer)
{ {
activeMaps.Clear(); activeMaps.Clear();
activeMaps.Push(default_table); activeMaps.Push(default_table);
hasDefaultEntry = true;
} }
else else
{ {
@ -369,7 +372,7 @@ void FStringTable::LoadLanguage (int lumpnum, const TArray<uint8_t> &buffer)
} }
if (!skip) if (!skip)
{ {
if (activeMaps[0] == default_table) if (hasDefaultEntry)
{ {
DeleteForLabel(lumpnum, strName); DeleteForLabel(lumpnum, strName);
} }
@ -427,7 +430,7 @@ void FStringTable::DeleteForLabel(int lumpnum, FName label)
void FStringTable::InsertString(int lumpnum, int langid, FName label, const FString &string) void FStringTable::InsertString(int lumpnum, int langid, FName label, const FString &string)
{ {
const char *strlangid = (const char *)&langid; const char *strlangid = (const char *)&langid;
TableElement te = { lumpnum, { string, string, string, string } }; TableElement te = { Wads.GetLumpFile(lumpnum), { string, string, string, string } };
long index; long index;
while ((index = te.strings[0].IndexOf("@[")) >= 0) while ((index = te.strings[0].IndexOf("@[")) >= 0)
{ {