added GetLangR, which doesn't construct a CLang object when not found;
GetDef now uses GetLangR, so when users set their language to an invalid value, no such language is created.
This commit is contained in:
parent
2f3950b548
commit
b63ae4eed8
@ -332,7 +332,7 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
|
||||
|
||||
const char * CLangMngr::CLang::GetDef(const char *key)
|
||||
{
|
||||
static char nfind[1024] = "ML_NOTFOUND";
|
||||
static char nfind[1024] = "ML_NOTFOUND(KEY)";
|
||||
int ikey = m_LMan->GetKeyEntry(key);
|
||||
if (ikey == -1)
|
||||
{
|
||||
@ -941,12 +941,25 @@ CLangMngr::CLang * CLangMngr::GetLang(const char *name)
|
||||
return p;
|
||||
}
|
||||
|
||||
// Find a CLang by name, if not found, return NULL
|
||||
CLangMngr::CLang * CLangMngr::GetLangR(const char *name)
|
||||
{
|
||||
LangVecIter iter;
|
||||
for (iter=m_Languages.begin(); iter!=m_Languages.end(); ++iter)
|
||||
{
|
||||
if ( strcmp((*iter)->GetName(), name)==0 )
|
||||
return (*iter);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *CLangMngr::GetDef(const char *langName, const char *key)
|
||||
{
|
||||
CLang *lang = GetLang(langName);
|
||||
CLang *lang = GetLangR(langName);
|
||||
if (lang)
|
||||
return lang->GetDef(key);
|
||||
return "";
|
||||
return "ML_NOTFOUND(LANG)";
|
||||
}
|
||||
|
||||
bool CLangMngr::Save(const char *filename)
|
||||
|
@ -154,6 +154,8 @@ class CLangMngr
|
||||
// Get a lang object (construct if needed)
|
||||
CLang * GetLang(const char *name);
|
||||
|
||||
CLang * GetLangR(const char *name);
|
||||
|
||||
// Current global client-id for functions like client_print with first parameter 0
|
||||
int m_CurGlobId;
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user