Lay groundwork for client language property
Abstract the language getter to HLTVClientWrapper::GetLanguageId so we have the option of having native setters / getters in SourcePawn to assign language. Whether we actually do something about it, I don't know.
This commit is contained in:
parent
4c38126ac3
commit
29f76a6737
@ -27,6 +27,14 @@ const char *HLTVClientWrapper::Password()
|
|||||||
return m_Password.chars();
|
return m_Password.chars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int HLTVClientWrapper::GetLanguageId()
|
||||||
|
{
|
||||||
|
// TODO expose natives to override spectator client language and remove native ifdefs
|
||||||
|
unsigned int langid = translator->GetServerLanguage();
|
||||||
|
translator->GetLanguageByName(m_Client->GetUserSetting("cl_language"), &langid);
|
||||||
|
return langid;
|
||||||
|
}
|
||||||
|
|
||||||
bool HLTVClientWrapper::IsConnected()
|
bool HLTVClientWrapper::IsConnected()
|
||||||
{
|
{
|
||||||
return m_Client && m_Client->IsConnected();
|
return m_Client && m_Client->IsConnected();
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
const char *Name();
|
const char *Name();
|
||||||
const char *Ip();
|
const char *Ip();
|
||||||
const char *Password();
|
const char *Password();
|
||||||
|
unsigned int GetLanguageId();
|
||||||
bool IsConnected();
|
bool IsConnected();
|
||||||
IClient *BaseClient();
|
IClient *BaseClient();
|
||||||
|
|
||||||
|
10
natives.cpp
10
natives.cpp
@ -830,10 +830,7 @@ static cell_t Native_PrintToChat(IPluginContext *pContext, const cell_t *params)
|
|||||||
// There's no way to set the current translation without a client index, so we'll save / restore the language on the relay.
|
// There's no way to set the current translation without a client index, so we'll save / restore the language on the relay.
|
||||||
int iHLTVClient = hltvserver->GetHLTVServer()->GetHLTVSlot() + 1;
|
int iHLTVClient = hltvserver->GetHLTVServer()->GetHLTVSlot() + 1;
|
||||||
IGamePlayer *pHLTVClient = playerhelpers->GetGamePlayer(iHLTVClient);
|
IGamePlayer *pHLTVClient = playerhelpers->GetGamePlayer(iHLTVClient);
|
||||||
|
pHLTVClient->SetLanguageId(pClient->GetLanguageId());
|
||||||
unsigned int langid = translator->GetServerLanguage();
|
|
||||||
translator->GetLanguageByName(pClient->BaseClient()->GetUserSetting("cl_language"), &langid);
|
|
||||||
pHLTVClient->SetLanguageId(langid);
|
|
||||||
|
|
||||||
int restoreTarget = translator->SetGlobalTarget(hltvserver->GetHLTVServer()->GetHLTVSlot() + 1);
|
int restoreTarget = translator->SetGlobalTarget(hltvserver->GetHLTVServer()->GetHLTVSlot() + 1);
|
||||||
#endif
|
#endif
|
||||||
@ -903,10 +900,7 @@ static cell_t Native_PrintToConsole(IPluginContext *pContext, const cell_t *para
|
|||||||
// There's no way to set the current translation without a client index, so we'll save / restore the language on the relay.
|
// There's no way to set the current translation without a client index, so we'll save / restore the language on the relay.
|
||||||
int iHLTVClient = hltvserver->GetHLTVServer()->GetHLTVSlot() + 1;
|
int iHLTVClient = hltvserver->GetHLTVServer()->GetHLTVSlot() + 1;
|
||||||
IGamePlayer *pHLTVClient = playerhelpers->GetGamePlayer(iHLTVClient);
|
IGamePlayer *pHLTVClient = playerhelpers->GetGamePlayer(iHLTVClient);
|
||||||
|
pHLTVClient->SetLanguageId(pClient->GetLanguageId());
|
||||||
unsigned int langid = translator->GetServerLanguage();
|
|
||||||
translator->GetLanguageByName(pClient->BaseClient()->GetUserSetting("cl_language"), &langid);
|
|
||||||
pHLTVClient->SetLanguageId(langid);
|
|
||||||
|
|
||||||
int restoreTarget = translator->SetGlobalTarget(hltvserver->GetHLTVServer()->GetHLTVSlot() + 1);
|
int restoreTarget = translator->SetGlobalTarget(hltvserver->GetHLTVServer()->GetHLTVSlot() + 1);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user