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.

86 lines
2.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef HLTVDEMO_H
  7. #define HLTVDEMO_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <filesystem.h>
  12. #include "demo.h"
  13. #include "demofile.h"
  14. #include "netmessages_signon.h"
  15. class CHLTVFrame;
  16. class CGameInfo;
  17. class CHLTVServer;
  18. class CNETMsg_PlayerAvatarData_t;
  19. class CHLTVDemoRecorder : private IDemoRecorder
  20. {
  21. public:
  22. CHLTVDemoRecorder( CHLTVServer *pHltvServer );
  23. virtual ~CHLTVDemoRecorder();
  24. // Convert to demo recorder
  25. IDemoRecorder* GetDemoRecorder() { return this; }
  26. public: // For use by HLTVServer
  27. void WriteFrame( CHLTVFrame *pFrame, bf_write *additionaldata = NULL );
  28. void RecordPlayerAvatar( const CNETMsg_PlayerAvatarData_t* hltvPlayerAvatar );
  29. bool IsRecording( void ); // True between StartRecording and StopRecording()
  30. void StopRecording( const CGameInfo* pGameInfo = NULL );
  31. int GetRecordingTick( void );
  32. const char* GetDemoFilename( void ) { return m_DemoFile.m_szFileName; }
  33. // These are somewhat misnamed; they queue up the recording to start on the next tick.
  34. // This is to guarantee that all game state is consistent during recording.
  35. void StartAutoRecording();
  36. void StartRecording( const char *filename, bool bContinuously );
  37. private: // IDemoRecorder
  38. void RecordCommand( const char *cmdstring );
  39. void RecordMessages( bf_read &data, int bits );
  40. void RecordPacket( void );
  41. void RecordServerClasses( ServerClass *pClasses );
  42. void RecordCustomData( int iCallbackIndex, const void *pData, size_t iDataLength );
  43. // These are not needed by HLTV demos, as they are for the local client; for HLTV/GOTV there
  44. // is no local client playing the game.
  45. void SetSignonState( SIGNONSTATE state ) {}
  46. void RecordUserInput( int cmdnumber ) {}
  47. void ResetDemoInterpolation( void ) {}
  48. private: // internal
  49. void CloseFile();
  50. void Reset();
  51. void WriteServerInfo();
  52. int WriteSignonData(); // write all necessary signon data and returns written bytes
  53. void WriteMessages( unsigned char cmd, bf_write &message );
  54. void RecordStringTables();
  55. // If we are recording and we have finished the 'sign-on' step of demo recording
  56. bool HasRecordingActuallyStarted() { return m_bIsRecording && m_nStartTick >= 0; }
  57. private:
  58. CDemoFile m_DemoFile;
  59. bool m_bIsRecording;
  60. int m_nFrameCount;
  61. int m_nStartTick;
  62. int m_SequenceInfo;
  63. int m_nDeltaTick;
  64. bf_write m_MessageData; // temp buffer for all network messages
  65. int m_nLastWrittenTick;
  66. CHLTVServer *hltv;
  67. };
  68. #endif // HLTVDEMO_H