本文整理汇总了C++中THash::AltFindOrInsert方法的典型用法代码示例。如果您正苦于以下问题:C++ THash::AltFindOrInsert方法的具体用法?C++ THash::AltFindOrInsert怎么用?C++ THash::AltFindOrInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THash
的用法示例。
在下文中一共展示了THash::AltFindOrInsert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: langName
const char *translate(AMX *amx, const char *lang, const char *key)
{
auto pLangName = lang;
int status;
if (!pLangName || !isalpha(pLangName[0]))
{
pLangName = amxmodx_language->string;
}
auto def = g_langMngr.GetDef(pLangName, key, status);
if (!amx_mldebug)
{
amx_mldebug = CVAR_GET_POINTER("amx_mldebug");
}
auto debug = (amx_mldebug && amx_mldebug->string && (amx_mldebug->string[0] != '\0'));
if (debug)
{
int debug_status;
auto validlang = true;
auto testlang = amx_mldebug->string;
if (!g_langMngr.LangExists(testlang))
{
AMXXLOG_Error("[AMXX] \"%s\" is an invalid debug language", testlang);
validlang = false;
}
g_langMngr.GetDef(testlang, key, debug_status);
if (validlang && debug_status == ERR_BADKEY)
{
AMXXLOG_Error("[AMXX] Language key \"%s\" not found for language \"%s\", check \"%s\"", key, testlang, GetFileName(amx));
}
}
if (!def)
{
if (debug && status == ERR_BADLANG)
{
ke::AString langName(pLangName);
auto &err = BadLang_Table.AltFindOrInsert(ke::Move(langName));
if (err.last + 120.0f < gpGlobals->time)
{
AMXXLOG_Error("[AMXX] Language \"%s\" not found", pLangName);
err.last = gpGlobals->time;
}
}
if (strcmp(pLangName, amxmodx_language->string) != 0)
{
def = g_langMngr.GetDef(amxmodx_language->string, key, status);
}
if (!def && (strcmp(pLangName, "en") != 0 && strcmp(amxmodx_language->string, "en") != 0))
{
def = g_langMngr.GetDef("en", key, status);
}
}
return def;
}