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.

160 lines
6.8 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DEMO_H
  8. #define DEMO_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "utlvector.h"
  13. #include "net.h"
  14. #include "demofile/demoformat.h"
  15. #include "netmessages_signon.h"
  16. class CUtlBuffer;
  17. class CDemoFile;
  18. class ServerClass;
  19. class CGameInfo;
  20. struct CDemoPlaybackParameters_t;
  21. struct DemoImportantTick_t;
  22. struct DemoImportantGameEvent_t;
  23. class IDemoStream;
  24. abstract_class IDemoRecorder
  25. {
  26. public:
  27. ~IDemoRecorder() {} // TODO: Should be virtual?
  28. // Notify the demo recorder of the client sign-on state, so it knows whether the
  29. // string tables and entity data are fully populated.
  30. virtual void SetSignonState( SIGNONSTATE state ) = 0;
  31. // Write entity send-tables so we can fix up deltas on later versions of the client
  32. // Note that this usually gets done as part of StartRecording, so it's a bit odd that it's in
  33. // the interface here.
  34. virtual void RecordServerClasses( ServerClass *pClasses ) = 0;
  35. // Recording commands
  36. virtual void RecordMessages( bf_read &data, int bits ) = 0; // add messages to current packet
  37. virtual void RecordPacket( void ) = 0; // packet finished, write all recorded stuff to file
  38. virtual void RecordCommand( const char *cmdstring ) = 0; // record a console command
  39. virtual void RecordUserInput( int cmdnumber ) = 0; // record a user input command
  40. // This function is pretty scary. It relies on the client code explicitly
  41. // versioning the embedded data (which the only client, blob particles, doesn't
  42. // seem to do!)
  43. //
  44. // Also, I am not sure how the callbacks are referenced in cross-version playback.
  45. //
  46. // You should use protocol buffers instead, with RecordMessages(). This way all
  47. // cross-version stuff is handled for you and backwards compatibility is a lot
  48. // simpler.
  49. virtual void RecordCustomData( int iCallbackIndex, const void *pData, size_t iDataLength ) = 0; //record a chunk of custom data
  50. // Notify the demo recorder that an entity is about to teleport, and
  51. // stop it from being interpolated between its old and new positions.
  52. //
  53. // TODO: Shouldn't this specify which entity is being teleported? Currently it seems
  54. // to only do anything in client-recorded demos, and notifies that the current client
  55. // is being teleported. (Also, nobody seems to ever call this function in CSGO, so
  56. // it's hard to verify my assumptions about it!)
  57. virtual void ResetDemoInterpolation() = 0;
  58. // TODO: This doesn't really belong here; different demo objects have different processes
  59. // for handling start/stop recording.
  60. virtual void StartRecording( const char *filename, bool bContinuously ) = 0;
  61. // Called during client disconnect. Should probably be named 'Shutdown' or 'Detach'.
  62. //
  63. // NOTE: There is an unused CGameInfo* parameter here that probably came from DotA2.
  64. // We never define that structure so it is impossible to pass anything aside from NULL.
  65. //
  66. // It seems its purpose is to attach some extra metadata about the game that wasn't
  67. // known at the start of recording to the header of the demo. This lets you populate
  68. // the playback interface with information about when kills happened, towers died, etc.
  69. virtual void StopRecording( const CGameInfo* pGameInfo = NULL ) = 0;
  70. // True between StartRecording and StopRecording
  71. virtual bool IsRecording( void ) = 0;
  72. // This is used by cdll_engine_int to provide an interface to the client's demo
  73. // recorder. However, they don't seem to have any callers through that wrapper.
  74. virtual int GetRecordingTick( void ) = 0;
  75. // These don't seem to be used anywhere, and are probably specific to the type
  76. // of demo being recorded, as opposed to belonging in IDemoRecorder.
  77. //
  78. // TODO: Delete these for real instead of just commenting them.
  79. //
  80. // virtual CDemoFile *GetDemoFile() = 0;
  81. //
  82. // virtual void PauseRecording( void ) = 0;
  83. // virtual void ResumeRecording( void ) = 0;
  84. // This function is especially odd. This is generally handled by StartRecording/
  85. // SetSignonState or something similar to write the initial string tables, and not
  86. // called externally. Updates are handled via the usual string table update
  87. // messages via RecordMessages(). Not sure where it would be used externally!
  88. //
  89. // virtual void RecordStringTables() = 0;
  90. };
  91. abstract_class IDemoPlayer
  92. {
  93. public:
  94. virtual ~IDemoPlayer() {};
  95. virtual IDemoStream *GetDemoStream() = 0;
  96. virtual int GetPlaybackStartTick( void ) = 0;
  97. virtual int GetPlaybackTick( void ) = 0;
  98. // virtual int GetPlaybackDeltaTick( void ) = 0;
  99. // virtual int GetPacketTick( void ) = 0;
  100. virtual bool IsPlayingBack( void ) const = 0; // true if demo loaded and playing back
  101. virtual bool IsPlaybackPaused( void ) const = 0; // true if playback paused
  102. virtual bool IsPlayingTimeDemo( void ) const = 0; // true if playing back in timedemo mode
  103. virtual bool IsSkipping( void ) const = 0; // true, if demo player skipping trough packets
  104. virtual bool CanSkipBackwards( void ) const = 0; // true if demoplayer can skip backwards
  105. virtual void SetPlaybackTimeScale( float timescale ) = 0; // sets playback timescale
  106. virtual float GetPlaybackTimeScale( void ) = 0; // get playback timescale
  107. virtual void PausePlayback( float seconds ) = 0; // pause playback n seconds, -1 = forever
  108. virtual void SkipToTick( int tick, bool bRelative, bool bPause ) = 0; // goto a specific tick, 0 = start, -1 = end
  109. virtual void SkipToImportantTick( const DemoImportantTick_t *pTick ) = 0;
  110. virtual void ResumePlayback( void ) = 0; // resume playback
  111. virtual void StopPlayback( void ) = 0; // stop playback, close file
  112. virtual void InterpolateViewpoint() = 0; // override viewpoint
  113. virtual netpacket_t *ReadPacket( void ) = 0; // read packet from demo file
  114. virtual void ResetDemoInterpolation() = 0;
  115. virtual CDemoPlaybackParameters_t const * GetDemoPlaybackParameters() = 0;
  116. virtual void SetPacketReadSuspended( bool bSuspendPacketReading ) = 0;
  117. virtual void SetImportantEventData( const KeyValues *pData ) = 0;
  118. virtual int FindNextImportantTick( int nCurrentTick, const char *pEventName = NULL ) = 0; // -1 = no next important tick
  119. virtual int FindPreviousImportantTick( int nCurrentTick, const char *pEventName = NULL ) = 0; // -1 = no previous important tick
  120. virtual const DemoImportantTick_t *GetImportantTick( int nIndex ) = 0;
  121. virtual const DemoImportantGameEvent_t *GetImportantGameEvent( const char *pszEventName ) = 0;
  122. virtual void ListImportantTicks( void ) = 0;
  123. virtual void ListHighlightData( void ) = 0;
  124. virtual void SetHighlightXuid( uint64 xuid, bool bLowlights ) = 0;
  125. virtual bool ScanDemo( const char *filename, const char* pszMode ) = 0;
  126. };
  127. #if !defined( DEDICATED )
  128. extern IDemoPlayer *demoplayer; // reference to current demo player
  129. extern IDemoRecorder *demorecorder; // reference to current demo recorder
  130. #endif
  131. #endif // DEMO_H