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.

93 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "cl_renderqueue.h"
  5. // memdbgon must be the last include file in a .cpp file!!!
  6. #include "tier0/memdbgon.h"
  7. //----------------------------------------------------------------------------------------
  8. CRenderQueue::CRenderQueue()
  9. {
  10. }
  11. CRenderQueue::~CRenderQueue()
  12. {
  13. Clear();
  14. }
  15. void CRenderQueue::Add( ReplayHandle_t hReplay, int iPerformance )
  16. {
  17. RenderInfo_t *pEntry = new RenderInfo_t;
  18. pEntry->m_hReplay = hReplay;
  19. pEntry->m_iPerformance = iPerformance;
  20. m_vecQueue.AddToTail( pEntry );
  21. }
  22. void CRenderQueue::Remove( ReplayHandle_t hReplay, int iPerformance )
  23. {
  24. RenderInfo_t *pEntry = Find( hReplay, iPerformance );
  25. if ( pEntry )
  26. {
  27. m_vecQueue.FindAndRemove( pEntry );
  28. delete pEntry;
  29. }
  30. }
  31. void CRenderQueue::Clear()
  32. {
  33. m_vecQueue.PurgeAndDeleteElements();
  34. }
  35. int CRenderQueue::GetCount() const
  36. {
  37. return m_vecQueue.Count();
  38. }
  39. bool CRenderQueue::GetEntryData( int iIndex, ReplayHandle_t *pHandleOut, int *pPerformanceOut ) const
  40. {
  41. if ( iIndex < 0 || iIndex >= GetCount() )
  42. {
  43. AssertMsg( 0, "Request for replay render queue data is out of bounds!" );
  44. Warning( "Request for replay render queue data is out of bounds!" );
  45. return false;
  46. }
  47. if ( !pHandleOut || !pPerformanceOut )
  48. {
  49. AssertMsg( 0, "Bad parameters" );
  50. return false;
  51. }
  52. const RenderInfo_t *pEntry = m_vecQueue[ iIndex ];
  53. *pHandleOut = pEntry->m_hReplay;
  54. *pPerformanceOut = pEntry->m_iPerformance;
  55. return true;
  56. }
  57. bool CRenderQueue::IsInQueue( ReplayHandle_t hReplay, int iPerformance ) const
  58. {
  59. return Find( hReplay, iPerformance ) != NULL;
  60. }
  61. CRenderQueue::RenderInfo_t *CRenderQueue::Find( ReplayHandle_t hReplay, int iPerformance )
  62. {
  63. FOR_EACH_VEC( m_vecQueue, i )
  64. {
  65. RenderInfo_t *pEntry = m_vecQueue[ i ];
  66. if ( pEntry->m_hReplay == hReplay && pEntry->m_iPerformance == iPerformance )
  67. return pEntry;
  68. }
  69. return NULL;
  70. }
  71. const CRenderQueue::RenderInfo_t *CRenderQueue::Find( ReplayHandle_t hReplay, int iPerformance ) const
  72. {
  73. return const_cast< CRenderQueue * >( this )->Find( hReplay, iPerformance );
  74. }
  75. //----------------------------------------------------------------------------------------