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.

88 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef DEMOFILE_H
  7. #define DEMOFILE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #define DEMO_FILE_UTLBUFFER 1
  12. #define DEMO_FILE_MAX_STRINGTABLE_SIZE 5000000 // 5 mb
  13. #include "demo.h"
  14. #ifdef DEMO_FILE_UTLBUFFER
  15. #include "tier2/utlstreambuffer.h"
  16. #else
  17. #include <filesystem.h>
  18. #endif
  19. #include "tier1/bitbuf.h"
  20. //-----------------------------------------------------------------------------
  21. // Forward declarations
  22. //-----------------------------------------------------------------------------
  23. class IDemoBuffer;
  24. //-----------------------------------------------------------------------------
  25. // Demo file
  26. //-----------------------------------------------------------------------------
  27. class CDemoFile
  28. {
  29. public:
  30. CDemoFile();
  31. ~CDemoFile();
  32. bool Open(const char *name, bool bReadOnly, bool bMemoryBuffer = false, int nBufferSize = 0, bool bAllowHeaderWrite = true);
  33. bool IsOpen();
  34. void Close();
  35. void SeekTo( int position, bool bRead );
  36. unsigned int GetCurPos( bool bRead );
  37. int GetSize();
  38. void WriteRawData( const char *buffer, int length );
  39. int ReadRawData( char *buffer, int length );
  40. void WriteSequenceInfo(int nSeqNrIn, int nSeqNrOutAck);
  41. void ReadSequenceInfo(int &nSeqNrIn, int &nSeqNrOutAck);
  42. void WriteCmdInfo( democmdinfo_t& info );
  43. void ReadCmdInfo( democmdinfo_t& info );
  44. void WriteCmdHeader( unsigned char cmd, int tick );
  45. void ReadCmdHeader( unsigned char& cmd, int& tick );
  46. void WriteConsoleCommand( const char *cmd, int tick );
  47. const char *ReadConsoleCommand( void );
  48. void WriteNetworkDataTables( bf_write *buf, int tick );
  49. int ReadNetworkDataTables( bf_read *buf );
  50. void WriteStringTables( bf_write *buf, int tick );
  51. int ReadStringTables( bf_read *buf );
  52. void WriteUserCmd( int cmdnumber, const char *buffer, unsigned char bytes, int tick );
  53. int ReadUserCmd( char *buffer, int &size );
  54. void WriteDemoHeader();
  55. demoheader_t *ReadDemoHeader();
  56. void WriteFileBytes( FileHandle_t fh, int length );
  57. // Returns the PROTOCOL_VERSION used when .dem was recorded
  58. int GetProtocolVersion();
  59. public:
  60. char m_szFileName[MAX_PATH]; //name of current demo file
  61. demoheader_t m_DemoHeader; //general demo info
  62. CUtlBuffer *m_pBuffer;
  63. bool m_bAllowHeaderWrite;
  64. bool m_bIsStreamBuffer;
  65. };
  66. #endif // DEMOFILE_H