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.

74 lines
2.1 KiB

  1. //========= Copyright 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. tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s", __FUNCTION__ );
  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; // cl.GetReceiveList( cl.delta_tick ) != NULL;
  56. //Msg( "%i/%i CL_RunPrediction: last ack %i most recent %i\n",
  57. // host_framecount, cl.tickcount,
  58. // cl.last_command_ack,
  59. // cl.netchan->m_nOutSequenceNr - 1 );
  60. CL_Predict( cl.m_nDeltaTick,
  61. valid,
  62. cl.last_command_ack,
  63. cl.lastoutgoingcommand + cl.chokedcommands );
  64. }