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.

89 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "player_command.h"
  9. #include "igamemovement.h"
  10. #include "in_buttons.h"
  11. #include "ipredictionsystem.h"
  12. #include "sdk_player.h"
  13. #include "iservervehicle.h"
  14. static CMoveData g_MoveData;
  15. CMoveData *g_pMoveData = &g_MoveData;
  16. IPredictionSystem *IPredictionSystem::g_pPredictionSystems = NULL;
  17. //-----------------------------------------------------------------------------
  18. // Sets up the move data for TF2
  19. //-----------------------------------------------------------------------------
  20. class CSDKPlayerMove : public CPlayerMove
  21. {
  22. DECLARE_CLASS( CSDKPlayerMove, CPlayerMove );
  23. public:
  24. virtual void StartCommand( CBasePlayer *player, CUserCmd *cmd );
  25. virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
  26. virtual void FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move );
  27. };
  28. // PlayerMove Interface
  29. static CSDKPlayerMove g_PlayerMove;
  30. //-----------------------------------------------------------------------------
  31. // Singleton accessor
  32. //-----------------------------------------------------------------------------
  33. CPlayerMove *PlayerMove()
  34. {
  35. return &g_PlayerMove;
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Main setup, finish
  39. //-----------------------------------------------------------------------------
  40. void CSDKPlayerMove::StartCommand( CBasePlayer *player, CUserCmd *cmd )
  41. {
  42. BaseClass::StartCommand( player, cmd );
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose: This is called pre player movement and copies all the data necessary
  46. // from the player for movement. (Server-side, the client-side version
  47. // of this code can be found in prediction.cpp.)
  48. //-----------------------------------------------------------------------------
  49. void CSDKPlayerMove::SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move )
  50. {
  51. BaseClass::SetupMove( player, ucmd, pHelper, move );
  52. IServerVehicle *pVehicle = player->GetVehicle();
  53. if (pVehicle && gpGlobals->frametime != 0)
  54. {
  55. pVehicle->SetupMove( player, ucmd, pHelper, move );
  56. }
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Purpose: This is called post player movement to copy back all data that
  60. // movement could have modified and that is necessary for future
  61. // movement. (Server-side, the client-side version of this code can
  62. // be found in prediction.cpp.)
  63. //-----------------------------------------------------------------------------
  64. void CSDKPlayerMove::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move )
  65. {
  66. // Call the default FinishMove code.
  67. BaseClass::FinishMove( player, ucmd, move );
  68. IServerVehicle *pVehicle = player->GetVehicle();
  69. if (pVehicle && gpGlobals->frametime != 0)
  70. {
  71. pVehicle->FinishMove( player, ucmd, move );
  72. }
  73. }