Moved client language detection to be earlier (on connect) (bug 3714, r=psychonic).
Moved client language detection to be earlier (on connect) (
bug 3714, r=psychonic).
1.1 --- a/core/PlayerManager.cpp Fri Oct 14 15:21:12 2011 -0400
1.2 +++ b/core/PlayerManager.cpp Sat Oct 15 12:07:55 2011 -0400
1.3 @@ -412,6 +412,21 @@
1.4 int client = IndexOfEdict(pEntity);
1.5 CPlayer *pPlayer = &m_Players[client];
1.6
1.7 + pPlayer->Initialize(pszName, pszAddress, pEntity);
1.8 +
1.9 + /* Get the client's language */
1.10 + if (m_QueryLang)
1.11 + {
1.12 + const char *name;
1.13 + if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
1.14 + {
1.15 + unsigned int langid;
1.16 + pPlayer->m_LangId = (translator->GetLanguageByName(name, &langid)) ? langid : translator->GetServerLanguage();
1.17 + } else {
1.18 + pPlayer->m_LangId = translator->GetServerLanguage();
1.19 + }
1.20 + }
1.21 +
1.22 List<IClientListener *>::iterator iter;
1.23 IClientListener *pListener = NULL;
1.24 for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
1.25 @@ -425,7 +440,6 @@
1.26
1.27 cell_t res = 1;
1.28
1.29 - pPlayer->Initialize(pszName, pszAddress, pEntity);
1.30 m_clconnect->PushCell(client);
1.31 m_clconnect->PushStringEx(reject, maxrejectlen, SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
1.32 m_clconnect->PushCell(maxrejectlen);
1.33 @@ -547,19 +561,6 @@
1.34 pPlayer->m_Info = playerinfo->GetPlayerInfo(pEntity);
1.35 }
1.36
1.37 - /* Get the client's language */
1.38 - if (m_QueryLang)
1.39 - {
1.40 - const char *name;
1.41 - if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
1.42 - {
1.43 - unsigned int langid;
1.44 - pPlayer->m_LangId = (translator->GetLanguageByName(name, &langid)) ? langid : translator->GetServerLanguage();
1.45 - } else {
1.46 - pPlayer->m_LangId = translator->GetServerLanguage();
1.47 - }
1.48 - }
1.49 -
1.50 pPlayer->Connect();
1.51 m_PlayerCount++;
1.52
2.1 --- a/core/logic/smn_lang.cpp Fri Oct 14 15:21:12 2011 -0400
2.2 +++ b/core/logic/smn_lang.cpp Sat Oct 15 12:07:55 2011 -0400
2.3 @@ -108,7 +108,7 @@
2.4 {
2.5 IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
2.6
2.7 - if (!player || !player->IsInGame())
2.8 + if (!player || !player->IsConnected())
2.9 {
2.10 return pContext->ThrowNativeError("Invalid client index %d", params[1]);
2.11 }
3.1 --- a/plugins/include/lang.inc Fri Oct 14 15:21:12 2011 -0400
3.2 +++ b/plugins/include/lang.inc Sat Oct 15 12:07:55 2011 -0400
3.3 @@ -63,7 +63,7 @@
3.4 *
3.5 * @param client Client index.
3.6 * @return Language number client is using.
3.7 - * @error Invalid client index or client not in game.
3.8 + * @error Invalid client index or client not connected.
3.9 */
3.10 native GetClientLanguage(client);
3.11
3.12 @@ -100,7 +100,7 @@
3.13 * @param client Client index.
3.14 * @param language Language number.
3.15 * @noreturn
3.16 - * @error Invalid client index or client not in game.
3.17 + * @error Invalid client index or client not connected.
3.18 */
3.19 native SetClientLanguage(client, language);
3.20