From 4928c56f216eb0266dfb8750e90e85a8f707af1f Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 14 Dec 2023 02:54:32 +0700 Subject: [PATCH] Change some Asserts to DbgAssert --- regamedll/public/utlarray.h | 10 +++++----- regamedll/public/utllinkedlist.h | 18 +++++++++--------- regamedll/public/utlmap.h | 2 +- regamedll/public/utlmemory.h | 22 +++++++++++----------- regamedll/public/utlrbtree.h | 16 ++++++++-------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/regamedll/public/utlarray.h b/regamedll/public/utlarray.h index fa0f22fa..1da8aafb 100644 --- a/regamedll/public/utlarray.h +++ b/regamedll/public/utlarray.h @@ -144,28 +144,28 @@ inline const T *CUtlArray::Base() const template inline T &CUtlArray::operator[](int i) { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); return m_Memory[i]; } template inline const T &CUtlArray::operator[](int i) const { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); return m_Memory[i]; } template inline T &CUtlArray::Element(int i) { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); return m_Memory[i]; } template inline const T &CUtlArray::Element(int i) const { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); return m_Memory[i]; } @@ -251,7 +251,7 @@ void CUtlArray::SortPredicate(F &&predicate) template void CUtlArray::CopyArray(const T *pArray, size_t count) { - Assert(count < MAX_SIZE); + DbgAssert(count < MAX_SIZE); for (size_t n = 0; n < count; n++) m_Memory[n] = pArray[n]; diff --git a/regamedll/public/utllinkedlist.h b/regamedll/public/utllinkedlist.h index c9336989..6d05231c 100644 --- a/regamedll/public/utllinkedlist.h +++ b/regamedll/public/utllinkedlist.h @@ -248,14 +248,14 @@ inline I CUtlLinkedList::Tail() const template inline I CUtlLinkedList::Previous(I i) const { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); return InternalElement(i).m_Previous; } template inline I CUtlLinkedList::Next(I i) const { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); return InternalElement(i).m_Next; } @@ -319,7 +319,7 @@ I CUtlLinkedList::AllocInternal(bool multilist) if (m_TotalElements == m_Memory.NumAllocated()) m_Memory.Grow(); - Assert(m_TotalElements != InvalidIndex()); + DbgAssert(m_TotalElements != InvalidIndex()); elem = (I)m_TotalElements; m_TotalElements++; @@ -356,7 +356,7 @@ I CUtlLinkedList::Alloc(bool multilist) template void CUtlLinkedList::Free(I elem) { - Assert(IsValidIndex(elem)); + DbgAssert(IsValidIndex(elem)); Unlink(elem); ListElem_t &internalElem = InternalElement(elem); @@ -520,7 +520,7 @@ void CUtlLinkedList::RemoveAll() template void CUtlLinkedList::LinkBefore(I before, I elem) { - Assert(IsValidIndex(elem)); + DbgAssert(IsValidIndex(elem)); // Unlink it if it's in the list at the moment Unlink(elem); @@ -540,7 +540,7 @@ void CUtlLinkedList::LinkBefore(I before, I elem) { // Here, we're not linking to the end. Set the prev pointer to point to // the element we're linking. - Assert(IsInList(before)); + DbgAssert(IsInList(before)); ListElem_t& beforeElem = InternalElement(before); newElem.m_Previous = beforeElem.m_Previous; beforeElem.m_Previous = elem; @@ -559,7 +559,7 @@ void CUtlLinkedList::LinkBefore(I before, I elem) template void CUtlLinkedList::LinkAfter(I after, I elem) { - Assert(IsValidIndex(elem)); + DbgAssert(IsValidIndex(elem)); // Unlink it if it's in the list at the moment if (IsInList(elem)) @@ -579,7 +579,7 @@ void CUtlLinkedList::LinkAfter(I after, I elem) { // Here, we're not linking to the end. Set the next pointer to point to // the element we're linking. - Assert(IsInList(after)); + DbgAssert(IsInList(after)); ListElem_t& afterElem = InternalElement(after); newElem.m_Next = afterElem.m_Next; afterElem.m_Next = elem; @@ -598,7 +598,7 @@ void CUtlLinkedList::LinkAfter(I after, I elem) template void CUtlLinkedList::Unlink(I elem) { - Assert(IsValidIndex(elem)); + DbgAssert(IsValidIndex(elem)); if (IsInList(elem)) { ListElem_t *pBase = m_Memory.Base(); diff --git a/regamedll/public/utlmap.h b/regamedll/public/utlmap.h index f414604a..2432b75e 100644 --- a/regamedll/public/utlmap.h +++ b/regamedll/public/utlmap.h @@ -250,7 +250,7 @@ inline void CUtlMap::PurgeAndDeleteElements() template void DeepCopyMap(const CUtlMap &pmapIn, CUtlMap *out_pmapOut) { - Assert(out_pmapOut); + DbgAssert(out_pmapOut); out_pmapOut->Purge(); FOR_EACH_MAP_FAST(pmapIn, i) diff --git a/regamedll/public/utlmemory.h b/regamedll/public/utlmemory.h index a28bfea1..1761dfa2 100644 --- a/regamedll/public/utlmemory.h +++ b/regamedll/public/utlmemory.h @@ -121,7 +121,7 @@ template CUtlMemory::CUtlMemory(int nGrowSize, int nInitSize) : m_pMemory(0), m_nAllocationCount(nInitSize), m_nGrowSize(nGrowSize) { - Assert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER)); + DbgAssert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER)); if (m_nAllocationCount) { m_pMemory = (T *)malloc(m_nAllocationCount * sizeof(T)); @@ -149,7 +149,7 @@ void CUtlMemory::Init(int nGrowSize, int nInitSize) m_nGrowSize = nGrowSize; m_nAllocationCount = nInitSize; - Assert(nGrowSize >= 0); + DbgAssert(nGrowSize >= 0); if (m_nAllocationCount) { m_pMemory = (T *)malloc(m_nAllocationCount * sizeof(T)); @@ -174,28 +174,28 @@ void CUtlMemory::SetExternalBuffer(T *pMemory, int numElements) template inline T& CUtlMemory::operator[](I i) { - Assert(IsIdxValid(i)); + DbgAssert(IsIdxValid(i)); return m_pMemory[i]; } template inline T const& CUtlMemory::operator[](I i) const { - Assert(IsIdxValid(i)); + DbgAssert(IsIdxValid(i)); return m_pMemory[i]; } template inline T& CUtlMemory::Element(I i) { - Assert(IsIdxValid(i)); + DbgAssert(IsIdxValid(i)); return m_pMemory[i]; } template inline T const& CUtlMemory::Element(I i) const { - Assert(IsIdxValid(i)); + DbgAssert(IsIdxValid(i)); return m_pMemory[i]; } @@ -209,7 +209,7 @@ bool CUtlMemory::IsExternallyAllocated() const template void CUtlMemory::SetGrowSize(int nSize) { - Assert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER)); + DbgAssert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER)); m_nGrowSize = nSize; } @@ -250,12 +250,12 @@ inline bool CUtlMemory::IsIdxValid(I i) const template void CUtlMemory::Grow(int num) { - Assert(num > 0); + DbgAssert(num > 0); if (IsExternallyAllocated()) { // Can't grow a buffer whose memory was externally allocated - Assert(0); + DbgAssert(0); return; } @@ -281,7 +281,7 @@ void CUtlMemory::Grow(int num) { // Compute an allocation which is at least as big as a cache line... m_nAllocationCount = (31 + sizeof(T)) / sizeof(T); - Assert(m_nAllocationCount != 0); + DbgAssert(m_nAllocationCount != 0); } } @@ -305,7 +305,7 @@ inline void CUtlMemory::EnsureCapacity(int num) if (IsExternallyAllocated()) { // Can't grow a buffer whose memory was externally allocated - Assert(0); + DbgAssert(0); return; } diff --git a/regamedll/public/utlrbtree.h b/regamedll/public/utlrbtree.h index 100ccbc9..114829df 100644 --- a/regamedll/public/utlrbtree.h +++ b/regamedll/public/utlrbtree.h @@ -398,7 +398,7 @@ inline typename CUtlRBTree::Links_t const &CUtlRBTree::L template inline typename CUtlRBTree::Links_t &CUtlRBTree::Links(I i) { - Assert(i != InvalidIndex()); + DbgAssert(i != InvalidIndex()); return *(Links_t *)&m_Elements[i]; } @@ -460,7 +460,7 @@ I CUtlRBTree::NewNode() template void CUtlRBTree::FreeNode(I i) { - Assert(IsValidIndex(i) && (i != InvalidIndex())); + DbgAssert(IsValidIndex(i) && (i != InvalidIndex())); Destruct(&Element(i)); SetLeftChild(i, i); // indicates it's in not in the tree SetRightChild(i, m_FirstFree); @@ -624,7 +624,7 @@ void CUtlRBTree::LinkToParent(I i, I parent, bool isLeft) InsertRebalance(i); - Assert(IsValid()); + DbgAssert(IsValid()); } // Rebalance the tree after a deletion @@ -872,7 +872,7 @@ I CUtlRBTree::FirstInorder() const template I CUtlRBTree::NextInorder(I i) const { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); if (RightChild(i) != InvalidIndex()) { @@ -895,7 +895,7 @@ I CUtlRBTree::NextInorder(I i) const template I CUtlRBTree::PrevInorder(I i) const { - Assert(IsValidIndex(i)); + DbgAssert(IsValidIndex(i)); if (LeftChild(i) != InvalidIndex()) { @@ -953,7 +953,7 @@ I CUtlRBTree::NextPreorder(I i) const template I CUtlRBTree::PrevPreorder(I i) const { - Assert(0); // Not implemented yet + DbgAssert(0); // Not implemented yet return InvalidIndex(); } @@ -1120,7 +1120,7 @@ void CUtlRBTree::SetLessFunc(typename CUtlRBTree::LessFu template void CUtlRBTree::FindInsertionPosition(T const &insert, I &parent, bool &leftchild) { - Assert(m_LessFunc); + DbgAssert(m_LessFunc); // Find where node belongs I current = m_Root; @@ -1167,7 +1167,7 @@ void CUtlRBTree::Insert(const T *pArray, int nItems) template I CUtlRBTree::Find(T const &search) const { - Assert(m_LessFunc); + DbgAssert(m_LessFunc); I current = m_Root; while (current != InvalidIndex())