From a2dff5f7d0344ecd7a7c61bfdb8b80364fc549af Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 7 Jun 2007 06:16:38 +0000 Subject: [PATCH] - fixed a bug where translation parameters were simply not read right - fixed some oddness about how SourceMod determines that a phrase does not exist --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40915 --- core/sm_stringutil.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/core/sm_stringutil.cpp b/core/sm_stringutil.cpp index dd2283cc..c225525a 100644 --- a/core/sm_stringutil.cpp +++ b/core/sm_stringutil.cpp @@ -89,7 +89,7 @@ try_serverlang: if (!TryTranslation(pl, key, langid, langcount, &pTrans)) { - if (target != LANG_SERVER) + if (target != LANG_SERVER && langid != g_Translator.GetServerLanguage()) { target = LANG_SERVER; goto try_serverlang; @@ -99,20 +99,32 @@ try_serverlang: pCtx->ThrowNativeErrorEx(SP_ERROR_PARAM, "Language phrase \"%s\" not found", key); goto error_out; } + } else { + pCtx->ThrowNativeErrorEx(SP_ERROR_PARAM, "Language prhase \"%s\" not found", key); + goto error_out; } } max_params = pTrans.fmt_count; - - for (size_t i=0; iLocalToPhysAddr(params[*arg], reinterpret_cast(&new_params[i])); - (*arg)++; - if ((*arg) + i > (size_t)params[0]) + /* Check if we're going to over the limit */ + if ((*arg) + (max_params - 1) > (size_t)params[0]) { - pCtx->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, "Translation string formatted incorrectly - parameter %d (total %d)", (*arg) + i, params[0]); + pCtx->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, + "Translation string formatted incorrectly - missing at least %d parameters", + ((*arg + (max_params - 1)) - params[0]) + ); goto error_out; } + + /* Translate the parameters to raw pointers */ + for (size_t i=0; iLocalToPhysAddr(params[*arg], reinterpret_cast(&new_params[i])); + (*arg)++; + } } return g_Translator.Translate(buffer, maxlen, new_params, &pTrans);