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.

63 lines
1.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "basetypes.h"
  8. #include "changeframelist.h"
  9. #include "dt.h"
  10. #include "utlvector.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //-----------------------------------------------------------------------------
  14. DEFINE_FIXEDSIZE_ALLOCATOR_MT( CChangeFrameList, 2048, CUtlMemoryPool::GROW_FAST );
  15. //-----------------------------------------------------------------------------
  16. CChangeFrameList::CChangeFrameList( int nProperties, int iCurTick )
  17. {
  18. //determine how many buckets we need for our properties
  19. int nNumBuckets = ( nProperties + knBucketSize - 1 ) / knBucketSize;
  20. m_nNumProps = nProperties;
  21. m_ChangeTicks.SetCount( nProperties + nNumBuckets );
  22. m_ChangeTicks.FillWithValue( iCurTick );
  23. }
  24. CChangeFrameList::~CChangeFrameList()
  25. {
  26. }
  27. void CChangeFrameList::Release()
  28. {
  29. delete this;
  30. }
  31. CChangeFrameList::CChangeFrameList( const CChangeFrameList &rhs )
  32. {
  33. m_ChangeTicks = rhs.m_ChangeTicks;
  34. m_nNumProps = rhs.m_nNumProps;
  35. }
  36. CChangeFrameList *CChangeFrameList::Copy()
  37. {
  38. CChangeFrameList *pRet = new CChangeFrameList( *this );
  39. return pRet;
  40. }
  41. void CChangeFrameList::SetChangeTick( const int* RESTRICT pProps, int nNumProps, const int iTick )
  42. {
  43. //avoid loads inside the array by the compiler thinking they could overlap
  44. int* pBuckets = m_ChangeTicks.Base() + m_nNumProps;
  45. for ( int i=0; i < nNumProps; i++ )
  46. {
  47. //update our tick, and the parent bucket for the tick
  48. m_ChangeTicks[ pProps[i] ] = iTick;
  49. pBuckets[ pProps[i] / knBucketSize ] = iTick;
  50. }
  51. }