Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "cbase.h"
  8. #include "prediction.h"
  9. #include "c_baseplayer.h"
  10. #include "igamemovement.h"
  11. #include "c_tf_player.h"
  12. static CMoveData g_MoveData;
  13. CMoveData *g_pMoveData = &g_MoveData;
  14. class CTFPrediction : public CPrediction
  15. {
  16. DECLARE_CLASS( CTFPrediction, CPrediction );
  17. public:
  18. virtual void SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
  19. virtual void FinishMove( C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move );
  20. };
  21. //-----------------------------------------------------------------------------
  22. // Purpose:
  23. //-----------------------------------------------------------------------------
  24. void CTFPrediction::SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper,
  25. CMoveData *move )
  26. {
  27. C_TFPlayer *pTFPlayer = ToTFPlayer( player );
  28. if ( pTFPlayer )
  29. {
  30. // Check to see if we are a crouched, heavy, firing his weapons and zero out movement.
  31. if ( pTFPlayer->GetPlayerClass()->IsClass( TF_CLASS_HEAVYWEAPONS ) )
  32. {
  33. if ( ( pTFPlayer->GetFlags() & FL_DUCKING ) && ( pTFPlayer->m_Shared.InCond( TF_COND_AIMING ) ) )
  34. {
  35. ucmd->forwardmove = 0.0f;
  36. ucmd->sidemove = 0.0f;
  37. }
  38. }
  39. }
  40. // Call the default SetupMove code.
  41. BaseClass::SetupMove( player, ucmd, pHelper, move );
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. //-----------------------------------------------------------------------------
  46. void CTFPrediction::FinishMove( C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move )
  47. {
  48. // Call the default FinishMove code.
  49. BaseClass::FinishMove( player, ucmd, move );
  50. }
  51. // Expose interface to engine
  52. // Expose interface to engine
  53. static CTFPrediction g_Prediction;
  54. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CTFPrediction, IPrediction, VCLIENT_PREDICTION_INTERFACE_VERSION, g_Prediction );
  55. CPrediction *prediction = &g_Prediction;