Moved client language detection to be earlier (on connect) (bug 3714, r=psychonic).
This commit is contained in:
		
							parent
							
								
									7f8c4eff39
								
							
						
					
					
						commit
						4b0373408d
					
				@ -412,6 +412,21 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
 | 
			
		||||
	int client = IndexOfEdict(pEntity);
 | 
			
		||||
	CPlayer *pPlayer = &m_Players[client];
 | 
			
		||||
 | 
			
		||||
	pPlayer->Initialize(pszName, pszAddress, pEntity);
 | 
			
		||||
	
 | 
			
		||||
	/* Get the client's language */
 | 
			
		||||
	if (m_QueryLang)
 | 
			
		||||
	{
 | 
			
		||||
		const char *name;
 | 
			
		||||
		if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
 | 
			
		||||
		{
 | 
			
		||||
			unsigned int langid;
 | 
			
		||||
			pPlayer->m_LangId = (translator->GetLanguageByName(name, &langid)) ? langid : translator->GetServerLanguage();
 | 
			
		||||
		} else {
 | 
			
		||||
			pPlayer->m_LangId = translator->GetServerLanguage();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	List<IClientListener *>::iterator iter;
 | 
			
		||||
	IClientListener *pListener = NULL;
 | 
			
		||||
	for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
 | 
			
		||||
@ -425,7 +440,6 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
 | 
			
		||||
 | 
			
		||||
	cell_t res = 1;
 | 
			
		||||
 | 
			
		||||
	pPlayer->Initialize(pszName, pszAddress, pEntity);
 | 
			
		||||
	m_clconnect->PushCell(client);
 | 
			
		||||
	m_clconnect->PushStringEx(reject, maxrejectlen, SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
 | 
			
		||||
	m_clconnect->PushCell(maxrejectlen);
 | 
			
		||||
@ -547,19 +561,6 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
 | 
			
		||||
		pPlayer->m_Info = playerinfo->GetPlayerInfo(pEntity);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Get the client's language */
 | 
			
		||||
	if (m_QueryLang)
 | 
			
		||||
	{
 | 
			
		||||
		const char *name;
 | 
			
		||||
		if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
 | 
			
		||||
		{
 | 
			
		||||
			unsigned int langid;
 | 
			
		||||
			pPlayer->m_LangId = (translator->GetLanguageByName(name, &langid)) ? langid : translator->GetServerLanguage();
 | 
			
		||||
		} else {
 | 
			
		||||
			pPlayer->m_LangId = translator->GetServerLanguage();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pPlayer->Connect();
 | 
			
		||||
	m_PlayerCount++;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -108,7 +108,7 @@ static cell_t sm_SetClientLanguage(IPluginContext *pContext, const cell_t *param
 | 
			
		||||
{
 | 
			
		||||
	IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
 | 
			
		||||
	
 | 
			
		||||
	if (!player || !player->IsInGame())
 | 
			
		||||
	if (!player || !player->IsConnected())
 | 
			
		||||
	{
 | 
			
		||||
		return pContext->ThrowNativeError("Invalid client index %d", params[1]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -63,7 +63,7 @@ native SetGlobalTransTarget(client);
 | 
			
		||||
 *
 | 
			
		||||
 * @param client	Client index.
 | 
			
		||||
 * @return			Language number client is using.
 | 
			
		||||
 * @error			Invalid client index or client not in game.
 | 
			
		||||
 * @error			Invalid client index or client not connected.
 | 
			
		||||
 */
 | 
			
		||||
native GetClientLanguage(client);
 | 
			
		||||
 | 
			
		||||
@ -100,7 +100,7 @@ native GetLanguageInfo(language, String:code[]="", codeLen=0, String:name[]="",
 | 
			
		||||
 * @param client	Client index.
 | 
			
		||||
 * @param language	Language number.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error			Invalid client index or client not in game.
 | 
			
		||||
 * @error			Invalid client index or client not connected.
 | 
			
		||||
 */
 | 
			
		||||
native SetClientLanguage(client, language);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user