Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send language code to the server #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions datasrc/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@
NetIntAny("m_ColorSkin"),
NetIntAny("m_BloodColor"),
NetIntRange("m_IsBot", 0, 1),
NetIntRange("m_Language", 0, 999),
]),

NetMessage("Cl_ChangeInfo", [
Expand All @@ -671,6 +672,7 @@
NetIntAny("m_ColorSkin"),
NetIntAny("m_BloodColor"),
NetIntRange("m_IsBot", 0, 1),
NetIntRange("m_Language", 0, 999),
]),

NetMessage("Cl_Kill", []),
Expand Down
1 change: 1 addition & 0 deletions src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,7 @@ void CMenus::RenderLanguageSelection(CUIRect MainView)
if(OldSelected != s_SelectedLanguage)
{
str_copy(g_Config.m_ClLanguagefile, s_Languages[s_SelectedLanguage].m_FileName, sizeof(g_Config.m_ClLanguagefile));
g_Config.m_ClLanguagecode = s_Languages[s_SelectedLanguage].m_CountryCode;
g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName, Storage(), Console());
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/game/client/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,7 @@ void CGameClient::SendInfo(bool Start)
Msg.m_ColorTopper = g_Config.m_PlayerColorTopper;
Msg.m_ColorSkin = g_Config.m_PlayerColorSkin;
Msg.m_BloodColor = g_Config.m_PlayerBloodColor;
Msg.m_Language = g_Config.m_ClLanguagecode;
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
}
else
Expand All @@ -1707,6 +1708,7 @@ void CGameClient::SendInfo(bool Start)
Msg.m_ColorTopper = g_Config.m_PlayerColorTopper;
Msg.m_ColorSkin = g_Config.m_PlayerColorSkin;
Msg.m_BloodColor = g_Config.m_PlayerBloodColor;
Msg.m_Language = g_Config.m_ClLanguagecode;
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);

// activate timer to resend the info if it gets filtered
Expand Down
12 changes: 10 additions & 2 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)

Server()->SetClientClan(ClientID, pMsg->m_pClan);
Server()->SetClientCountry(ClientID, pMsg->m_Country);
str_copy(pPlayer->m_aLanguage, Localization()->GetLanguageCode(pMsg->m_Country), sizeof(pPlayer->m_aLanguage));
str_copy(pPlayer->m_TeeInfos.m_TopperName, pMsg->m_pTopper, sizeof(pPlayer->m_TeeInfos.m_TopperName));
str_copy(pPlayer->m_TeeInfos.m_EyeName, pMsg->m_pEye, sizeof(pPlayer->m_TeeInfos.m_EyeName));
str_copy(pPlayer->m_TeeInfos.m_HeadName, pMsg->m_pHead, sizeof(pPlayer->m_TeeInfos.m_HeadName));
Expand All @@ -2373,6 +2372,11 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
pPlayer->m_TeeInfos.m_ColorTopper = pMsg->m_ColorTopper;
pPlayer->m_TeeInfos.m_BloodColor = pMsg->m_BloodColor;
pPlayer->m_TeeInfos.m_ColorSkin = pMsg->m_ColorSkin;

str_copy(pPlayer->m_aLanguage, Localization()->GetLanguageCode(pMsg->m_Country), sizeof(pPlayer->m_aLanguage));
if(pMsg->m_Language)
str_copy(pPlayer->m_aLanguage, Localization()->GetLanguageCode(pMsg->m_Language), sizeof(pPlayer->m_aLanguage));

m_pController->OnPlayerInfoChange(pPlayer);
}
else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused)
Expand Down Expand Up @@ -2453,7 +2457,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
Server()->SetClientName(ClientID, pMsg->m_pName);
Server()->SetClientClan(ClientID, pMsg->m_pClan);
Server()->SetClientCountry(ClientID, pMsg->m_Country);
str_copy(pPlayer->m_aLanguage, Localization()->GetLanguageCode(pMsg->m_Country), sizeof(pPlayer->m_aLanguage));
str_copy(pPlayer->m_TeeInfos.m_TopperName, pMsg->m_pTopper, sizeof(pPlayer->m_TeeInfos.m_TopperName));
str_copy(pPlayer->m_TeeInfos.m_EyeName, pMsg->m_pEye, sizeof(pPlayer->m_TeeInfos.m_EyeName));
str_copy(pPlayer->m_TeeInfos.m_HeadName, pMsg->m_pHead, sizeof(pPlayer->m_TeeInfos.m_HeadName));
Expand All @@ -2465,6 +2468,11 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
pPlayer->m_TeeInfos.m_ColorTopper = pMsg->m_ColorTopper;
pPlayer->m_TeeInfos.m_ColorSkin = pMsg->m_ColorSkin;
pPlayer->m_TeeInfos.m_BloodColor = pMsg->m_BloodColor;

str_copy(pPlayer->m_aLanguage, Localization()->GetLanguageCode(pMsg->m_Country), sizeof(pPlayer->m_aLanguage));
if(pMsg->m_Language)
str_copy(pPlayer->m_aLanguage, Localization()->GetLanguageCode(pMsg->m_Language), sizeof(pPlayer->m_aLanguage));

m_pController->OnPlayerInfoChange(pPlayer);

// send vote options
Expand Down
1 change: 1 addition & 0 deletions src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ MACRO_CONFIG_INT(ClMotdTime, cl_motd_time, 10, 0, 100, CFGFLAG_CLIENT|CFGFLAG_SA
MACRO_CONFIG_STR(ClVersionServer, cl_version_server, 100, "version.ninslash.com", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Server to use to check for new versions")

MACRO_CONFIG_STR(ClLanguagefile, cl_languagefile, 255, "", CFGFLAG_CLIENT|CFGFLAG_SAVE, "What language file to use")
MACRO_CONFIG_INT(ClLanguagecode, cl_languagecode, 0, 0, 999, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Language code sent to the server")

MACRO_CONFIG_INT(PlayerColorBody, player_color_body, 0, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
MACRO_CONFIG_INT(PlayerColorFeet, player_color_feet, 0, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")
Expand Down
Loading