Permalink
Browse files

cgame: fix zoom/unzoom effect when moving to fast

  • Loading branch information...
Aranud committed Dec 7, 2017
1 parent 1b4c65c commit 0b3e912f33345b22ce47a898f198aa7066aacbae
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/cgame/cg_draw.c
  2. +14 −0 src/cgame/cg_weapons.c
View
@@ -1142,7 +1142,7 @@ static void CG_DrawCrosshair(void)
{
CG_FinishWeaponChange(cg.snap->ps.weapon, GetWeaponTableData(cg.snap->ps.weapon)->weapAlts);
}
if (
else if (
#ifdef FEATURE_MULTIVIEW
cg.mvTotalClients < 1 ||
#endif
View
@@ -4018,6 +4018,12 @@ void CG_AltWeapon_f(void)
trap_SendConsoleCommand( "+zoom\n" );
}*/
// don't allow zooming when prone moving (prevent fast zoom/unzoom)
if (cg.predictedPlayerState.eFlags & EF_PRONE_MOVING)
{
return;
}
if (cg.snap->ps.eFlags & EF_ZOOMING)
{
trap_SendConsoleCommand("-zoom\n");
@@ -4033,6 +4039,14 @@ void CG_AltWeapon_f(void)
return;
}
else if (GetWeaponTableData(GetWeaponTableData(cg.weaponSelect)->weapAlts)->isScoped)
{
// don't allow players switching to scoped weapon when prone moving and run -- speed 80 == crouch, 128 == walk, 256 == run
if (VectorLengthSquared(cg.snap->ps.velocity) > Square(160) || cg.predictedPlayerState.eFlags & EF_PRONE_MOVING)
{
return;
}
}
if (CG_WeaponSelectable(GetWeaponTableData(cg.weaponSelect)->weapAlts)) // new weapon is valid
{

0 comments on commit 0b3e912

Please sign in to comment.