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.

154 lines
3.9 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "sceneentity_shared.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. ConVar scene_print( "scene_print", "0", FCVAR_REPLICATED, "When playing back a scene, print timing and event info to console." );
  11. ConVar scene_clientflex( "scene_clientflex", "1", FCVAR_REPLICATED, "Do client side flex animation." );
  12. CSceneEventInfo::CSceneEventInfo()
  13. :
  14. m_pEvent( 0 ),
  15. m_pScene( 0 ),
  16. m_pActor( 0 ),
  17. m_hSceneEntity( INVALID_EHANDLE ),
  18. m_bStarted( false ),
  19. m_iLayer( -1 ),
  20. m_iPriority( 0 ),
  21. m_nSequence( 0 ),
  22. m_bIsGesture( false ),
  23. m_flWeight( 0.0f ),
  24. m_hTarget(),
  25. m_bIsMoving( false ),
  26. m_bHasArrived( false ),
  27. m_flInitialYaw( 0.0f ),
  28. m_flTargetYaw( 0.0f ),
  29. m_flFacingYaw( 0.0f ),
  30. m_nType( 0 ),
  31. m_flNext( 0.0f ),
  32. m_bClientSide( false ),
  33. m_pExpHdr( NULL )
  34. {
  35. }
  36. CSceneEventInfo::~CSceneEventInfo()
  37. {
  38. }
  39. //-----------------------------------------------------------------------------
  40. // Purpose:
  41. // Input : *pFormat -
  42. // ... -
  43. // Output : static void
  44. //-----------------------------------------------------------------------------
  45. void Scene_Printf( const char *pFormat, ... )
  46. {
  47. int val = scene_print.GetInt();
  48. if ( !val )
  49. return;
  50. if ( val >= 2 )
  51. {
  52. if ( CBaseEntity::IsServer() && val != 2 )
  53. {
  54. return;
  55. }
  56. else if ( !CBaseEntity::IsServer() && val != 3 )
  57. {
  58. return;
  59. }
  60. }
  61. va_list marker;
  62. char msg[8192];
  63. va_start(marker, pFormat);
  64. Q_vsnprintf(msg, sizeof(msg), pFormat, marker);
  65. va_end(marker);
  66. Msg( "%8.3f[%d] %s: %s", gpGlobals->curtime, gpGlobals->tickcount, CBaseEntity::IsServer() ? "sv" : "cl", msg );
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Purpose:
  70. // Output : const char
  71. //-----------------------------------------------------------------------------
  72. const char *CSceneTokenProcessor::CurrentToken( void )
  73. {
  74. return m_szToken;
  75. }
  76. //-----------------------------------------------------------------------------
  77. // Purpose:
  78. // Input : crossline -
  79. // Output : Returns true on success, false on failure.
  80. //-----------------------------------------------------------------------------
  81. bool CSceneTokenProcessor::GetToken( bool crossline )
  82. {
  83. // NOTE: crossline is ignored here, may need to implement if needed
  84. m_pBuffer = engine->ParseFile( m_pBuffer, m_szToken, sizeof( m_szToken ) );
  85. if ( 0 <= (int)strlen( m_szToken ) )
  86. return true;
  87. return false;
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose:
  91. // Output : Returns true on success, false on failure.
  92. //-----------------------------------------------------------------------------
  93. bool CSceneTokenProcessor::TokenAvailable( void )
  94. {
  95. char const *search_p = m_pBuffer;
  96. while ( *search_p <= 32)
  97. {
  98. if (*search_p == '\n')
  99. return false;
  100. search_p++;
  101. if ( !*search_p )
  102. return false;
  103. }
  104. if (*search_p == ';' || *search_p == '#' || // semicolon and # is comment field
  105. (*search_p == '/' && *((search_p)+1) == '/')) // also make // a comment field
  106. return false;
  107. return true;
  108. }
  109. //-----------------------------------------------------------------------------
  110. // Purpose:
  111. // Input : *fmt -
  112. // ... -
  113. //-----------------------------------------------------------------------------
  114. void CSceneTokenProcessor::Error( const char *fmt, ... )
  115. {
  116. char string[ 2048 ];
  117. va_list argptr;
  118. va_start( argptr, fmt );
  119. Q_vsnprintf( string, sizeof(string), fmt, argptr );
  120. va_end( argptr );
  121. Warning( "%s", string );
  122. Assert(0);
  123. }
  124. //-----------------------------------------------------------------------------
  125. // Purpose:
  126. // Input : *buffer -
  127. //-----------------------------------------------------------------------------
  128. void CSceneTokenProcessor::SetBuffer( char *buffer )
  129. {
  130. m_pBuffer = buffer;
  131. }
  132. CSceneTokenProcessor g_TokenProcessor;