From 060a0a565ce3fc9676e4db70cd4c3270dc6215e3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 13 Aug 2004 10:01:41 +0000 Subject: [PATCH] Fixed default language errors --- amxmodx/CLang.cpp | 9 ++++++--- amxmodx/meta_api.cpp | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/amxmodx/CLang.cpp b/amxmodx/CLang.cpp index bf45427d..0afca963 100755 --- a/amxmodx/CLang.cpp +++ b/amxmodx/CLang.cpp @@ -528,11 +528,13 @@ const char *CLangMngr::Format(const char *src, ...) if ((int)langName == -1) cpLangName = g_vault.get("server_language"); else if ((int)langName >= 1 && (int)langName <= 32) - cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I((int)langName)->pEdict, "_language"); + cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I((int)langName)->pEdict, "lang"); else { cpLangName = langName; } + if (!cpLangName || strlen(cpLangName) < 1) + cpLangName = "en"; char *key = va_arg(argptr, char*); const char *def = GetDef(cpLangName, key); while (*def) @@ -558,7 +560,6 @@ const char *CLangMngr::Format(const char *src, ...) sprintf(outptr, "%f", tmpArg); outptr += strlen(outptr); break; - break; } case INSERT_NEWLINE: *outptr++ = '\n'; @@ -648,12 +649,14 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len) if (*pLangName == -1) cpLangName = g_vault.get("server_language"); else if (*pLangName >= 1 && *pLangName <= 32) - cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(*pLangName)->pEdict, "_language"); + cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(*pLangName)->pEdict, "lang"); else { int len = 0; cpLangName = get_amxstring(amx, langName, 2, len); } + if (!cpLangName || strlen(cpLangName) < 1) + cpLangName = "en"; int len; char *key = get_amxstring(amx, params[parm++], 1, len); const char *def = GetDef(cpLangName, key); diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 2d3a3d7a..feeb6bd4 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -252,7 +252,11 @@ int C_Spawn( edict_t *pent ) { // ###### Load Vault g_vault.setSource( build_pathname("%s", get_localinfo("amxx_vault", "addons/amxx/configs/vault.ini")) ); g_vault.loadVault( ); - + if (strlen(g_vault.get("server_language")) < 1) + { + g_vault.put("server_language", "en"); + g_vault.saveVault(); + } // ###### Init time and freeze tasks g_game_timeleft = g_bmod_dod ? 1 : 0;