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.

98 lines
3.3 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 "iservervehicle.h"
  13. #include "cs_player.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 CCSPlayerMove : public CPlayerMove
  21. {
  22. DECLARE_CLASS( CCSPlayerMove, 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 CCSPlayerMove g_PlayerMove;
  30. //-----------------------------------------------------------------------------
  31. // Singleton accessor
  32. //-----------------------------------------------------------------------------
  33. CPlayerMove *PlayerMove()
  34. {
  35. return &g_PlayerMove;
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Main setup, finish
  39. //-----------------------------------------------------------------------------
  40. void CCSPlayerMove::StartCommand( CBasePlayer *player, CUserCmd *cmd )
  41. {
  42. CCSPlayer *pPlayer = ToCSPlayer( player );
  43. // Reset this.. it gets reset each frame that we're in a bomb zone.
  44. pPlayer->m_bInBombZone = false;
  45. pPlayer->m_bInBuyZone = false;
  46. pPlayer->m_bInHostageRescueZone = false;
  47. BaseClass::StartCommand( player, cmd );
  48. }
  49. //-----------------------------------------------------------------------------
  50. // Purpose: This is called pre player movement and copies all the data necessary
  51. // from the player for movement. (Server-side, the client-side version
  52. // of this code can be found in prediction.cpp.)
  53. //-----------------------------------------------------------------------------
  54. void CCSPlayerMove::SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move )
  55. {
  56. player->AvoidPhysicsProps( ucmd );
  57. BaseClass::SetupMove( player, ucmd, pHelper, move );
  58. IServerVehicle *pVehicle = player->GetVehicle();
  59. if (pVehicle && gpGlobals->frametime != 0)
  60. {
  61. pVehicle->SetupMove( player, ucmd, pHelper, move );
  62. }
  63. }
  64. //-----------------------------------------------------------------------------
  65. // Purpose: This is called post player movement to copy back all data that
  66. // movement could have modified and that is necessary for future
  67. // movement. (Server-side, the client-side version of this code can
  68. // be found in prediction.cpp.)
  69. //-----------------------------------------------------------------------------
  70. void CCSPlayerMove::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move )
  71. {
  72. // Call the default FinishMove code.
  73. BaseClass::FinishMove( player, ucmd, move );
  74. IServerVehicle *pVehicle = player->GetVehicle();
  75. if (pVehicle && gpGlobals->frametime != 0)
  76. {
  77. pVehicle->FinishMove( player, ucmd, move );
  78. }
  79. }