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.

174 lines
4.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: An object that is used, when modifying the state of the document,
  4. // to collect information about what objects changed and how they changed.
  5. // This aggregate info is then passed to CMapDoc::UpdateObjects which performs
  6. // post processing and view updates.
  7. //
  8. // $NoKeywords: $
  9. //=============================================================================//
  10. //-----------------------------------------------------------------------------
  11. // Purpose: Iterates the list of updated objects.
  12. //-----------------------------------------------------------------------------
  13. POSITION CUpdateHint::GetHeadPosition(int nIndex)
  14. {
  15. return(m_NotifyList[nIndex].Objects.GetHeadPosition());
  16. }
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Iterates the list of updated objects.
  19. //-----------------------------------------------------------------------------
  20. CMapClass *CUpdateHint::GetNext(POSITION &pos)
  21. {
  22. return(m_NotifyList[nIndex].Objects.GetNext(pos));
  23. }
  24. //-----------------------------------------------------------------------------
  25. // Purpose: Returns the notification code for this update.
  26. //-----------------------------------------------------------------------------
  27. int CUpdateHint::GetNotifyCode(void)
  28. {
  29. return(m_NotifyList[nIndex].nCode);
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Returns the current update region.
  33. //-----------------------------------------------------------------------------
  34. BoundBox const &CUpdateHint::GetUpdateRegion(void)
  35. {
  36. return(m_UpdateRegion);
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose: Prepares to update an object.
  40. // Input : pObject - Object that will be updated.
  41. //-----------------------------------------------------------------------------
  42. void CUpdateHint::PreUpdateObject(CMapClass *pObject)
  43. {
  44. if (pObject != NULL)
  45. {
  46. CMapObjectList TempList;
  47. TempList.AddTail(pObject);
  48. PreUpdateObjects(&TempList);
  49. }
  50. else
  51. {
  52. PreUpdateObjects(NULL);
  53. }
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose: Prepares to update the list of objects.
  57. // Input : pObjects - List of objects, NULL if none.
  58. //-----------------------------------------------------------------------------
  59. void CUpdateHint::PreUpdateObjects(CMapObjectList *pObjects)
  60. {
  61. if (pObjects != NULL)
  62. {
  63. POSITION pos = pObjects->GetHeadPosition();
  64. while (pos != NULL)
  65. {
  66. CMapClass *pObject = pObjects->GetNext(pos);
  67. if (pObject != NULL)
  68. {
  69. m_UpdateRegion.UpdateBounds(pObject);
  70. }
  71. }
  72. }
  73. }
  74. //-----------------------------------------------------------------------------
  75. // Purpose: Prepares to update an object.
  76. // Input : pObject - Object that will be updated.
  77. //-----------------------------------------------------------------------------
  78. void CUpdateHint::PostUpdateObject(CMapClass *pObject, int nNotifyCode)
  79. {
  80. if (pObject != NULL)
  81. {
  82. CMapObjectList TempList;
  83. TempList.AddTail(pObject);
  84. PostUpdateObjects(&TempList, nNotifyCode);
  85. }
  86. else
  87. {
  88. PostUpdateObjects(NULL, nNotifyCode);
  89. }
  90. }
  91. //-----------------------------------------------------------------------------
  92. // Purpose: Prepares to update the list of objects.
  93. // Input : pObjects - List of objects, NULL if none.
  94. //-----------------------------------------------------------------------------
  95. void CUpdateHint::PostUpdateObjects(CMapObjectList *pObjects, int nNotifyCode)
  96. {
  97. int nIndex = 0;
  98. bool bFound = false;
  99. while (!bFound && (nIndex < m_ListEntries))
  100. {
  101. if (m_NotifyList[nIndex].nCode == nNotifyCode)
  102. {
  103. bFound = true;
  104. }
  105. else
  106. {
  107. nIndex++;
  108. }
  109. }
  110. if ((!bFound && (nIndex < MAX_NOTIFY_CODES))
  111. {
  112. if (nIndex < MAX_NOTIFY_CODES)
  113. {
  114. m_ListEntries++;
  115. }
  116. }
  117. else
  118. {
  119. ASSERT(nIndex < MAX_NOTIFY_CODES);
  120. return;
  121. }
  122. m_NotifyList[nIndex].Objects.AddTail(pObjects);
  123. if (pObjects != NULL)
  124. {
  125. POSITION pos = pObjects->GetHeadPosition();
  126. while (pos != NULL)
  127. {
  128. CMapClass *pObject = pObjects->GetNext(pos);
  129. if (pObject != NULL)
  130. {
  131. m_UpdateRegion.UpdateBounds(pObject);
  132. }
  133. }
  134. }
  135. }
  136. //-----------------------------------------------------------------------------
  137. // Purpose:
  138. //-----------------------------------------------------------------------------
  139. void CUpdateHint::Reset(void)
  140. {
  141. m_Objects.RemoveAll();
  142. m_UpdateRegion.ResetBounds();
  143. }
  144. //-----------------------------------------------------------------------------
  145. // Purpose:
  146. //-----------------------------------------------------------------------------
  147. void CUpdateHint::UpdateBounds(BoundBox &bbox)
  148. {
  149. m_UpdateRegion.UpdateBounds(&bbox);
  150. }