Skip to content

Commit

Permalink
Make CSelection template code more cross-platform.
Browse files Browse the repository at this point in the history
- Replace "unsigned long" type with engine's "ULONG".
- Replace _CrtIsValidPointer() assertion with a simple null-pointer check.
  • Loading branch information
DreamyCecil committed Aug 11, 2024
1 parent 7fae8c4 commit e6bdc8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Sources/Engine/Templates/Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Templates/DynamicContainer.cpp>

// Select one object
template<class cType, unsigned long ulFlag>
template<class cType, ULONG ulFlag>
void CSelection<cType, ulFlag>::Select(cType &tToSelect)
{
// If the object is not selected
Expand All @@ -40,7 +40,7 @@ void CSelection<cType, ulFlag>::Select(cType &tToSelect)
};

// Deselect one object
template<class cType, unsigned long ulFlag>
template<class cType, ULONG ulFlag>
void CSelection<cType, ulFlag>::Deselect(cType &tToSelect)
{
// If the object is selected
Expand All @@ -56,23 +56,26 @@ void CSelection<cType, ulFlag>::Deselect(cType &tToSelect)
};

// Check if an object is selected
template<class cType, unsigned long ulFlag>
template<class cType, ULONG ulFlag>
BOOL CSelection<cType, ulFlag>::IsSelected(cType &tToSelect)
{
return tToSelect.IsSelected(ulFlag);
};

// Deselect all objects
template<class cType, unsigned long ulFlag>
template<class cType, ULONG ulFlag>
void CSelection<cType, ulFlag>::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);
}
Expand All @@ -82,7 +85,7 @@ void CSelection<cType, ulFlag>::Clear(void)
};

// Get first in selection (NULL if empty selection)
template<class cType, unsigned long ulFlag>
template<class cType, ULONG ulFlag>
cType *CSelection<cType, ulFlag>::GetFirstInSelection(void)
{
// Empty selection
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Templates/Selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Templates/DynamicContainer.h>

// A selection of some objects that support selecting
template <class cType, unsigned long ulFlag>
template <class cType, ULONG ulFlag>
class CSelection : public CDynamicContainer<cType> {
public:
// Destructor
Expand Down

0 comments on commit e6bdc8f

Please sign in to comment.