mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6470
6470: Fix ninja not getting predicted r=heinrich5991 a=Zwelf 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. ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Zwelf <zwelf@strct.cc>
This commit is contained in:
commit
b207826df1
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue