From d40ff12d9ab00297d8a30946ca89b51c4969d08f Mon Sep 17 00:00:00 2001 From: Zwelf Date: Sun, 26 Mar 2023 16:42:31 +0200 Subject: [PATCH] Fix ninja dash not getting predicted correctly Fixes #6464 This was regressed by #6246 by the wrong transformation of `if(!m_FreezeTime)` to `if(m_FreezeTime != 0)` instead of the correct `if(m_FreezeTime == 0)`. And take additional measure to never set m_FreezeTime to a negative number in client prediction code. --- src/game/client/prediction/entities/character.cpp | 4 ++-- src/game/server/entities/character.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/prediction/entities/character.cpp b/src/game/client/prediction/entities/character.cpp index e14695589..f05978fa6 100644 --- a/src/game/client/prediction/entities/character.cpp +++ b/src/game/client/prediction/entities/character.cpp @@ -489,7 +489,7 @@ void CCharacter::GiveNinja() { m_Core.m_Ninja.m_ActivationTick = GameWorld()->GameTick(); m_Core.m_aWeapons[WEAPON_NINJA].m_Got = true; - if(m_FreezeTime > 0) + if(m_FreezeTime == 0) m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = -1; if(m_Core.m_ActiveWeapon != WEAPON_NINJA) m_LastWeapon = m_Core.m_ActiveWeapon; @@ -1205,7 +1205,7 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende { if(m_FreezeTime == 0) Freeze(); - m_FreezeTime = pExtended->m_FreezeEnd - GameWorld()->GameTick(); + m_FreezeTime = maximum(1, pExtended->m_FreezeEnd - GameWorld()->GameTick()); } else if(pExtended->m_FreezeEnd == -1) m_Core.m_DeepFrozen = true; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 0adb70e66..cd3d2448d 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1022,7 +1022,7 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID) Health = m_Health; Armor = m_Armor; if(m_Core.m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0) - AmmoCount = (m_FreezeTime > 0) ? m_Core.m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo : 0; + AmmoCount = (m_FreezeTime == 0) ? m_Core.m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo : 0; } if(GetPlayer()->IsAfk() || GetPlayer()->IsPaused())