diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index a3bf82298b5..3dca1c58430 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3315,10 +3315,10 @@ int main(int argc, const char **argv) // ignore_convention pClient->InitInterfaces(); // execute config file - IOHANDLE file = pStorage->OpenFile(CONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL); - if(file) + IOHANDLE File = pStorage->OpenFile(CONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL); + if(File) { - io_close(file); + io_close(File); pConsole->ExecuteFile(CONFIG_FILE); } else // fallback @@ -3327,10 +3327,10 @@ int main(int argc, const char **argv) // ignore_convention } // execute autoexec file - file = pStorage->OpenFile(AUTOEXEC_CLIENT_FILE, IOFLAG_READ, IStorage::TYPE_ALL); - if(file) + File = pStorage->OpenFile(AUTOEXEC_CLIENT_FILE, IOFLAG_READ, IStorage::TYPE_ALL); + if(File) { - io_close(file); + io_close(File); pConsole->ExecuteFile(AUTOEXEC_CLIENT_FILE); } else // fallback @@ -3338,6 +3338,17 @@ int main(int argc, const char **argv) // ignore_convention pConsole->ExecuteFile(AUTOEXEC_FILE); } + if(g_Config.m_ClConfigVersion < 1) + { + if(g_Config.m_ClAntiPing == 0) + { + g_Config.m_ClAntiPingPlayers = 1; + g_Config.m_ClAntiPingGrenade = 1; + g_Config.m_ClAntiPingWeapons = 1; + } + } + g_Config.m_ClConfigVersion = 1; + // parse the command line arguments if(argc > 1) // ignore_convention pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 55397e98607..3e1d108a69d 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -360,6 +360,7 @@ MACRO_CONFIG_INT(InpJoystick, inp_joystick, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT #else MACRO_CONFIG_INT(InpJoystick, inp_joystick, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Try to use a joystick as input") #endif +MACRO_CONFIG_INT(ClConfigVersion, cl_config_version, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "The config version. Helps newer clients fix bugs with older configs.") // demo editor MACRO_CONFIG_INT(ClDemoSliceBegin, cl_demo_slice_begin, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Begin marker for demo slice") diff --git a/src/game/client/components/items.cpp b/src/game/client/components/items.cpp index 2cb1dc05c98..f60650ad222 100644 --- a/src/game/client/components/items.cpp +++ b/src/game/client/components/items.cpp @@ -57,7 +57,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID) int PrevTick = Client()->PrevGameTick(); - if (g_Config.m_ClAntiPingGrenade && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK)) + if (m_pClient->AntiPingGrenade() && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK)) { // calc predicted game tick static int Offset = 0; diff --git a/src/game/client/components/nameplates.cpp b/src/game/client/components/nameplates.cpp index 2bcc771cfef..d41bd9f276d 100644 --- a/src/game/client/components/nameplates.cpp +++ b/src/game/client/components/nameplates.cpp @@ -88,7 +88,7 @@ void CNamePlates::RenderNameplate( void CNamePlates::OnRender() { - if (!g_Config.m_ClNameplates || g_Config.m_ClAntiPingPlayers) + if (!g_Config.m_ClNameplates || m_pClient->AntiPingPlayers()) return; for(int i = 0; i < MAX_CLIENTS; i++) diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 90388a89a46..9f09d7f93d4 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -257,7 +257,7 @@ void CPlayers::RenderHook( // set size RenderInfo.m_Size = 64.0f; - if (!g_Config.m_ClAntiPingPlayers) + if (!m_pClient->AntiPingPlayers()) { // use preditect players if needed if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) @@ -290,7 +290,7 @@ void CPlayers::RenderHook( } vec2 Position; - if (!g_Config.m_ClAntiPingPlayers) + if (!m_pClient->AntiPingPlayers()) Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); else Position = parPosition; @@ -305,7 +305,7 @@ void CPlayers::RenderHook( vec2 Pos = Position; vec2 HookPos; - if (!g_Config.m_ClAntiPingPlayers) + if (!m_pClient->AntiPingPlayers()) { if(pPlayerChar->m_HookedPlayer != -1) { @@ -440,7 +440,7 @@ void CPlayers::RenderPlayer( // use preditect players if needed - if (!g_Config.m_ClAntiPingPlayers) + if (!m_pClient->AntiPingPlayers()) { if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { @@ -475,7 +475,7 @@ void CPlayers::RenderPlayer( vec2 Direction = GetDirection((int)(Angle*256.0f)); vec2 Position; - if (!g_Config.m_ClAntiPingPlayers) + if (!m_pClient->AntiPingPlayers()) Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); else Position = parPosition; @@ -878,7 +878,7 @@ void CPlayers::RenderPlayer( Graphics()->QuadsEnd(); } - if(g_Config.m_ClNameplates && g_Config.m_ClAntiPingPlayers) + if(g_Config.m_ClNameplates && m_pClient->AntiPingPlayers()) { float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f; float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f; @@ -972,7 +972,7 @@ void CPlayers::OnRender() static int predcnt = 0; - if (g_Config.m_ClAntiPingPlayers) + if (m_pClient->AntiPingPlayers()) { for(int i = 0; i < MAX_CLIENTS; i++) { @@ -999,7 +999,7 @@ void CPlayers::OnRender() } } - if(g_Config.m_ClAntiPingPlayers && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) + if(m_pClient->AntiPingPlayers() && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(m_pClient->m_Snap.m_pLocalCharacter && !(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)) { // double ping = m_pClient->m_Snap.m_pLocalInfo->m_Latency; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 82efe1f7c07..90a9bc72d20 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -461,7 +461,7 @@ void CGameClient::UpdatePositions() // local character position if(g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { - if (!g_Config.m_ClAntiPingPlayers) + if(!AntiPingPlayers()) { if(!m_Snap.m_pLocalCharacter || (m_Snap.m_pGameInfoObj && m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)) { @@ -488,7 +488,7 @@ void CGameClient::UpdatePositions() vec2(m_Snap.m_pLocalCharacter->m_X, m_Snap.m_pLocalCharacter->m_Y), Client()->IntraGameTick()); } - if (g_Config.m_ClAntiPingPlayers) + if (AntiPingPlayers()) { for (int i = 0; i < MAX_CLIENTS; i++) { @@ -579,14 +579,6 @@ void CGameClient::OnRender() m_NewTick = false; m_NewPredictedTick = false; - if(g_Config.m_ClAntiPing != m_CurrentAntiPing) - { - g_Config.m_ClAntiPingPlayers = g_Config.m_ClAntiPing; - g_Config.m_ClAntiPingGrenade = g_Config.m_ClAntiPing; - g_Config.m_ClAntiPingWeapons = g_Config.m_ClAntiPing; - m_CurrentAntiPing = g_Config.m_ClAntiPing; - } - if(g_Config.m_ClDummy && !Client()->DummyConnected()) g_Config.m_ClDummy = 0; @@ -664,7 +656,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) g_GameClient.m_pItems->AddExtraProjectile(&Proj); - if(g_Config.m_ClAntiPingWeapons && Proj.m_Type == WEAPON_GRENADE && !UseExtraInfo(&Proj)) + if(AntiPingWeapons() && Proj.m_Type == WEAPON_GRENADE && !UseExtraInfo(&Proj)) { vec2 StartPos; vec2 Direction; @@ -1310,7 +1302,7 @@ void CGameClient::OnPredict() } static bool IsWeaker[2][MAX_CLIENTS] = {{0}}; - if(g_Config.m_ClAntiPingPlayers) + if(AntiPingPlayers()) FindWeaker(IsWeaker); // repredict character @@ -1338,7 +1330,7 @@ void CGameClient::OnPredict() int ReloadTimer = 0; vec2 PrevPos; - if(g_Config.m_ClAntiPingWeapons) + if(AntiPingWeapons()) { for(int Index = 0; Index < MaxProjectiles; Index++) PredictedProjectiles[Index].Deactivate(); @@ -1419,7 +1411,7 @@ void CGameClient::OnPredict() } } - if(g_Config.m_ClAntiPingWeapons) + if(AntiPingWeapons()) { const float ProximityRadius = 28.0f; CNetObj_PlayerInput Input; @@ -1593,7 +1585,7 @@ void CGameClient::OnPredict() } // calculate where everyone should move - if(g_Config.m_ClAntiPingPlayers) + if(AntiPingPlayers()) { //first apply Tick to weaker players (players that the local client has strong hook against), then local, then stronger players for(int h = 0; h < 3; h++) @@ -1623,7 +1615,7 @@ void CGameClient::OnPredict() } // move all players and quantize their data - if(g_Config.m_ClAntiPingPlayers) + if(AntiPingPlayers()) { // Everyone with weaker hook for(int c = 0; c < MAX_CLIENTS; c++) @@ -1700,7 +1692,7 @@ void CGameClient::OnPredict() { m_PredictedChar = *World.m_apCharacters[m_Snap.m_LocalClientID]; - if (g_Config.m_ClAntiPingPlayers) + if (AntiPingPlayers()) { for (int c = 0; c < MAX_CLIENTS; c++) { diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 10dbdf2e106..885d9dd87e6 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -363,11 +363,13 @@ class CGameClient : public IGameClient void FindWeaker(bool IsWeaker[2][MAX_CLIENTS]); -private: + bool AntiPingPlayers() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingPlayers; } + bool AntiPingGrenade() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingGrenade; } + bool AntiPingWeapons() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingWeapons; } +private: bool m_DDRaceMsgSent[2]; int m_ShowOthers[2]; - bool m_CurrentAntiPing; }; diff --git a/src/game/variables.h b/src/game/variables.h index 91ad9f46f86..6f7eaf695a3 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -7,10 +7,10 @@ // client MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements") MACRO_CONFIG_INT(ClAntiPingLimit, cl_antiping_limit, 0, 0, 200, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping limit (0 to disable)") -MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (sets all Antiping settings)") -MACRO_CONFIG_INT(ClAntiPingPlayers, cl_antiping_players, 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(ClAntiPingWeapons, cl_antiping_weapons, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict weapons)") +MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable antiping, i. e. more aggressive prediction.") +MACRO_CONFIG_INT(ClAntiPingPlayers, cl_antiping_players, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict other player's movement more aggressively (only enabled if cl_antiping is set to 1)") +MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict grenades (only enabled if cl_antiping is set to 1)") +MACRO_CONFIG_INT(ClAntiPingWeapons, cl_antiping_weapons, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict weapon projectiles (only enabled if cl_antiping is set to 1)") MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates") MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show name plates disregarding of distance") MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Use team colors for name plates")