Skip to content

Commit 2aa8ffc

Browse files
committed
game\shared: Let player shoot on the same tick they canceled their reload
"When a player tries to shoot a weapon with a non-empty clip while reloading in TF2, it cancels the reload on the first tick and only fires the weapon on the tick after. This happens because ItemBusyFrame (idle logic) and ItemPostFrame (shooting logic) are separated with an if/else statement controlled by gpGlobals->curtime < m_flNextAttack. Canceling a reload is effectively done by setting m_flNextAttack = gpGlobals->curtime inside ItemBusyFrame, so ItemPostFrame is skipped over even though m_flNextAttack marks the weapon as ready to shoot." Changing the if/else to an if/if solves this. I'm pretty sure it shouldn't cause any problems as it only applies when m_flNextAttack is intentionally set to gpGlobals->curtime by weapon logic. However this is mostly a change directed at TF2, so I could specifically target TF2's reload cancel if need be. See ValveSoftware/source-sdk-2013#935
1 parent 38a8e01 commit 2aa8ffc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

game/shared/baseplayer_shared.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,17 @@ void CBasePlayer::ItemPostFrame()
266266
return;
267267
}
268268

269-
if ( gpGlobals->curtime < m_flNextAttack )
269+
if ( gpGlobals->curtime < m_flNextAttack )
270270
{
271271
if ( GetActiveWeapon() )
272272
{
273273
GetActiveWeapon()->ItemBusyFrame();
274274
}
275275
}
276-
else
276+
277+
// dimhotepus: replace if/else with if/if as ItemBusyFrame() can do m_flNextAttack = gpGlobals->curtime
278+
// and we must fire immediately instead of waiting for next tick.
279+
if ( gpGlobals->curtime >= m_flNextAttack )
277280
{
278281
if ( GetActiveWeapon() && (!IsInAVehicle() || UsingStandardWeaponsInVehicle()) )
279282
{

0 commit comments

Comments
 (0)