Counter Strike : Global Offensive Source Code
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.

94 lines
3.1 KiB

  1. //========= Copyright � 1996-2005, 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. // NOTE: This has to be the last file included!
  15. #include "tier0/memdbgon.h"
  16. static CMoveData g_MoveData;
  17. CMoveData *g_pMoveData = &g_MoveData;
  18. IPredictionSystem *IPredictionSystem::g_pPredictionSystems = NULL;
  19. //-----------------------------------------------------------------------------
  20. // Sets up the move data for TF2
  21. //-----------------------------------------------------------------------------
  22. class CCSPlayerMove : public CPlayerMove
  23. {
  24. DECLARE_CLASS( CCSPlayerMove, CPlayerMove );
  25. public:
  26. virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
  27. virtual void FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move );
  28. };
  29. // PlayerMove Interface
  30. static CCSPlayerMove g_PlayerMove;
  31. //-----------------------------------------------------------------------------
  32. // Singleton accessor
  33. //-----------------------------------------------------------------------------
  34. CPlayerMove *PlayerMove()
  35. {
  36. return &g_PlayerMove;
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose: This is called pre player movement and copies all the data necessary
  40. // from the player for movement. (Server-side, the client-side version
  41. // of this code can be found in prediction.cpp.)
  42. //-----------------------------------------------------------------------------
  43. void CCSPlayerMove::SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move )
  44. {
  45. player->AvoidPhysicsProps( ucmd );
  46. BaseClass::SetupMove( player, ucmd, pHelper, move );
  47. IServerVehicle *pVehicle = player->GetVehicle();
  48. if (pVehicle && gpGlobals->frametime != 0)
  49. {
  50. pVehicle->SetupMove( player, ucmd, pHelper, move );
  51. }
  52. }
  53. //-----------------------------------------------------------------------------
  54. // Purpose: This is called post player movement to copy back all data that
  55. // movement could have modified and that is necessary for future
  56. // movement. (Server-side, the client-side version of this code can
  57. // be found in prediction.cpp.)
  58. //-----------------------------------------------------------------------------
  59. void CCSPlayerMove::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move )
  60. {
  61. // Call the default FinishMove code.
  62. BaseClass::FinishMove( player, ucmd, move );
  63. IServerVehicle *pVehicle = player->GetVehicle();
  64. if (pVehicle && gpGlobals->frametime != 0)
  65. {
  66. pVehicle->FinishMove( player, ucmd, move );
  67. }
  68. CCSPlayer *pPlayer = ToCSPlayer( player );
  69. // Reset these... they get reset each frame.
  70. pPlayer->m_bInBombZone = false;
  71. pPlayer->m_bInBombZoneTrigger = false;
  72. pPlayer->m_bInBuyZone = false;
  73. pPlayer->m_bInHostageRescueZone = false;
  74. pPlayer->m_bInNoDefuseArea = false;
  75. }