Merge pull request #124 from alliedmodders/csgo-cl-language
Fix automatic language detection on CS:GO (bug 6163) (r=asherkin).
This commit is contained in:
commit
25f8570279
@ -648,8 +648,11 @@ QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char
|
|||||||
return InvalidQueryCvarCookie;
|
return InvalidQueryCvarCookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConVarQuery query = {cookie, pCallback, (cell_t)hndl, IndexOfEdict(pPlayer)};
|
if (pCallback != NULL)
|
||||||
m_ConVarQueries.push_back(query);
|
{
|
||||||
|
ConVarQuery query = { cookie, pCallback, (cell_t) hndl, IndexOfEdict(pPlayer) };
|
||||||
|
m_ConVarQueries.push_back(query);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return cookie;
|
return cookie;
|
||||||
@ -753,6 +756,13 @@ void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, CEntityIn
|
|||||||
void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
|
void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
|
||||||
#endif // SE_DOTA
|
#endif // SE_DOTA
|
||||||
{
|
{
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
if (g_Players.HandleConVarQuery(cookie, pPlayer, result, cvarName, cvarValue))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
IPluginFunction *pCallback = NULL;
|
IPluginFunction *pCallback = NULL;
|
||||||
cell_t value = 0;
|
cell_t value = 0;
|
||||||
List<ConVarQuery>::iterator iter;
|
List<ConVarQuery>::iterator iter;
|
||||||
|
@ -502,6 +502,9 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
|
|||||||
/* Get the client's language */
|
/* Get the client's language */
|
||||||
if (m_QueryLang)
|
if (m_QueryLang)
|
||||||
{
|
{
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
pPlayer->m_LangId = translator->GetServerLanguage();
|
||||||
|
#else
|
||||||
const char *name;
|
const char *name;
|
||||||
if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
|
if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
|
||||||
{
|
{
|
||||||
@ -510,6 +513,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
|
|||||||
} else {
|
} else {
|
||||||
pPlayer->m_LangId = translator->GetServerLanguage();
|
pPlayer->m_LangId = translator->GetServerLanguage();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IClientListener *>::iterator iter;
|
List<IClientListener *>::iterator iter;
|
||||||
@ -727,6 +731,13 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
|||||||
}
|
}
|
||||||
pPlayer->Authorize_Post();
|
pPlayer->Authorize_Post();
|
||||||
}
|
}
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Not a bot
|
||||||
|
pPlayer->m_LanguageCookie = g_ConVarManager.QueryClientConVar(pEntity, "cl_language", NULL, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (playerinfo)
|
if (playerinfo)
|
||||||
{
|
{
|
||||||
@ -1862,6 +1873,24 @@ void CmdMaxplayersCallback()
|
|||||||
g_Players.MaxPlayersChanged();
|
g_Players.MaxPlayersChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= m_maxClients; i++)
|
||||||
|
{
|
||||||
|
if (m_Players[i].m_LanguageCookie == cookie)
|
||||||
|
{
|
||||||
|
unsigned int langid;
|
||||||
|
m_Players[i].m_LangId = (translator->GetLanguageByName(cvarValue, &langid)) ? langid : translator->GetServerLanguage();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
*** PLAYER CODE ***
|
*** PLAYER CODE ***
|
||||||
@ -1886,6 +1915,9 @@ CPlayer::CPlayer()
|
|||||||
m_bIsReplay = false;
|
m_bIsReplay = false;
|
||||||
m_Serial.value = -1;
|
m_Serial.value = -1;
|
||||||
m_SteamAccountID = 0;
|
m_SteamAccountID = 0;
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
m_LanguageCookie = InvalidQueryCvarCookie;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||||
@ -1966,6 +1998,9 @@ void CPlayer::Disconnect()
|
|||||||
m_bIsReplay = false;
|
m_bIsReplay = false;
|
||||||
m_Serial.value = -1;
|
m_Serial.value = -1;
|
||||||
m_SteamAccountID = 0;
|
m_SteamAccountID = 0;
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
m_LanguageCookie = InvalidQueryCvarCookie;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::SetName(const char *name)
|
void CPlayer::SetName(const char *name)
|
||||||
|
@ -131,6 +131,9 @@ private:
|
|||||||
bool m_bIsReplay;
|
bool m_bIsReplay;
|
||||||
serial_t m_Serial;
|
serial_t m_Serial;
|
||||||
unsigned int m_SteamAccountID;
|
unsigned int m_SteamAccountID;
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
QueryCvarCookie_t m_LanguageCookie;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerManager :
|
class PlayerManager :
|
||||||
@ -211,6 +214,9 @@ public:
|
|||||||
unsigned int GetReplyTo();
|
unsigned int GetReplyTo();
|
||||||
unsigned int SetReplyTo(unsigned int reply);
|
unsigned int SetReplyTo(unsigned int reply);
|
||||||
void MaxPlayersChanged(int newvalue = -1);
|
void MaxPlayersChanged(int newvalue = -1);
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
bool HandleConVarQuery(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue);
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_DOTA
|
||||||
void OnServerActivate();
|
void OnServerActivate();
|
||||||
|
Loading…
Reference in New Issue
Block a user