diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/updatehint.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'hammer/updatehint.cpp')
| -rw-r--r-- | hammer/updatehint.cpp | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/hammer/updatehint.cpp b/hammer/updatehint.cpp new file mode 100644 index 0000000..1017356 --- /dev/null +++ b/hammer/updatehint.cpp @@ -0,0 +1,174 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: An object that is used, when modifying the state of the document, +// to collect information about what objects changed and how they changed. +// This aggregate info is then passed to CMapDoc::UpdateObjects which performs +// post processing and view updates. +// +// $NoKeywords: $ +//=============================================================================// + + +//----------------------------------------------------------------------------- +// Purpose: Iterates the list of updated objects. +//----------------------------------------------------------------------------- +POSITION CUpdateHint::GetHeadPosition(int nIndex) +{ + return(m_NotifyList[nIndex].Objects.GetHeadPosition()); +} + + +//----------------------------------------------------------------------------- +// Purpose: Iterates the list of updated objects. +//----------------------------------------------------------------------------- +CMapClass *CUpdateHint::GetNext(POSITION &pos) +{ + return(m_NotifyList[nIndex].Objects.GetNext(pos)); +} + + +//----------------------------------------------------------------------------- +// Purpose: Returns the notification code for this update. +//----------------------------------------------------------------------------- +int CUpdateHint::GetNotifyCode(void) +{ + return(m_NotifyList[nIndex].nCode); +} + + +//----------------------------------------------------------------------------- +// Purpose: Returns the current update region. +//----------------------------------------------------------------------------- +BoundBox const &CUpdateHint::GetUpdateRegion(void) +{ + return(m_UpdateRegion); +} + + +//----------------------------------------------------------------------------- +// Purpose: Prepares to update an object. +// Input : pObject - Object that will be updated. +//----------------------------------------------------------------------------- +void CUpdateHint::PreUpdateObject(CMapClass *pObject) +{ + if (pObject != NULL) + { + CMapObjectList TempList; + TempList.AddTail(pObject); + PreUpdateObjects(&TempList); + } + else + { + PreUpdateObjects(NULL); + } +} + + +//----------------------------------------------------------------------------- +// Purpose: Prepares to update the list of objects. +// Input : pObjects - List of objects, NULL if none. +//----------------------------------------------------------------------------- +void CUpdateHint::PreUpdateObjects(CMapObjectList *pObjects) +{ + if (pObjects != NULL) + { + POSITION pos = pObjects->GetHeadPosition(); + while (pos != NULL) + { + CMapClass *pObject = pObjects->GetNext(pos); + if (pObject != NULL) + { + m_UpdateRegion.UpdateBounds(pObject); + } + } + } +} + + +//----------------------------------------------------------------------------- +// Purpose: Prepares to update an object. +// Input : pObject - Object that will be updated. +//----------------------------------------------------------------------------- +void CUpdateHint::PostUpdateObject(CMapClass *pObject, int nNotifyCode) +{ + if (pObject != NULL) + { + CMapObjectList TempList; + TempList.AddTail(pObject); + PostUpdateObjects(&TempList, nNotifyCode); + } + else + { + PostUpdateObjects(NULL, nNotifyCode); + } +} + + +//----------------------------------------------------------------------------- +// Purpose: Prepares to update the list of objects. +// Input : pObjects - List of objects, NULL if none. +//----------------------------------------------------------------------------- +void CUpdateHint::PostUpdateObjects(CMapObjectList *pObjects, int nNotifyCode) +{ + int nIndex = 0; + bool bFound = false; + + while (!bFound && (nIndex < m_ListEntries)) + { + if (m_NotifyList[nIndex].nCode == nNotifyCode) + { + bFound = true; + } + else + { + nIndex++; + } + } + + if ((!bFound && (nIndex < MAX_NOTIFY_CODES)) + { + if (nIndex < MAX_NOTIFY_CODES) + { + m_ListEntries++; + } + } + else + { + ASSERT(nIndex < MAX_NOTIFY_CODES); + return; + } + + m_NotifyList[nIndex].Objects.AddTail(pObjects); + + if (pObjects != NULL) + { + POSITION pos = pObjects->GetHeadPosition(); + while (pos != NULL) + { + CMapClass *pObject = pObjects->GetNext(pos); + if (pObject != NULL) + { + m_UpdateRegion.UpdateBounds(pObject); + } + } + } +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CUpdateHint::Reset(void) +{ + m_Objects.RemoveAll(); + m_UpdateRegion.ResetBounds(); +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CUpdateHint::UpdateBounds(BoundBox &bbox) +{ + m_UpdateRegion.UpdateBounds(&bbox); +} |