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.

75 lines
2.1 KiB

  1. //========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "client_pch.h"
  14. #include "demo.h"
  15. #include "host.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. //-----------------------------------------------------------------------------
  19. // Purpose:
  20. // Input : world_start_state -
  21. // validframe -
  22. // start_command -
  23. // stop_command -
  24. //-----------------------------------------------------------------------------
  25. void CL_Predict( int world_start_state, bool validframe, int start_command, int stop_command )
  26. {
  27. // Allow client .dll to do prediction.
  28. g_pClientSidePrediction->Update(
  29. world_start_state,
  30. validframe,
  31. start_command,
  32. stop_command );
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Purpose: Determine if we received a new message, which means we need to
  36. // redo prediction
  37. //-----------------------------------------------------------------------------
  38. void CL_RunPrediction( PREDICTION_REASON reason )
  39. {
  40. CClientState &cl = GetBaseLocalClient();
  41. if ( !cl.IsActive() )
  42. return;
  43. if ( cl.m_nDeltaTick < 0 )
  44. {
  45. // no valid snapshot received yet
  46. return;
  47. }
  48. // Don't do prediction if skipping ahead during demo playback
  49. if ( demoplayer->IsSkipping() )
  50. {
  51. return;
  52. }
  53. //Msg( "%i pred reason %s\n", host_framecount, reason == PREDICTION_SIMULATION_RESULTS_ARRIVING_ON_SEND_FRAME ?
  54. // "same frame" : "normal" );
  55. bool valid = cl.m_nDeltaTick > 0; // GetBaseLocalClient().GetReceiveList( GetLocalClient().delta_tick ) != NULL;
  56. //Msg( "%i/%i CL_RunPrediction: last ack %i most recent %i\n",
  57. // host_framecount, GetBaseLocalClient().tickcount,
  58. // GetBaseLocalClient().last_command_ack,
  59. // GetBaseLocalClient().netchan->m_nOutSequenceNr - 1 );
  60. CL_Predict( cl.m_nDeltaTick,
  61. valid,
  62. cl.last_command_ack,
  63. cl.lastoutgoingcommand + cl.chokedcommands );
  64. }