Merge pull request #293 from liswei/master

fixed #516
This commit is contained in:
minggo 2011-06-13 19:42:56 -07:00
commit 23362964bb
3 changed files with 9 additions and 8 deletions

View File

@ -286,7 +286,7 @@ void CCActionManager::removeAction(cocos2d::CCAction *pAction)
if (pElement)
{
unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction);
if ((int)i != -1)
if (UINT_MAX == i)
{
removeActionAtIndex(i, pElement);
}

View File

@ -422,7 +422,8 @@ namespace cocos2d
// ignore parent Z if parent is spriteSheet
bool bIgnoreParent = (CCSpriteBatchNode*)(pobSprite->getParent()) == this;
CCSprite *pPrevious = NULL;
if (uChildIndex > 0)
if (uChildIndex > 0 &&
uChildIndex < UINT_MAX)
{
pPrevious = (CCSprite*)(pBrothers->objectAtIndex(uChildIndex - 1));
}
@ -537,7 +538,7 @@ namespace cocos2d
pobSprite->useSelfRender();
unsigned int uIndex = m_pobDescendants->indexOfObject(pobSprite);
if ((int)uIndex != -1)
if (uIndex != UINT_MAX)
{
m_pobDescendants->removeObjectAtIndex(uIndex);

View File

@ -118,13 +118,13 @@ static inline unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* objec
}
}
return (unsigned int)-1;
return UINT_MAX;
}
/** Returns a Boolean value that indicates whether object is present in array. */
static inline bool ccArrayContainsObject(ccArray *arr, CCObject* object)
{
return (int)ccArrayGetIndexOfObject(arr, object) != -1;
return ccArrayGetIndexOfObject(arr, object) != UINT_MAX;
}
/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */
@ -210,7 +210,7 @@ static inline void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int ind
static inline void ccArrayFastRemoveObject(ccArray *arr, CCObject* object)
{
unsigned int index = ccArrayGetIndexOfObject(arr, object);
if ((int)index != -1)
if (index != UINT_MAX)
ccArrayFastRemoveObjectAtIndex(arr, index);
}
@ -220,7 +220,7 @@ static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object)
{
unsigned int index = ccArrayGetIndexOfObject(arr, object);
if ((int)index != -1)
if (index != UINT_MAX)
{
ccArrayRemoveObjectAtIndex(arr, index);
}
@ -422,7 +422,7 @@ static inline void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int in
static inline void ccCArrayRemoveValue(ccCArray *arr, void* value)
{
unsigned int index = ccCArrayGetIndexOfValue(arr, value);
if ((int)index != -1)
if (index != UINT_MAX)
{
ccCArrayRemoveValueAtIndex(arr, index);
}