diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index 1a1763394e..63f91c81a2 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -53,7 +53,7 @@ class Dictionary; * { * const char*key = pElement->getStrKey(); * // You certainly know the type of value, so we assume that it's a Sprite. - * Sprite* pSprite = (Sprite*)pElement->getObject(); + * Sprite* pSprite = static_cast(pElement->getObject()); * // ...... * } * @endcode @@ -138,7 +138,7 @@ public: * It's also safe to remove elements while traversing. */ #define CCDICT_FOREACH(__dict__, __el__) \ - DictElement* pTmp##__dict__##__el__ = NULL; \ + DictElement* pTmp##__dict__##__el__ = nullptr; \ if (__dict__) \ HASH_ITER(hh, (__dict__)->_elements, __el__, pTmp##__dict__##__el__) diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index 446609168b..7f1e9c1a58 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -97,8 +97,8 @@ void AnimationCache::parseVersion1(Dictionary* animations) DictElement* pElement = NULL; CCDICT_FOREACH(animations, pElement) { - Dictionary* animationDict = (Dictionary*)pElement->getObject(); - Array* frameNames = (Array*)animationDict->objectForKey("frames"); + Dictionary* animationDict = static_cast(pElement->getObject()); + Array* frameNames = static_cast(animationDict->objectForKey("frames")); float delay = animationDict->valueForKey("delay")->floatValue(); Animation* animation = NULL; @@ -151,12 +151,12 @@ void AnimationCache::parseVersion2(Dictionary* animations) CCDICT_FOREACH(animations, pElement) { const char* name = pElement->getStrKey(); - Dictionary* animationDict = (Dictionary*)pElement->getObject(); + Dictionary* animationDict = static_cast(pElement->getObject()); const String* loops = animationDict->valueForKey("loops"); bool restoreOriginalFrame = animationDict->valueForKey("restoreOriginalFrame")->boolValue(); - Array* frameArray = (Array*)animationDict->objectForKey("frames"); + Array* frameArray = static_cast(animationDict->objectForKey("frames")); if ( frameArray == NULL ) { CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", name); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index d5da72e357..261228a6bb 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -103,9 +103,9 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex DictElement* pElement = NULL; CCDICT_FOREACH(framesDict, pElement) { - Dictionary* frameDict = (Dictionary*)pElement->getObject(); + Dictionary* frameDict = static_cast(pElement->getObject()); std::string spriteFrameName = pElement->getStrKey(); - SpriteFrame* spriteFrame = (SpriteFrame*)_spriteFrames->objectForKey(spriteFrameName); + SpriteFrame* spriteFrame = static_cast(_spriteFrames->objectForKey(spriteFrameName)); if (spriteFrame) { continue; @@ -299,7 +299,7 @@ void SpriteFrameCache::removeUnusedSpriteFrames(void) DictElement* pElement = NULL; CCDICT_FOREACH(_spriteFrames, pElement) { - SpriteFrame* spriteFrame = (SpriteFrame*)pElement->getObject(); + SpriteFrame* spriteFrame = static_cast(pElement->getObject()); if( spriteFrame->retainCount() == 1 ) { CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", pElement->getStrKey()); @@ -360,7 +360,7 @@ void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist) void SpriteFrameCache::removeSpriteFramesFromDictionary(Dictionary* dictionary) { - Dictionary* framesDict = (Dictionary*)dictionary->objectForKey("frames"); + Dictionary* framesDict = static_cast(dictionary->objectForKey("frames")); Array* keysToRemove = Array::create(); DictElement* pElement = NULL; @@ -383,7 +383,7 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture) CCDICT_FOREACH(_spriteFrames, pElement) { string key = pElement->getStrKey(); - SpriteFrame* frame = (SpriteFrame*)_spriteFrames->objectForKey(key.c_str()); + SpriteFrame* frame = static_cast(_spriteFrames->objectForKey(key.c_str())); if (frame && (frame->getTexture() == texture)) { keysToRemove->addObject(String::create(pElement->getStrKey())); diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index 1aac95db38..bb259124f3 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -84,7 +84,7 @@ void Profiler::displayTimers() DictElement* pElement = NULL; CCDICT_FOREACH(_activeTimers, pElement) { - ProfilingTimer* timer = (ProfilingTimer*)pElement->getObject(); + ProfilingTimer* timer = static_cast(pElement->getObject()); CCLog("%s", timer->description()); } } diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 56591d4c01..8aee499d15 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -538,7 +538,7 @@ void TextureCache::removeUnusedTextures() CCDICT_FOREACH(_textures, pElement) { CCLOG("cocos2d: TextureCache: texture: %s", pElement->getStrKey()); - Texture2D *value = (Texture2D*)pElement->getObject(); + Texture2D *value = static_cast(pElement->getObject()); if (value->retainCount() == 1) { CCLOG("cocos2d: TextureCache: removing unused texture: %s", pElement->getStrKey()); @@ -557,7 +557,7 @@ void TextureCache::removeUnusedTextures() CCDICT_FOREACH(_textures, pElement) { CCLOG("cocos2d: TextureCache: texture: %s", pElement->getStrKey()); - Texture2D *value = (Texture2D*)pElement->getObject(); + Texture2D *value = static_cast(pElement->getObject()); if (value->retainCount() == 1) { elementToRemove.push_back(pElement); @@ -615,7 +615,7 @@ void TextureCache::dumpCachedTextureInfo() DictElement* pElement = NULL; CCDICT_FOREACH(_textures, pElement) { - Texture2D* tex = (Texture2D*)pElement->getObject(); + Texture2D* tex = static_cast(pElement->getObject()); unsigned int bpp = tex->bitsPerPixelForFormat(); // Each texture takes up width * height * bytesPerPixel bytes. unsigned int bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8; diff --git a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp b/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp index 1bc61acf92..2421ae4349 100644 --- a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp +++ b/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp @@ -87,7 +87,7 @@ void SpriteFrameCacheHelper::addSpriteFrameFromDict(Dictionary *dictionary, Text DictElement *pElement = NULL; CCDICT_FOREACH(framesDict, pElement) { - Dictionary *frameDict = (Dictionary *)pElement->getObject(); + Dictionary *frameDict = static_cast(pElement->getObject()); std::string spriteFrameName = pElement->getStrKey(); _display2ImageMap[spriteFrameName] = imagePath; diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 60e881641a..7adacc5039 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -742,7 +742,7 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl DictElement* pElement = NULL; CCDICT_FOREACH(mNodeSequences, pElement) { - Node *node = (Node*)pElement->getIntKey(); + Node *node = reinterpret_cast(pElement->getIntKey()); node->stopAllActions(); // Refer to CCBReader::readKeyframe() for the real type of value @@ -758,7 +758,7 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl CCDICT_FOREACH(seqNodeProps, pElement1) { const char *propName = pElement1->getStrKey(); - CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propName); + CCBSequenceProperty *seqProp = static_cast(seqNodeProps->objectForKey(propName)); seqNodePropNames.insert(propName); setFirstFrame(node, seqProp, fTweenDuration); diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 832e65cb71..bead756bac 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -294,7 +294,7 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size & CCDICT_FOREACH(animationManagers, pElement) { Node* pNode = (Node*)pElement->getIntKey(); - CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode); + CCBAnimationManager* manager = static_cast(animationManagers->objectForKey((intptr_t)pNode)); pNode->setUserObject(manager); if (jsControlled) @@ -714,11 +714,11 @@ Node * CCBReader::readNodeGraph(Node * pParent) { DictElement* pElement; CCDICT_FOREACH(pCustomPropeties, pElement) { - customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), (CCBValue*)pElement->getObject()); + customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast(pElement->getObject())); if(!customAssigned && this->mCCBMemberVariableAssigner != NULL) { - customAssigned = this->mCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), (CCBValue*)pElement->getObject()); + customAssigned = this->mCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast(pElement->getObject())); } } } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 5f8d234e6e..3f2dd8b704 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -251,7 +251,7 @@ void ControlButton::setPreferredSize(Size size) DictElement * item = NULL; CCDICT_FOREACH(_backgroundSpriteDispatchTable, item) { - Scale9Sprite* sprite = (Scale9Sprite*)item->getObject(); + Scale9Sprite* sprite = static_cast(item->getObject()); sprite->setPreferredSize(size); } } @@ -719,7 +719,7 @@ void ControlButton::setOpacity(GLubyte opacity) DictElement * item = NULL; CCDICT_FOREACH(_backgroundSpriteDispatchTable, item) { - Scale9Sprite* sprite = (Scale9Sprite*)item->getObject(); + Scale9Sprite* sprite = static_cast(item->getObject()); sprite->setOpacity(opacity); } } @@ -736,7 +736,7 @@ void ControlButton::setColor(const Color3B & color) DictElement * item = NULL; CCDICT_FOREACH(_backgroundSpriteDispatchTable, item) { - Scale9Sprite* sprite = (Scale9Sprite*)item->getObject(); + Scale9Sprite* sprite = static_cast(item->getObject()); sprite->setColor(color); } }