Permalink
Browse files

- rewrote the language table so that it doesn't have to reload everyt…

…hing on a language change.

It now reads everything into a two-dimensional TMap and creates a list of mappings that apply to the current setting.
The constant need for reloading was the main blocker in redesigning how Dehacked strings get inserted. Currently they override everything, but IWAD-based Dehacked text shouldn't block PWAD overrides from PWADs' LANGUAGE lumps and instead be treated as coming from an [en default] block.

This also renames the main block from [enu default] to [en default], because it should be treated as the English default for all English locales and not just make it fall through to the base default as it did before.
  • Loading branch information...
coelckers committed Feb 6, 2019
1 parent 7fa3081 commit 495298079bf32312a5acace2f277057ed643524a
Showing with 90 additions and 273 deletions.
  1. +1 −1 src/d_main.cpp
  2. +2 −2 src/doomstat.cpp
  3. +10 −17 src/gamedata/d_dehacked.cpp
  4. +55 −238 src/gamedata/stringtable.cpp
  5. +21 −14 src/gamedata/stringtable.h
  6. +1 −1 wadsrc/static/language.enu
@@ -2427,7 +2427,7 @@ void D_DoomMain (void)
}

// [RH] Initialize localizable strings.
GStrings.LoadStrings (false);
GStrings.LoadStrings ();

V_InitFontColors ();

@@ -56,10 +56,10 @@ CUSTOM_CVAR (Float, teamdamage, 0.f, CVAR_SERVERINFO)
}
}

CUSTOM_CVAR (String, language, "auto", CVAR_ARCHIVE)
CUSTOM_CVAR (String, language, "auto", CVAR_ARCHIVE|CVAR_NOINITCALL)
{
SetLanguageIDs ();
GStrings.LoadStrings (false);
GStrings.UpdateLanguage();
for (auto Level : AllLevels())
{
// does this even make sense on secondary levels...?
@@ -285,7 +285,7 @@ static bool including, includenotext;

static const char *unknown_str = "Unknown key %s encountered in %s %d.\n";

static FStringTable *EnglishStrings;
static StringMap EnglishStrings, DehStrings;

// This is an offset to be used for computing the text stuff.
// Straight from the DeHackEd source which was
@@ -2169,7 +2169,7 @@ static int PatchMusic (int dummy)

keystring << "MUSIC_" << Line1;

GStrings.SetString (keystring, newname);
DehStrings.Insert(keystring, newname);
DPrintf (DMSG_SPAMMY, "Music %s set to:\n%s\n", keystring.GetChars(), newname);
}

@@ -2280,11 +2280,11 @@ static int PatchText (int oldSize)
const char *str;
do
{
str = EnglishStrings->MatchString(oldStr);
str = EnglishStrings.MatchString(oldStr);
if (str != NULL)
{
GStrings.SetString(str, newStr);
EnglishStrings->SetString(str, "~~"); // set to something invalid so that it won't get found again by the next iteration or by another replacement later
DehStrings.Insert(str, newStr);
EnglishStrings.Remove(str); // remove entry so that it won't get found again by the next iteration or by another replacement later
good = true;
}
}
@@ -2337,7 +2337,7 @@ static int PatchStrings (int dummy)
// Account for a discrepancy between Boom's and ZDoom's name for the red skull key pickup message
const char *ll = Line1;
if (!stricmp(ll, "GOTREDSKULL")) ll = "GOTREDSKUL";
GStrings.SetString (ll, holdstring);
DehStrings.Insert(ll, holdstring);
DPrintf (DMSG_SPAMMY, "%s set to:\n%s\n", Line1, holdstring.GetChars());
}

@@ -2670,11 +2670,6 @@ static void UnloadDehSupp ()
StyleNames.Reset();
AmmoNames.Reset();
UnchangedSpriteNames.Reset();
if (EnglishStrings != NULL)
{
delete EnglishStrings;
EnglishStrings = NULL;
}
}
}

@@ -2704,12 +2699,8 @@ static bool LoadDehSupp ()
return true;
}

if (EnglishStrings == NULL)
{
EnglishStrings = new FStringTable;
EnglishStrings->LoadStrings (true);
}

if (EnglishStrings.CountUsed() == 0)
EnglishStrings = GStrings.GetDefaultStrings();

UnchangedSpriteNames.Resize(sprites.Size());
for (unsigned i = 0; i < UnchangedSpriteNames.Size(); ++i)
@@ -3079,6 +3070,8 @@ void FinishDehPatch ()
StateMap.ShrinkToFit();
TouchedActors.Clear();
TouchedActors.ShrinkToFit();
EnglishStrings.Clear();
GStrings.SetDehackedStrings(std::move(DehStrings));

// Now it gets nasty: We have to fiddle around with the weapons' ammo use info to make Doom's original
// ammo consumption work as intended.
Oops, something went wrong.

0 comments on commit 4952980

Please sign in to comment.