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.

201 lines
6.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Core Temp Entity client implementation.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "c_basetempentity.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. IMPLEMENT_CLIENTCLASS(C_BaseTempEntity, DT_BaseTempEntity, CBaseTempEntity);
  12. BEGIN_RECV_TABLE_NOBASE(C_BaseTempEntity, DT_BaseTempEntity)
  13. END_RECV_TABLE()
  14. // Global list of temp entity classes
  15. C_BaseTempEntity *C_BaseTempEntity::s_pTempEntities = NULL;
  16. // Global list of dynamic temp entities
  17. C_BaseTempEntity *C_BaseTempEntity::s_pDynamicEntities = NULL;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Returns head of list
  20. // Output : CBaseTempEntity * -- head of list
  21. //-----------------------------------------------------------------------------
  22. C_BaseTempEntity *C_BaseTempEntity::GetDynamicList( void )
  23. {
  24. return s_pDynamicEntities;
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Returns head of list
  28. // Output : CBaseTempEntity * -- head of list
  29. //-----------------------------------------------------------------------------
  30. C_BaseTempEntity *C_BaseTempEntity::GetList( void )
  31. {
  32. return s_pTempEntities;
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. // Output :
  37. //-----------------------------------------------------------------------------
  38. C_BaseTempEntity::C_BaseTempEntity( void )
  39. {
  40. // Add to list
  41. m_pNext = s_pTempEntities;
  42. s_pTempEntities = this;
  43. m_pNextDynamic = NULL;
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. // Output :
  48. //-----------------------------------------------------------------------------
  49. C_BaseTempEntity::~C_BaseTempEntity( void )
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose: Get next temp ent in chain
  54. // Output : CBaseTempEntity *
  55. //-----------------------------------------------------------------------------
  56. C_BaseTempEntity *C_BaseTempEntity::GetNext( void )
  57. {
  58. return m_pNext;
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose: Get next temp ent in chain
  62. // Output : CBaseTempEntity *
  63. //-----------------------------------------------------------------------------
  64. C_BaseTempEntity *C_BaseTempEntity::GetNextDynamic( void )
  65. {
  66. return m_pNextDynamic;
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Purpose:
  70. //-----------------------------------------------------------------------------
  71. void C_BaseTempEntity::Precache( void )
  72. {
  73. // Nothing...
  74. }
  75. //-----------------------------------------------------------------------------
  76. // Purpose: Called at startup to allow temp entities to precache any models/sounds that they need
  77. //-----------------------------------------------------------------------------
  78. void C_BaseTempEntity::PrecacheTempEnts( void )
  79. {
  80. C_BaseTempEntity *te = GetList();
  81. while ( te )
  82. {
  83. te->Precache();
  84. te = te->GetNext();
  85. }
  86. }
  87. //-----------------------------------------------------------------------------
  88. // Purpose: Called at startup and level load to clear out leftover temp entities
  89. //-----------------------------------------------------------------------------
  90. void C_BaseTempEntity::ClearDynamicTempEnts( void )
  91. {
  92. C_BaseTempEntity *next;
  93. C_BaseTempEntity *te = s_pDynamicEntities;
  94. while ( te )
  95. {
  96. next = te->GetNextDynamic();
  97. delete te;
  98. te = next;
  99. }
  100. s_pDynamicEntities = NULL;
  101. }
  102. //-----------------------------------------------------------------------------
  103. // Purpose: Called at startup and level load to clear out leftover temp entities
  104. //-----------------------------------------------------------------------------
  105. void C_BaseTempEntity::CheckDynamicTempEnts( void )
  106. {
  107. C_BaseTempEntity *next, *newlist = NULL;
  108. C_BaseTempEntity *te = s_pDynamicEntities;
  109. while ( te )
  110. {
  111. next = te->GetNextDynamic();
  112. if ( te->ShouldDestroy() )
  113. {
  114. delete te;
  115. }
  116. else
  117. {
  118. te->m_pNextDynamic = newlist;
  119. newlist = te;
  120. }
  121. te = next;
  122. }
  123. s_pDynamicEntities = newlist;
  124. }
  125. //-----------------------------------------------------------------------------
  126. // Purpose: Dynamic/non-singleton temp entities are initialized by
  127. // calling into here. They should be added to a list of C_BaseTempEntities so
  128. // that their memory can be deallocated appropriately.
  129. // Input : *pEnt -
  130. // Output : Returns true on success, false on failure.
  131. //-----------------------------------------------------------------------------
  132. bool C_BaseTempEntity::Init( int entnum, int iSerialNum )
  133. {
  134. if ( entnum != -1 )
  135. {
  136. Assert( 0 );
  137. }
  138. // Link into dynamic entity list
  139. m_pNextDynamic = s_pDynamicEntities;
  140. s_pDynamicEntities = this;
  141. return true;
  142. }
  143. void C_BaseTempEntity::Release()
  144. {
  145. Assert( !"C_BaseTempEntity::Release should never be called" );
  146. }
  147. void C_BaseTempEntity::NotifyShouldTransmit( ShouldTransmitState_t state )
  148. {
  149. }
  150. //-----------------------------------------------------------------------------
  151. // Purpose:
  152. // Input : bool -
  153. //-----------------------------------------------------------------------------
  154. void C_BaseTempEntity::PreDataUpdate( DataUpdateType_t updateType )
  155. {
  156. // TE's may or may not implement this
  157. }
  158. int C_BaseTempEntity::entindex( void ) const { Assert( 0 ); return 0; }
  159. void C_BaseTempEntity::PostDataUpdate( DataUpdateType_t updateType ) { Assert( 0 ); }
  160. void C_BaseTempEntity::OnPreDataChanged( DataUpdateType_t updateType ) { Assert( 0 ); }
  161. void C_BaseTempEntity::OnDataChanged( DataUpdateType_t updateType ) { Assert( 0 ); }
  162. void C_BaseTempEntity::SetDormant( bool bDormant ) { Assert( 0 ); }
  163. bool C_BaseTempEntity::IsDormant( void ) const { Assert( 0 ); return false; };
  164. void C_BaseTempEntity::ReceiveMessage( int classID, bf_read &msg ) { Assert( 0 ); }
  165. void C_BaseTempEntity::SetDestroyedOnRecreateEntities( void ) { Assert(0); }
  166. void* C_BaseTempEntity::GetDataTableBasePtr()
  167. {
  168. return this;
  169. }