Automatic timeout protect message in client

This commit is contained in:
def 2014-08-09 19:17:21 +02:00
parent 85b7475ae4
commit ee6fcdf876
5 changed files with 34 additions and 0 deletions

View file

@ -310,5 +310,6 @@ MACRO_CONFIG_INT(ClShowDirection, cl_show_direction, 0, 0, 1, CFGFLAG_SAVE|CFGFL
MACRO_CONFIG_INT(ClAutoUpdate, cl_auto_update, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Auto-Update")
MACRO_CONFIG_INT(ClOldGunPosition, cl_old_gun_position, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Tees hold gun a bit higher like in TW 0.6.1 and older")
MACRO_CONFIG_INT(ClConfirmDisconnect, cl_confirm_disconnect, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Confirmation popup before disconnecting")
MACRO_CONFIG_STR(ClTimeoutCode, cl_timeout_code, 64, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Timeout code to use")
#endif

View file

@ -1852,4 +1852,13 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
DoEditBox(&g_Config.m_ConnTimeout, &Button, aBuf, sizeof(aBuf), 14.0f, &Offset);
g_Config.m_ConnTimeout = clamp(str_toint(aBuf), 5, 1000);
}
// player name
Right.HSplitTop(20.0f, &Button, &Right);
Button.VSplitLeft(190.0f, &Label, &Button);
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Timeout code"));
UI()->DoLabelScaled(&Label, aBuf, 14.0, -1);
static float s_OffsetCode = 0.0f;
DoEditBox(g_Config.m_ClTimeoutCode, &Button, g_Config.m_ClTimeoutCode, sizeof(g_Config.m_ClTimeoutCode), 14.0f, &s_OffsetCode);
}

View file

@ -320,6 +320,17 @@ void CGameClient::OnInit()
// Set free binds to DDRace binds if it's active
if(!g_Config.m_ClDDRaceBindsSet && g_Config.m_ClDDRaceBinds)
gs_Binds.SetDDRaceBinds(true);
if(g_Config.m_ClTimeoutCode[0] == '\0')
{
for(unsigned int i = 0; i < 16; i++)
{
if (rand() % 2)
g_Config.m_ClTimeoutCode[i] = (rand() % 26) + 97;
else
g_Config.m_ClTimeoutCode[i] = (rand() % 26) + 65;
}
}
}
void CGameClient::DispatchInput()
@ -704,6 +715,17 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy)
if (i <= 16)
m_Teams.m_IsDDRace16 = true;
else if (!m_Teams.m_IsDDRace64)
{
m_Teams.m_IsDDRace64 = true;
CNetMsg_Cl_Say Msg;
Msg.m_Team = 0;
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "/timeout %s", g_Config.m_ClTimeoutCode);
Msg.m_pMessage = aBuf;
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
}
}
else if(MsgId == NETMSGTYPE_SV_PLAYERTIME)
{

View file

@ -34,6 +34,7 @@ bool CTeamsCore::CanCollide(int ClientID1, int ClientID2)
void CTeamsCore::Reset()
{
m_IsDDRace16 = false;
m_IsDDRace64 = false;
for (int i = 0; i < MAX_CLIENTS; ++i)
{

View file

@ -16,6 +16,7 @@ class CTeamsCore
bool m_IsSolo[MAX_CLIENTS];
public:
bool m_IsDDRace16;
bool m_IsDDRace64;
CTeamsCore(void);