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.

290 lines
5.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: VCR mode records a client's game and allows you to
  4. // play it back and reproduce it exactly. When playing it back, nothing
  5. // is simulated on the server, but all server packets are recorded.
  6. //
  7. // Most of the VCR mode functionality is accomplished through hooks
  8. // called at various points in the engine.
  9. //
  10. // $NoKeywords: $
  11. //=============================================================================
  12. #include "xbox/xbox_platform.h"
  13. #include "xbox/xbox_win32stubs.h"
  14. #include <time.h>
  15. #include <assert.h>
  16. #include <stdio.h>
  17. #include <stdarg.h>
  18. #include <string.h>
  19. #include "tier0/vcrmode.h"
  20. #include "tier0/dbg.h"
  21. #define VCRFILE_VERSION 2
  22. #define VCR_RuntimeAssert(x) VCR_RuntimeAssertFn(x, #x)
  23. // ---------------------------------------------------------------------- //
  24. // Internal functions.
  25. // ---------------------------------------------------------------------- //
  26. static void VCR_Error( const char *pFormat, ... )
  27. {
  28. }
  29. static void VCR_RuntimeAssertFn(int bAssert, char const *pStr)
  30. {
  31. }
  32. static void VCR_Read(void *pDest, int size)
  33. {
  34. }
  35. template<class T>
  36. static void VCR_ReadVal(T &val)
  37. {
  38. VCR_Read(&val, sizeof(val));
  39. }
  40. static void VCR_Write(void const *pSrc, int size)
  41. {
  42. }
  43. template<class T>
  44. static void VCR_WriteVal(T &val)
  45. {
  46. }
  47. // Hook from ExtendedTrace.cpp
  48. bool g_bTraceRead = false;
  49. void OutputDebugStringFormat( const char *pMsg, ... )
  50. {
  51. }
  52. static VCREvent VCR_ReadEvent()
  53. {
  54. return (VCREvent)-1;
  55. }
  56. static void VCR_WriteEvent(VCREvent event)
  57. {
  58. }
  59. static void VCR_IncrementEvent()
  60. {
  61. }
  62. static void VCR_Event(VCREvent type)
  63. {
  64. }
  65. // ---------------------------------------------------------------------- //
  66. // VCR trace interface.
  67. // ---------------------------------------------------------------------- //
  68. class CVCRTrace : public IVCRTrace
  69. {
  70. public:
  71. virtual VCREvent ReadEvent()
  72. {
  73. return VCR_ReadEvent();
  74. }
  75. virtual void Read( void *pDest, int size )
  76. {
  77. VCR_Read( pDest, size );
  78. }
  79. };
  80. static CVCRTrace g_VCRTrace;
  81. // ---------------------------------------------------------------------- //
  82. // VCR interface.
  83. // ---------------------------------------------------------------------- //
  84. static int VCR_Start( char const *pFilename, bool bRecord, IVCRHelpers *pHelpers )
  85. {
  86. return 0;
  87. }
  88. static void VCR_End()
  89. {
  90. }
  91. static IVCRTrace* VCR_GetVCRTraceInterface()
  92. {
  93. return 0;
  94. }
  95. static VCRMode VCR_GetMode()
  96. {
  97. return VCR_Disabled;
  98. }
  99. static void VCR_SetEnabled(int bEnabled)
  100. {
  101. }
  102. static void VCR_SyncToken(char const *pToken)
  103. {
  104. }
  105. static double VCR_Hook_Sys_FloatTime(double time)
  106. {
  107. return 0;
  108. }
  109. static int VCR_Hook_PeekMessage(
  110. struct tagMSG *msg,
  111. void *hWnd,
  112. unsigned int wMsgFilterMin,
  113. unsigned int wMsgFilterMax,
  114. unsigned int wRemoveMsg
  115. )
  116. {
  117. return 0;
  118. }
  119. void VCR_Hook_RecordGameMsg( unsigned int uMsg, unsigned int wParam, long lParam )
  120. {
  121. }
  122. void VCR_Hook_RecordEndGameMsg()
  123. {
  124. }
  125. bool VCR_Hook_PlaybackGameMsg( unsigned int &uMsg, unsigned int &wParam, long &lParam )
  126. {
  127. return 0;
  128. }
  129. static void VCR_Hook_GetCursorPos(struct tagPOINT *pt)
  130. {
  131. }
  132. static void VCR_Hook_ScreenToClient(void *hWnd, struct tagPOINT *pt)
  133. {
  134. }
  135. static int VCR_Hook_recvfrom(int s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen)
  136. {
  137. return 0;
  138. }
  139. static int VCR_Hook_recv(int s, char *buf, int len, int flags)
  140. {
  141. return 0;
  142. }
  143. static int VCR_Hook_send(int s, const char *buf, int len, int flags)
  144. {
  145. return 0;
  146. }
  147. static void VCR_Hook_Cmd_Exec(char **f)
  148. {
  149. }
  150. static char* VCR_Hook_GetCommandLine()
  151. {
  152. return GetCommandLine();
  153. }
  154. static long VCR_Hook_RegOpenKeyEx( void *hKey, const char *lpSubKey, unsigned long ulOptions, unsigned long samDesired, void *pHKey )
  155. {
  156. return 0;
  157. }
  158. static long VCR_Hook_RegSetValueEx(void *hKey, char const *lpValueName, unsigned long Reserved, unsigned long dwType, unsigned char const *lpData, unsigned long cbData)
  159. {
  160. return 0;
  161. }
  162. static long VCR_Hook_RegQueryValueEx(void *hKey, char const *lpValueName, unsigned long *lpReserved, unsigned long *lpType, unsigned char *lpData, unsigned long *lpcbData)
  163. {
  164. return 0;
  165. }
  166. static long VCR_Hook_RegCreateKeyEx(void *hKey, char const *lpSubKey, unsigned long Reserved, char *lpClass, unsigned long dwOptions,
  167. unsigned long samDesired, void *lpSecurityAttributes, void *phkResult, unsigned long *lpdwDisposition)
  168. {
  169. return 0;
  170. }
  171. static void VCR_Hook_RegCloseKey(void *hKey)
  172. {
  173. }
  174. int VCR_Hook_GetNumberOfConsoleInputEvents( void *hInput, unsigned long *pNumEvents )
  175. {
  176. return 0;
  177. }
  178. int VCR_Hook_ReadConsoleInput( void *hInput, void *pRecs, int nMaxRecs, unsigned long *pNumRead )
  179. {
  180. return 0;
  181. }
  182. void VCR_Hook_LocalTime( struct tm *today )
  183. {
  184. }
  185. short VCR_Hook_GetKeyState( int nVirtKey )
  186. {
  187. return 0;
  188. }
  189. void VCR_GenericRecord( const char *pEventName, const void *pData, int len )
  190. {
  191. }
  192. int VCR_GenericPlayback( const char *pEventName, void *pOutData, int maxLen, bool bForceSameLen )
  193. {
  194. return 0;
  195. }
  196. void VCR_GenericValue( const char *pEventName, void *pData, int maxLen )
  197. {
  198. }
  199. // ---------------------------------------------------------------------- //
  200. // The global VCR interface.
  201. // ---------------------------------------------------------------------- //
  202. VCR_t g_VCR =
  203. {
  204. VCR_Start,
  205. VCR_End,
  206. VCR_GetVCRTraceInterface,
  207. VCR_GetMode,
  208. VCR_SetEnabled,
  209. VCR_SyncToken,
  210. VCR_Hook_Sys_FloatTime,
  211. VCR_Hook_PeekMessage,
  212. VCR_Hook_RecordGameMsg,
  213. VCR_Hook_RecordEndGameMsg,
  214. VCR_Hook_PlaybackGameMsg,
  215. VCR_Hook_recvfrom,
  216. VCR_Hook_GetCursorPos,
  217. VCR_Hook_ScreenToClient,
  218. VCR_Hook_Cmd_Exec,
  219. VCR_Hook_GetCommandLine,
  220. VCR_Hook_RegOpenKeyEx,
  221. VCR_Hook_RegSetValueEx,
  222. VCR_Hook_RegQueryValueEx,
  223. VCR_Hook_RegCreateKeyEx,
  224. VCR_Hook_RegCloseKey,
  225. VCR_Hook_GetNumberOfConsoleInputEvents,
  226. VCR_Hook_ReadConsoleInput,
  227. VCR_Hook_LocalTime,
  228. VCR_Hook_GetKeyState,
  229. VCR_Hook_recv,
  230. VCR_Hook_send,
  231. VCR_GenericRecord,
  232. VCR_GenericPlayback,
  233. VCR_GenericValue
  234. };
  235. VCR_t *g_pVCR = &g_VCR;