- removed the automatic system language detection for Windows.

Default language is now always American English, just like on Linux and macOS.
This commit is contained in:
Christoph Oelckers 2019-03-16 00:07:18 +01:00
parent 04281d4a0b
commit dbd6c2eabf
9 changed files with 25 additions and 127 deletions

View file

@ -1243,10 +1243,12 @@ CCMD(secret)
FString levelname; FString levelname;
level_info_t *info = FindLevelInfo(mapname); level_info_t *info = FindLevelInfo(mapname);
const char *ln = !(info->flags & LEVEL_LOOKUPLEVELNAME)? info->LevelName.GetChars() : GStrings[info->LevelName.GetChars()]; const char *ln = !(info->flags & LEVEL_LOOKUPLEVELNAME)? info->LevelName.GetChars() : GStrings[info->LevelName.GetChars()];
levelname.Format("%s - %s\n", mapname, ln); levelname.Format("%s - %s", mapname, ln);
size_t llen = levelname.Len() - 1; Printf(TEXTCOLOR_YELLOW "%s\n", levelname.GetChars());
size_t llen = levelname.Len();
levelname = "";
for(size_t ii=0; ii<llen; ii++) levelname += '-'; for(size_t ii=0; ii<llen; ii++) levelname += '-';
Printf(TEXTCOLOR_YELLOW"%s\n", levelname.GetChars()); Printf(TEXTCOLOR_YELLOW "%s\n", levelname.GetChars());
foundsome = true; foundsome = true;
} }
} }

View file

@ -131,7 +131,6 @@ CUSTOM_CVAR(Float, teamdamage, 0.f, CVAR_SERVERINFO | CVAR_NOINITCALL)
CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
{ {
SetLanguageIDs();
GStrings.UpdateLanguage(); GStrings.UpdateLanguage();
for (auto Level : AllLevels()) for (auto Level : AllLevels())
{ {

View file

@ -45,6 +45,7 @@
#include "d_player.h" #include "d_player.h"
#include "xlsxread/xlsxio_read.h" #include "xlsxread/xlsxio_read.h"
EXTERN_CVAR(String, language)
//========================================================================== //==========================================================================
// //
@ -63,7 +64,6 @@ void FStringTable::LoadStrings ()
if (!LoadLanguageFromSpreadsheet(lump)) if (!LoadLanguageFromSpreadsheet(lump))
LoadLanguage (lump); LoadLanguage (lump);
} }
SetLanguageIDs();
UpdateLanguage(); UpdateLanguage();
allMacros.Clear(); allMacros.Clear();
} }
@ -378,6 +378,12 @@ void FStringTable::InsertString(int langid, FName label, const FString &string)
void FStringTable::UpdateLanguage() void FStringTable::UpdateLanguage()
{ {
size_t langlen = strlen(language);
int LanguageID = (langlen < 2 || langlen > 3) ?
MAKE_ID('e', 'n', 'u', '\0') :
MAKE_ID(language[0], language[1], language[2], '\0');
currentLanguageSet.Clear(); currentLanguageSet.Clear();
auto checkone = [&](uint32_t lang_id) auto checkone = [&](uint32_t lang_id)
@ -389,11 +395,8 @@ void FStringTable::UpdateLanguage()
checkone(dehacked_table); checkone(dehacked_table);
checkone(global_table); checkone(global_table);
for (int i = 0; i < 4; ++i) checkone(LanguageID);
{ checkone(LanguageID & MAKE_ID(0xff, 0xff, 0, 0));
checkone(LanguageIDs[i]);
checkone(LanguageIDs[i] & MAKE_ID(0xff, 0xff, 0, 0));
}
checkone(default_table); checkone(default_table);
} }

View file

@ -1300,17 +1300,20 @@ int FTextureManager::PalCheck(int tex)
// FTextureManager :: PalCheck // FTextureManager :: PalCheck
// //
//========================================================================== //==========================================================================
EXTERN_CVAR(String, language)
int FTextureManager::ResolveLocalizedTexture(int tex) int FTextureManager::ResolveLocalizedTexture(int tex)
{ {
for(int i = 0; i < 4; i++) size_t langlen = strlen(language);
{ int lang = (langlen < 2 || langlen > 3) ?
uint32_t lang = LanguageIDs[i]; MAKE_ID('e', 'n', 'u', '\0') :
uint64_t index = (uint64_t(lang) << 32) + tex; MAKE_ID(language[0], language[1], language[2], '\0');
if (auto pTex = LocalizedTextures.CheckKey(index)) return *pTex;
index = (uint64_t(lang & MAKE_ID(255, 255, 0, 0)) << 32) + tex; uint64_t index = (uint64_t(lang) << 32) + tex;
if (auto pTex = LocalizedTextures.CheckKey(index)) return *pTex; if (auto pTex = LocalizedTextures.CheckKey(index)) return *pTex;
} index = (uint64_t(lang & MAKE_ID(255, 255, 0, 0)) << 32) + tex;
if (auto pTex = LocalizedTextures.CheckKey(index)) return *pTex;
return tex; return tex;
} }

View file

@ -68,21 +68,6 @@ ticcmd_t* I_BaseTiccmd()
//
// SetLanguageIDs
//
void SetLanguageIDs()
{
size_t langlen = strlen(language);
uint32_t lang = (langlen < 2 || langlen > 3)
? MAKE_ID('e', 'n', 'u', '\0')
: MAKE_ID(language[0], language[1], language[2], '\0');
LanguageIDs[3] = LanguageIDs[2] = LanguageIDs[1] = LanguageIDs[0] = lang;
}
double PerfToSec, PerfToMillisec; double PerfToSec, PerfToMillisec;
static void CalculateCPUSpeed() static void CalculateCPUSpeed()

View file

@ -45,16 +45,6 @@ struct WadStuff;
#define SHARE_DIR "/usr/local/share/" #define SHARE_DIR "/usr/local/share/"
#endif #endif
// Index values into the LanguageIDs array
enum
{
LANGIDX_UserPreferred,
LANGIDX_UserDefault,
LANGIDX_SysPreferred,
LANGIDX_SysDefault
};
extern uint32_t LanguageIDs[4];
extern void SetLanguageIDs ();
// Called by DoomMain. // Called by DoomMain.
void I_Init (void); void I_Init (void);

View file

@ -92,20 +92,6 @@ void I_EndRead(void)
} }
//
// SetLanguageIDs
//
void SetLanguageIDs ()
{
size_t langlen = strlen(language);
uint32_t lang = (langlen < 2 || langlen > 3) ?
MAKE_ID('e','n','u','\0') :
MAKE_ID(language[0],language[1],language[2],'\0');
LanguageIDs[3] = LanguageIDs[2] = LanguageIDs[1] = LanguageIDs[0] = lang;
}
// //
// I_Init // I_Init
// //

View file

@ -273,65 +273,6 @@ void I_DetectOS(void)
info.dwBuildNumber, info.szCSDVersion); info.dwBuildNumber, info.szCSDVersion);
} }
//==========================================================================
//
// SubsetLanguageIDs
//
// Helper function for SetLanguageIDs.
//
//==========================================================================
static void SubsetLanguageIDs(LCID id, LCTYPE type, int idx)
{
char buf[8];
LCID langid;
char *idp;
if (!GetLocaleInfoA(id, type, buf, 8))
return;
langid = MAKELCID(strtoul(buf, NULL, 16), SORT_DEFAULT);
if (!GetLocaleInfoA(langid, LOCALE_SABBREVLANGNAME, buf, 8))
return;
idp = (char *)(&LanguageIDs[idx]);
memset (idp, 0, 4);
idp[0] = tolower(buf[0]);
idp[1] = tolower(buf[1]);
idp[2] = tolower(buf[2]);
idp[3] = 0;
}
//==========================================================================
//
// SetLanguageIDs
//
//==========================================================================
void SetLanguageIDs()
{
size_t langlen = strlen(language);
if (langlen < 2 || langlen > 3)
{
memset(LanguageIDs, 0, sizeof(LanguageIDs));
SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, 0);
SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 1);
SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, 2);
SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 3);
}
else
{
uint32_t lang = 0;
((uint8_t *)&lang)[0] = (language)[0];
((uint8_t *)&lang)[1] = (language)[1];
((uint8_t *)&lang)[2] = (language)[2];
LanguageIDs[0] = lang;
LanguageIDs[1] = lang;
LanguageIDs[2] = lang;
LanguageIDs[3] = lang;
}
}
//========================================================================== //==========================================================================
// //
// CalculateCPUSpeed // CalculateCPUSpeed

View file

@ -34,17 +34,6 @@
struct ticcmd_t; struct ticcmd_t;
struct WadStuff; struct WadStuff;
// Index values into the LanguageIDs array
enum
{
LANGIDX_UserPreferred,
LANGIDX_UserDefault,
LANGIDX_SysPreferred,
LANGIDX_SysDefault
};
extern uint32_t LanguageIDs[4];
extern void SetLanguageIDs ();
// [RH] Detects the OS the game is running under. // [RH] Detects the OS the game is running under.
void I_DetectOS (void); void I_DetectOS (void);