From e6bdc8f0a61524a747929fcaaa0f138ac5ca5f49 Mon Sep 17 00:00:00 2001 From: Dreamy Cecil <21009796+DreamyCecil@users.noreply.github.com> Date: Sun, 11 Aug 2024 10:17:00 +0300 Subject: [PATCH] Make CSelection template code more cross-platform. - Replace "unsigned long" type with engine's "ULONG". - Replace _CrtIsValidPointer() assertion with a simple null-pointer check. --- Sources/Engine/Templates/Selection.cpp | 15 +++++++++------ Sources/Engine/Templates/Selection.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Sources/Engine/Templates/Selection.cpp b/Sources/Engine/Templates/Selection.cpp index c4d9029d9..0b50943b8 100644 --- a/Sources/Engine/Templates/Selection.cpp +++ b/Sources/Engine/Templates/Selection.cpp @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include // Select one object -template +template void CSelection::Select(cType &tToSelect) { // If the object is not selected @@ -40,7 +40,7 @@ void CSelection::Select(cType &tToSelect) }; // Deselect one object -template +template void CSelection::Deselect(cType &tToSelect) { // If the object is selected @@ -56,23 +56,26 @@ void CSelection::Deselect(cType &tToSelect) }; // Check if an object is selected -template +template BOOL CSelection::IsSelected(cType &tToSelect) { return tToSelect.IsSelected(ulFlag); }; // Deselect all objects -template +template void CSelection::Clear(void) { // Go through all objects FOREACHINDYNAMICCONTAINER(*this, cType, itObject) { // The object must be allocated and valid - ASSERT(_CrtIsValidPointer(&*itObject, sizeof(cType), TRUE)); + //ASSERT(_CrtIsValidPointer(&*itObject, sizeof(cType), TRUE)); //ASSERT(_CrtIsValidHeapPointer(&*itObject)); //ASSERT(_CrtIsMemoryBlock(&*itObject, sizeof(cType), NULL, NULL, NULL)); + // [Cecil] _CrtIsValidPointer() above is redundant since VS2010 + ASSERT(&*itObject != NULL); + // Deselect it itObject->Deselect(ulFlag); } @@ -82,7 +85,7 @@ void CSelection::Clear(void) }; // Get first in selection (NULL if empty selection) -template +template cType *CSelection::GetFirstInSelection(void) { // Empty selection diff --git a/Sources/Engine/Templates/Selection.h b/Sources/Engine/Templates/Selection.h index 44ccbbd32..f1504c504 100644 --- a/Sources/Engine/Templates/Selection.h +++ b/Sources/Engine/Templates/Selection.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include // A selection of some objects that support selecting -template +template class CSelection : public CDynamicContainer { public: // Destructor