From da9ff2a69604c87ec807f085765a892cd70232a5 Mon Sep 17 00:00:00 2001 From: def Date: Wed, 18 Dec 2013 16:54:20 +0100 Subject: [PATCH] Add: Set Ping to any value you want --- src/engine/client/client.cpp | 6 +++++- src/game/client/components/menus_settings.cpp | 12 ++++++++++++ src/game/variables.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 51439923f..3c819755b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1207,6 +1207,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) { int InputPredTick = Unpacker.GetInt(); int TimeLeft = Unpacker.GetInt(); + int64 Now = time_get(); // adjust our prediction time int64 Target = 0; @@ -1214,12 +1215,15 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) { if(m_aInputs[k].m_Tick == InputPredTick) { - Target = m_aInputs[k].m_PredictedTime + (time_get() - m_aInputs[k].m_Time); + Target = m_aInputs[k].m_PredictedTime + (Now - m_aInputs[k].m_Time); Target = Target - (int64)(((TimeLeft-PREDICTION_MARGIN)/1000.0f)*time_freq()); break; } } + if ((Target - m_GameTime.Get(Now)) / 1000 < g_Config.m_ClSetPing) + Target = m_GameTime.Get(Now) + g_Config.m_ClSetPing * 1000; + if(Target) m_PredictedTime.Update(&m_InputtimeMarginGraph, Target, TimeLeft, 1); } diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index f8aa53609..3c0f4a287 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1112,6 +1112,18 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView) g_Config.m_ClShowChat ^= 1; } + // Set Ping + { + char aBuf[64]; + str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_ClSetPing); + MainView.HSplitTop(20.0f, &Button, &MainView); + UI()->DoLabelScaled(&Button, Localize("Set Ping"), 14.0f, -1); + Button.VSplitLeft(190.0f, 0, &Button); + static float Offset = 0.0f; + DoEditBox(&g_Config.m_ClSetPing, &Button, aBuf, sizeof(aBuf), 14.0f, &Offset); + g_Config.m_ClSetPing = min(900, max(0, str_toint(aBuf))); + } + CUIRect aRects[2]; CUIRect Label; MainView.HSplitTop(5.0f, 0, &MainView); diff --git a/src/game/variables.h b/src/game/variables.h index ca1870894..dff80dbe4 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -7,6 +7,7 @@ // client MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements") +MACRO_CONFIG_INT(ClSetPing, cl_setping, 0, 0, 900, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Set ping (in ms; prediction time is increased as if you have that ping)") MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements)") MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict grenades)") MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates")