From c622e1b6c7a1870c794fb35c936268864e1fc2ca Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 18 Aug 2004 15:30:06 +0000 Subject: [PATCH] More error reporting --- amxmodx/CLang.cpp | 28 ++++++++++++++++++++++++++-- amxmodx/amxmodx.cpp | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/amxmodx/CLang.cpp b/amxmodx/CLang.cpp index 99ec58c3..9fe398a8 100755 --- a/amxmodx/CLang.cpp +++ b/amxmodx/CLang.cpp @@ -335,13 +335,16 @@ const char * CLangMngr::CLang::GetDef(const char *key) static char nfind[1024] = "ML_NOTFOUND"; int ikey = lman->GetKeyEntry(key); if (ikey == -1) + { + sprintf(nfind, "ML_NOTFOUND: %s", key); return nfind; + } for (unsigned int i = 0; iGetKey() == ikey) return m_LookUpTable[i]->GetDef(); } - return "ML_LNOTFOUND"; + return NULL; } @@ -659,6 +662,23 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len) int len; char *key = get_amxstring(amx, params[parm++], 1, len); const char *def = GetDef(cpLangName, key); + if (def == NULL) + { + if (*pLangName != LANG_SERVER) + { + def = GetDef(g_vault.get("server_language"), key); + } + if (strcmp(cpLangName, "en")!=0 && strcmp(g_vault.get("server_language"), "en")!=0) + { + def = GetDef("en", key); + } + if (!def) + { + static char buf[255]; + sprintf(buf, "ML_LNOTFOUND: %s", key); + def = buf; + } + } while (*def) { switch (*def) @@ -770,6 +790,7 @@ int CLangMngr::MergeDefinitionFile(const char *file) break; } } + AMXXLOG_Log("[AMXX] Failed to open dictionary file: %s", file); return 0; } MD5 md5; @@ -786,7 +807,7 @@ int CLangMngr::MergeDefinitionFile(const char *file) { if ( (*iter)->val.compare(md5buffer) == 0 ) { - return 2; + return -1; } else { (*iter)->val.assign(md5buffer); break; @@ -806,6 +827,7 @@ int CLangMngr::MergeDefinitionFile(const char *file) fp = fopen(file, "rt"); if (!fp) { + AMXXLOG_Log("[AMXX] Failed to re-open dictionary file: %s", file); return 0; } @@ -870,6 +892,8 @@ int CLangMngr::MergeDefinitionFile(const char *file) r = INSERT_FLOAT; } else if (c == 's') { r = INSERT_STRING; + } else if (c == 'n') { + r = '\n'; } else { r = 0; } diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 5a4751cf..26654ee5 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2618,9 +2618,9 @@ static cell get_lang(AMX *amx, cell *params) static cell register_dictionary(AMX *amx, cell *params) { int len; - g_langMngr.MergeDefinitionFile(build_pathname("%s/lang/%s", + int result = g_langMngr.MergeDefinitionFile(build_pathname("%s/lang/%s", get_localinfo("amxx_datadir", "addons/amxx/data"), get_amxstring(amx, params[1], 1, len))); - return 0; + return result; } // lang_exists(const name[]);