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.

162 lines
5.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "effect_dispatch_data.h"
  9. #include "coordsize.h"
  10. #ifdef CLIENT_DLL
  11. #include "cliententitylist.h"
  12. #endif
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. #define SUBINCH_PRECISION 3
  16. // Note, must match common/qlimits.h!!!
  17. // Must have this value in sync(-1) with qlimits.h and const.h
  18. #define MAX_MODEL_INDEX_BITS 12
  19. #ifdef CLIENT_DLL
  20. #include "dt_recv.h"
  21. static void RecvProxy_EntIndex( const CRecvProxyData *pData, void *pStruct, void *pOut )
  22. {
  23. int nEntIndex = pData->m_Value.m_Int;
  24. ((CEffectData*)pStruct)->m_hEntity = (nEntIndex < 0) ? INVALID_EHANDLE : ClientEntityList().EntIndexToHandle( nEntIndex );
  25. }
  26. BEGIN_RECV_TABLE_NOBASE( CEffectData, DT_EffectData )
  27. RecvPropFloat( RECVINFO( m_vOrigin.x ) ),
  28. RecvPropFloat( RECVINFO( m_vOrigin.y ) ),
  29. RecvPropFloat( RECVINFO( m_vOrigin.z ) ),
  30. RecvPropFloat( RECVINFO( m_vStart.x ) ),
  31. RecvPropFloat( RECVINFO( m_vStart.y ) ),
  32. RecvPropFloat( RECVINFO( m_vStart.z ) ),
  33. RecvPropQAngles( RECVINFO( m_vAngles ) ),
  34. RecvPropVector( RECVINFO( m_vNormal ) ),
  35. RecvPropInt( RECVINFO( m_fFlags ) ),
  36. RecvPropFloat( RECVINFO( m_flMagnitude ) ),
  37. RecvPropFloat( RECVINFO( m_flScale ) ),
  38. RecvPropInt( RECVINFO( m_nAttachmentIndex ) ),
  39. RecvPropIntWithMinusOneFlag( RECVINFO( m_nSurfaceProp ), RecvProxy_ShortSubOne ),
  40. RecvPropInt( RECVINFO( m_iEffectName ) ),
  41. RecvPropInt( RECVINFO( m_nMaterial ) ),
  42. RecvPropInt( RECVINFO( m_nDamageType ) ),
  43. RecvPropInt( RECVINFO( m_nHitBox ) ),
  44. RecvPropInt( "entindex", 0, SIZEOF_IGNORE, 0, RecvProxy_EntIndex ),
  45. RecvPropInt( RECVINFO( m_nOtherEntIndex ) ),
  46. RecvPropInt( RECVINFO( m_nColor ) ),
  47. RecvPropFloat( RECVINFO( m_flRadius ) ),
  48. RecvPropBool( RECVINFO( m_bPositionsAreRelativeToEntity ) ),
  49. END_RECV_TABLE()
  50. #else
  51. #include "dt_send.h"
  52. BEGIN_SEND_TABLE_NOBASE( CEffectData, DT_EffectData )
  53. // Everything uses _NOCHECK here since this is not an entity and we don't need
  54. // the functionality of CNetworkVars.
  55. // Get half-inch precision here.
  56. #ifdef HL2_DLL
  57. SendPropFloat( SENDINFO_NOCHECK( m_vOrigin.x ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  58. SendPropFloat( SENDINFO_NOCHECK( m_vOrigin.y ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  59. SendPropFloat( SENDINFO_NOCHECK( m_vOrigin.z ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  60. SendPropFloat( SENDINFO_NOCHECK( m_vStart.x ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  61. SendPropFloat( SENDINFO_NOCHECK( m_vStart.y ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  62. SendPropFloat( SENDINFO_NOCHECK( m_vStart.z ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  63. #else
  64. SendPropFloat( SENDINFO_NOCHECK( m_vOrigin.x ), -1, SPROP_COORD_MP_INTEGRAL ),
  65. SendPropFloat( SENDINFO_NOCHECK( m_vOrigin.y ), -1, SPROP_COORD_MP_INTEGRAL ),
  66. SendPropFloat( SENDINFO_NOCHECK( m_vOrigin.z ), -1, SPROP_COORD_MP_INTEGRAL ),
  67. SendPropFloat( SENDINFO_NOCHECK( m_vStart.x ), -1, SPROP_COORD_MP_INTEGRAL ),
  68. SendPropFloat( SENDINFO_NOCHECK( m_vStart.y ), -1, SPROP_COORD_MP_INTEGRAL ),
  69. SendPropFloat( SENDINFO_NOCHECK( m_vStart.z ), -1, SPROP_COORD_MP_INTEGRAL ),
  70. #endif
  71. SendPropQAngles( SENDINFO_NOCHECK( m_vAngles ), 7 ),
  72. #if defined( TF_DLL )
  73. SendPropVector( SENDINFO_NOCHECK( m_vNormal ), 6, 0, -1.0f, 1.0f ),
  74. #else
  75. SendPropVector( SENDINFO_NOCHECK( m_vNormal ), 0, SPROP_NORMAL ),
  76. #endif
  77. SendPropInt( SENDINFO_NOCHECK( m_fFlags ), MAX_EFFECT_FLAG_BITS, SPROP_UNSIGNED ),
  78. SendPropFloat( SENDINFO_NOCHECK( m_flMagnitude ), 12, SPROP_ROUNDDOWN, 0.0f, 1023.0f ),
  79. SendPropFloat( SENDINFO_NOCHECK( m_flScale ), 0, SPROP_NOSCALE ),
  80. SendPropInt( SENDINFO_NOCHECK( m_nAttachmentIndex ), 5 ),
  81. SendPropIntWithMinusOneFlag( SENDINFO_NOCHECK( m_nSurfaceProp ), 8, SendProxy_ShortAddOne ),
  82. SendPropInt( SENDINFO_NOCHECK( m_iEffectName ), MAX_EFFECT_DISPATCH_STRING_BITS, SPROP_UNSIGNED ),
  83. SendPropInt( SENDINFO_NOCHECK( m_nMaterial ), MAX_MODEL_INDEX_BITS, SPROP_UNSIGNED ),
  84. SendPropInt( SENDINFO_NOCHECK( m_nDamageType ), 32, SPROP_UNSIGNED ),
  85. SendPropInt( SENDINFO_NOCHECK( m_nHitBox ), 11, SPROP_UNSIGNED ),
  86. SendPropInt( SENDINFO_NAME( m_nEntIndex, entindex ), MAX_EDICT_BITS, SPROP_UNSIGNED ),
  87. SendPropInt( SENDINFO_NOCHECK( m_nOtherEntIndex ), MAX_EDICT_BITS, SPROP_UNSIGNED ),
  88. SendPropInt( SENDINFO_NOCHECK( m_nColor ), 8, SPROP_UNSIGNED ),
  89. SendPropFloat( SENDINFO_NOCHECK( m_flRadius ), 10, SPROP_ROUNDDOWN, 0.0f, 1023.0f ),
  90. SendPropBool( SENDINFO_NOCHECK( m_bPositionsAreRelativeToEntity ) ),
  91. END_SEND_TABLE()
  92. #endif
  93. #ifdef CLIENT_DLL
  94. IClientRenderable *CEffectData::GetRenderable() const
  95. {
  96. return ClientEntityList().GetClientRenderableFromHandle( m_hEntity );
  97. }
  98. C_BaseEntity *CEffectData::GetEntity() const
  99. {
  100. return ClientEntityList().GetBaseEntityFromHandle( m_hEntity );
  101. }
  102. int CEffectData::entindex() const
  103. {
  104. C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( m_hEntity );
  105. return pEnt ? pEnt->entindex() : -1;
  106. }
  107. #endif
  108. #ifdef CLIENT_DLL
  109. bool g_bSuppressParticleEffects = false;
  110. bool SuppressingParticleEffects()
  111. {
  112. return g_bSuppressParticleEffects;
  113. }
  114. void SuppressParticleEffects( bool bSuppress )
  115. {
  116. g_bSuppressParticleEffects = bSuppress;
  117. }
  118. #endif