Skip to content

Commit 1a8e808

Browse files
authored
Fix prediction when player has no current weapon (ddnet#11651)
2 parents 765b391 + b354144 commit 1a8e808

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/game/client/prediction/entities/character.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,9 +1467,11 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende
14671467
SetTuneZone(GameWorld()->m_WorldConfig.m_UseTuneZones ? Collision()->IsTune(Collision()->GetMapIndex(m_Pos)) : 0);
14681468

14691469
// set the current weapon
1470-
if(pChar->m_Weapon >= 0 && pChar->m_Weapon != WEAPON_NINJA)
1470+
if(pChar->m_Weapon != WEAPON_NINJA)
14711471
{
1472-
m_Core.m_aWeapons[pChar->m_Weapon].m_Ammo = (GameWorld()->m_WorldConfig.m_InfiniteAmmo || pChar->m_Weapon == WEAPON_HAMMER) ? -1 : pChar->m_AmmoCount;
1472+
if(pChar->m_Weapon >= 0)
1473+
m_Core.m_aWeapons[pChar->m_Weapon].m_Ammo = (GameWorld()->m_WorldConfig.m_InfiniteAmmo || pChar->m_Weapon == WEAPON_HAMMER) ? -1 : pChar->m_AmmoCount;
1474+
14731475
if(pChar->m_Weapon != m_Core.m_ActiveWeapon)
14741476
SetActiveWeapon(pChar->m_Weapon);
14751477
}
@@ -1522,7 +1524,7 @@ void CCharacter::SetActiveWeapon(int ActiveWeapon)
15221524
{
15231525
if(ActiveWeapon < WEAPON_HAMMER || ActiveWeapon >= NUM_WEAPONS)
15241526
{
1525-
m_Core.m_ActiveWeapon = WEAPON_HAMMER;
1527+
m_Core.m_ActiveWeapon = -1;
15261528
}
15271529
else
15281530
{

0 commit comments

Comments
 (0)