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.

108 lines
1.9 KiB

  1. //========= Copyright 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. class CChangeFrameList : public IChangeFrameList
  14. {
  15. public:
  16. void Init( int nProperties, int iCurTick )
  17. {
  18. m_ChangeTicks.SetSize( nProperties );
  19. for ( int i=0; i < nProperties; i++ )
  20. m_ChangeTicks[i] = iCurTick;
  21. }
  22. // IChangeFrameList implementation.
  23. public:
  24. virtual void Release()
  25. {
  26. delete this;
  27. }
  28. virtual IChangeFrameList* Copy()
  29. {
  30. CChangeFrameList *pRet = new CChangeFrameList;
  31. int numProps = m_ChangeTicks.Count();
  32. pRet->m_ChangeTicks.SetSize( numProps );
  33. for ( int i=0; i < numProps; i++ )
  34. {
  35. pRet->m_ChangeTicks[ i ] = m_ChangeTicks[ i ];
  36. }
  37. return pRet;
  38. }
  39. virtual int GetNumProps()
  40. {
  41. return m_ChangeTicks.Count();
  42. }
  43. virtual void SetChangeTick( const int *pPropIndices, int nPropIndices, const int iTick )
  44. {
  45. for ( int i=0; i < nPropIndices; i++ )
  46. {
  47. m_ChangeTicks[ pPropIndices[i] ] = iTick;
  48. }
  49. }
  50. virtual int GetPropsChangedAfterTick( int iTick, int *iOutProps, int nMaxOutProps )
  51. {
  52. int nOutProps = 0;
  53. int c = m_ChangeTicks.Count();
  54. Assert( c <= nMaxOutProps );
  55. for ( int i=0; i < c; i++ )
  56. {
  57. if ( m_ChangeTicks[i] > iTick )
  58. {
  59. iOutProps[nOutProps] = i;
  60. ++nOutProps;
  61. }
  62. }
  63. return nOutProps;
  64. }
  65. // IChangeFrameList implementation.
  66. protected:
  67. virtual ~CChangeFrameList()
  68. {
  69. }
  70. private:
  71. // Change frames for each property.
  72. CUtlVector<int> m_ChangeTicks;
  73. };
  74. IChangeFrameList* AllocChangeFrameList( int nProperties, int iCurTick )
  75. {
  76. CChangeFrameList *pRet = new CChangeFrameList;
  77. pRet->Init( nProperties, iCurTick);
  78. return pRet;
  79. }