From 424431690a37618978e7ffcbd3827ccfef2b17ba Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Nov 2013 10:39:30 +0800 Subject: [PATCH] Fixing warning generated by VS2012. --- cocos/2d/CCActionInterval.cpp | 4 ++-- cocos/2d/CCDrawNode.cpp | 4 ++-- cocos/2d/CCEventDispatcher.cpp | 6 +++--- cocos/2d/CCEventDispatcher.h | 6 +++--- cocos/2d/CCSpriteFrameCache.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 14c0fec762..bd300f73f0 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -210,7 +210,7 @@ Sequence* Sequence::create(Array* arrayOfActions) if (count > 1) { - for (unsigned int i = 1; i < count; ++i) + for (long i = 1; i < count; ++i) { prev = createWithTwoActions(prev, static_cast(arrayOfActions->getObjectAtIndex(i))); } @@ -220,7 +220,7 @@ Sequence* Sequence::create(Array* arrayOfActions) // If only one action is added to Sequence, make up a Sequence by adding a simplest finite time action. prev = createWithTwoActions(prev, ExtraAction::create()); } - pRet = (Sequence*)prev; + pRet = static_cast(prev); }while (0); return pRet; } diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 67ba1075b1..28da2da3e8 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -346,7 +346,7 @@ void DrawNode::drawPolygon(Point *verts, long count, const Color4F &fillColor, f struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count); memset(extrude, 0, sizeof(struct ExtrudeVerts)*count); - for(unsigned int i = 0; i < count; i++) + for (long i = 0; i < count; i++) { Vertex2F v0 = __v2f(verts[(i-1+count)%count]); Vertex2F v1 = __v2f(verts[i]); @@ -370,7 +370,7 @@ void DrawNode::drawPolygon(Point *verts, long count, const Color4F &fillColor, f V2F_C4B_T2F_Triangle *cursor = triangles; float inset = (outline == false ? 0.5 : 0.0); - for(unsigned int i = 0; i < count-2; i++) + for (long i = 0; i < count-2; i++) { Vertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset)); Vertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset)); diff --git a/cocos/2d/CCEventDispatcher.cpp b/cocos/2d/CCEventDispatcher.cpp index 0b9f4d042d..3387e8b3bf 100644 --- a/cocos/2d/CCEventDispatcher.cpp +++ b/cocos/2d/CCEventDispatcher.cpp @@ -491,7 +491,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, s auto fixedPriorityListeners = listeners->getFixedPriorityListeners(); auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners(); - int i = 0; + long i = 0; // priority < 0 if (fixedPriorityListeners) { @@ -527,7 +527,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, s if (!shouldStopPropagation) { // priority > 0 - for (; i < fixedPriorityListeners->size(); ++i) + for (; i < static_cast(fixedPriorityListeners->size()); ++i) { auto l = fixedPriorityListeners->at(i); @@ -976,7 +976,7 @@ void EventDispatcher::sortEventListenersOfFixedPriority(EventListener::ListenerI }); // FIXME: Should use binary search - int index = 0; + long index = 0; for (auto& listener : *fixedlisteners) { if (listener->getFixedPriority() >= 0) diff --git a/cocos/2d/CCEventDispatcher.h b/cocos/2d/CCEventDispatcher.h index b8b1aa8efb..c6127135f2 100644 --- a/cocos/2d/CCEventDispatcher.h +++ b/cocos/2d/CCEventDispatcher.h @@ -136,12 +136,12 @@ private: inline std::vector* getFixedPriorityListeners() const { return _fixedListeners; }; inline std::vector* getSceneGraphPriorityListeners() const { return _sceneGraphListeners; }; - inline int getGt0Index() const { return _gt0Index; }; - inline void setGt0Index(int index) { _gt0Index = index; }; + inline long getGt0Index() const { return _gt0Index; }; + inline void setGt0Index(long index) { _gt0Index = index; }; private: std::vector* _fixedListeners; std::vector* _sceneGraphListeners; - int _gt0Index; + long _gt0Index; }; /** Adds event listener with item */ diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index f5afd18f76..80cff587b5 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -319,7 +319,7 @@ void SpriteFrameCache::removeUnusedSpriteFrames(void) void SpriteFrameCache::removeSpriteFrameByName(const std::string& name) { // explicit nil handling - if( ! name.size()>0 ) + if( !(name.size()>0) ) return; // Is this an alias ?