1.1 --- a/core/sm_stringutil.cpp Thu Jun 07 06:08:16 2007 +0000
1.2 +++ b/core/sm_stringutil.cpp Thu Jun 07 06:16:38 2007 +0000
1.3 @@ -89,7 +89,7 @@
1.4
1.5 if (!TryTranslation(pl, key, langid, langcount, &pTrans))
1.6 {
1.7 - if (target != LANG_SERVER)
1.8 + if (target != LANG_SERVER && langid != g_Translator.GetServerLanguage())
1.9 {
1.10 target = LANG_SERVER;
1.11 goto try_serverlang;
1.12 @@ -99,20 +99,32 @@
1.13 pCtx->ThrowNativeErrorEx(SP_ERROR_PARAM, "Language phrase \"%s\" not found", key);
1.14 goto error_out;
1.15 }
1.16 + } else {
1.17 + pCtx->ThrowNativeErrorEx(SP_ERROR_PARAM, "Language prhase \"%s\" not found", key);
1.18 + goto error_out;
1.19 }
1.20 }
1.21
1.22 max_params = pTrans.fmt_count;
1.23 -
1.24 - for (size_t i=0; i<max_params; i++)
1.25 +
1.26 + if (max_params)
1.27 {
1.28 - pCtx->LocalToPhysAddr(params[*arg], reinterpret_cast<cell_t **>(&new_params[i]));
1.29 - (*arg)++;
1.30 - if ((*arg) + i > (size_t)params[0])
1.31 + /* Check if we're going to over the limit */
1.32 + if ((*arg) + (max_params - 1) > (size_t)params[0])
1.33 {
1.34 - pCtx->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, "Translation string formatted incorrectly - parameter %d (total %d)", (*arg) + i, params[0]);
1.35 + pCtx->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX,
1.36 + "Translation string formatted incorrectly - missing at least %d parameters",
1.37 + ((*arg + (max_params - 1)) - params[0])
1.38 + );
1.39 goto error_out;
1.40 }
1.41 +
1.42 + /* Translate the parameters to raw pointers */
1.43 + for (size_t i=0; i<max_params; i++)
1.44 + {
1.45 + pCtx->LocalToPhysAddr(params[*arg], reinterpret_cast<cell_t **>(&new_params[i]));
1.46 + (*arg)++;
1.47 + }
1.48 }
1.49
1.50 return g_Translator.Translate(buffer, maxlen, new_params, &pTrans);