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.

104 lines
3.1 KiB

  1. //===== Copyright � 1996-2005, 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. //#ifdef _X360
  12. #define DEMO_FILE_UTLBUFFER 1
  13. //#endif
  14. #include "demo.h"
  15. #ifdef DEMO_FILE_UTLBUFFER
  16. #include "tier2/utlstreambuffer.h"
  17. #else
  18. #include <filesystem.h>
  19. #endif
  20. #include "tier1/bitbuf.h"
  21. #include "demostream.h"
  22. //-----------------------------------------------------------------------------
  23. // Forward declarations
  24. //-----------------------------------------------------------------------------
  25. class IDemoBuffer;
  26. struct CDemoPlaybackParameters_t;
  27. //-----------------------------------------------------------------------------
  28. // Demo file
  29. //-----------------------------------------------------------------------------
  30. class CDemoFile : public IDemoStream
  31. {
  32. public:
  33. CDemoFile();
  34. ~CDemoFile();
  35. bool Open(const char *name, bool bReadOnly, bool bMemoryBuffer = false);
  36. bool IsOpen();
  37. void Close();
  38. // Functions specifically for in-memory demo file
  39. void NotifySignonComplete();
  40. void NotifyBeginFrame();
  41. void NotifyEndFrame();
  42. void DumpBufferToFile( char const* pFilename, const demoheader_t &header );
  43. void UpdateStartTick( int& nStartTick );
  44. void SeekTo( int position, bool bRead );
  45. unsigned int GetCurPos( bool bRead );
  46. int GetSize();
  47. void WriteRawData( const char *buffer, int length );
  48. int ReadRawData( char *buffer, int length );
  49. void WriteSequenceInfo(int nSeqNrIn, int nSeqNrOutAck);
  50. void ReadSequenceInfo(int &nSeqNrIn, int &nSeqNrOutAck);
  51. void WriteCmdInfo( democmdinfo_t& info );
  52. void ReadCmdInfo( democmdinfo_t& info );
  53. void WriteCmdHeader( unsigned char cmd, int tick, int nPlayerSlot );
  54. void ReadCmdHeader( unsigned char& cmd, int& tick, int &nPlayerSlot );
  55. void WriteConsoleCommand( const char *cmd, int tick, int nPlayerSlot );
  56. const char *ReadConsoleCommand( void );
  57. void WriteNetworkDataTables( bf_write *buf, int tick );
  58. int ReadNetworkDataTables( bf_read *buf );
  59. void WriteStringTables( bf_write *buf, int tick );
  60. int ReadStringTables( bf_read *buf );
  61. void WriteUserCmd( int cmdnumber, const char *buffer, unsigned char bytes, int tick, int nPlayerSlot );
  62. int ReadUserCmd( char *buffer, int &size );
  63. void WriteCustomData( int iCallbackIndex, const void *pData, size_t iDataSize, int tick);
  64. int ReadCustomData( int *pCallbackIndex, uint8 **ppDataChunk ); //returns message size, both parameters are outputs.
  65. void WriteDemoHeader();
  66. demoheader_t * ReadDemoHeader( CDemoPlaybackParameters_t const *pPlaybackParameters );
  67. void WriteFileBytes( FileHandle_t fh, int length );
  68. virtual const char* GetUrl( void ) OVERRIDE { return m_szFileName; }
  69. virtual float GetTicksPerSecond() OVERRIDE;
  70. virtual float GetTicksPerFrame() OVERRIDE;
  71. virtual int GetTotalTicks( void ) OVERRIDE;
  72. public:
  73. char m_szFileName[MAX_PATH]; //name of current demo file
  74. demoheader_t m_DemoHeader; //general demo info
  75. private:
  76. IDemoBuffer *m_pBuffer;
  77. };
  78. #define DEMO_RECORD_BUFFER_SIZE 2*1024*1024 // temp buffer big enough to fit both string tables and server classes
  79. #endif // DEMOFILE_H