From 7d139a3bc3647901a83577d9e645c1e01275fa36 Mon Sep 17 00:00:00 2001 From: signmotion Date: Sun, 22 Sep 2013 23:50:54 +0300 Subject: [PATCH] Fixed compiling-warnings (MSVC2012): C4996(* was declared deprecated), C4305 (* truncation from 'double' to 'float'), C4018 (* signed/unsigned mismatch), C4800(* forcing value to bool 'true' or 'false'). --- cocos2dx/physics/CCPhysicsWorld.cpp | 2 +- .../CocoStudio/Action/CCActionManagerEx.cpp | 2 +- .../Armature/display/CCDisplayManager.cpp | 4 ++-- .../Armature/utils/CCDataReaderHelper.cpp | 6 +++--- .../GUI/UIWidgets/ScrollWidget/UIPageView.cpp | 2 +- .../CocoStudio/Json/DictionaryHelper.cpp | 6 +++--- .../CocoStudio/Reader/CCSSceneReader.cpp | 4 ++-- .../UINodeContainerTest.cpp | 2 +- .../UITextFieldTest/UITextFieldTest.cpp | 18 +++++++++--------- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp index 08857de24b..5b714447d0 100644 --- a/cocos2dx/physics/CCPhysicsWorld.cpp +++ b/cocos2dx/physics/CCPhysicsWorld.cpp @@ -236,7 +236,7 @@ void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape) PhysicsHelper::cpvs2points(poly->tVerts, seg, num); - node->drawPolygon(seg, num, Color4F(1, 0, 0, 0.3), 1, Color4F(1, 0, 0, 1)); + node->drawPolygon(seg, num, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1.0f, Color4F(1.0f, 0.0f, 0.0f, 1.0f)); delete[] seg; break; diff --git a/extensions/CocoStudio/Action/CCActionManagerEx.cpp b/extensions/CocoStudio/Action/CCActionManagerEx.cpp index 7034788852..3f927c1b84 100644 --- a/extensions/CocoStudio/Action/CCActionManagerEx.cpp +++ b/extensions/CocoStudio/Action/CCActionManagerEx.cpp @@ -82,7 +82,7 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* { return NULL; } - for (unsigned int i=0; icount(); i++) + for (int i = 0; i < actionList->count(); i++) { ActionObject* action = dynamic_cast(actionList->getObjectAtIndex(i)); if (strcmp(actionName, action->getName()) == 0) diff --git a/extensions/CocoStudio/Armature/display/CCDisplayManager.cpp b/extensions/CocoStudio/Armature/display/CCDisplayManager.cpp index 01103f392d..a0c89f45cd 100644 --- a/extensions/CocoStudio/Armature/display/CCDisplayManager.cpp +++ b/extensions/CocoStudio/Armature/display/CCDisplayManager.cpp @@ -90,7 +90,7 @@ void DisplayManager::addDisplay(DisplayData *displayData, int index) { DecorativeDisplay *decoDisplay = NULL; - if(index >= 0 && (unsigned int)index < _decoDisplayList->count()) + if( (index >= 0) && (index < _decoDisplayList->count()) ) { decoDisplay = (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index); } @@ -114,7 +114,7 @@ void DisplayManager::addDisplay(Node *display, int index) { DecorativeDisplay *decoDisplay = NULL; - if(index >= 0 && (unsigned int)index < _decoDisplayList->count()) + if( (index >= 0) && (index < _decoDisplayList->count()) ) { decoDisplay = (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index); } diff --git a/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp index 76d56a4b8d..563526570c 100644 --- a/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp +++ b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp @@ -704,7 +704,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML } if( movementXML->QueryIntAttribute(A_LOOP, &(loop)) == tinyxml2::XML_SUCCESS) { - movementData->loop = (bool)loop; + movementData->loop = (loop != 0); } const char *_easing = movementXML->Attribute(A_TWEEN_EASING); @@ -855,7 +855,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - CCFrameData **frames = (CCFrameData **)movBoneData->frameList.data->arr; + FrameData **frames = (FrameData **)movBoneData->frameList.data->arr; for (int i = movBoneData->frameList.count() - 1; i >= 0; i--) { if (i > 0) @@ -1432,7 +1432,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(cs::JsonDictionary &json) if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) { //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - CCFrameData **frames = (CCFrameData **)movementBoneData->frameList.data->arr; + FrameData **frames = (FrameData **)movementBoneData->frameList.data->arr; for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--) { if (i > 0) diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp index 28716b8db9..0313820ee7 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp @@ -261,7 +261,7 @@ void UIPageView::updateChildrenSize() } Size selfSize = getSize(); - for (unsigned int i=0; i<_pages->count(); i++) + for (int i = 0; i < _pages->count(); i++) { Layout* page = dynamic_cast(_pages->getObjectAtIndex(i)); page->setSize(selfSize); diff --git a/extensions/CocoStudio/Json/DictionaryHelper.cpp b/extensions/CocoStudio/Json/DictionaryHelper.cpp index db93ba1563..ca8dfd8594 100644 --- a/extensions/CocoStudio/Json/DictionaryHelper.cpp +++ b/extensions/CocoStudio/Json/DictionaryHelper.cpp @@ -105,7 +105,7 @@ const char* DictionaryHelper::getStringValue(cocos2d::Dictionary* root,const cha bool DictionaryHelper::getBooleanValue(cocos2d::Dictionary* root,const char* key) { - return this->getIntValue(root, key); + return (getIntValue( root, key ) != 0); } cocos2d::Array* DictionaryHelper::getArrayValue(cocos2d::Dictionary *root, const char *key) @@ -163,9 +163,9 @@ bool DictionaryHelper::objectToBooleanValue(cocos2d::Object *obj) { if (!obj) { - return 0; + return false; } - return this->objectToIntValue(obj); + return (objectToIntValue( obj ) != 0); } cocos2d::Array* DictionaryHelper::objectToCCArray(cocos2d::Object *obj) diff --git a/extensions/CocoStudio/Reader/CCSSceneReader.cpp b/extensions/CocoStudio/Reader/CCSSceneReader.cpp index f8735331d7..0d55a96653 100644 --- a/extensions/CocoStudio/Reader/CCSSceneReader.cpp +++ b/extensions/CocoStudio/Reader/CCSSceneReader.cpp @@ -308,7 +308,7 @@ NS_CC_EXT_BEGIN } pAudio->preloadBackgroundMusic(pPath.c_str()); pAudio->setFile(pPath.c_str()); - bool bLoop = subDict->getItemIntValue("loop", 0); + const bool bLoop = (subDict->getItemIntValue("loop", 0) != 0); pAudio->setLoop(bLoop); gb->addComponent(pAudio); pAudio->playBackgroundMusic(pPath.c_str(), bLoop); @@ -354,7 +354,7 @@ NS_CC_EXT_BEGIN int y = dict->getItemIntValue("y", 0); node->setPosition(Point(x, y)); - bool bVisible = (bool)(dict->getItemIntValue("visible", 1)); + const bool bVisible = (dict->getItemIntValue("visible", 1) != 0); node->setVisible(bVisible); int nTag = dict->getItemIntValue("objecttag", -1); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UINodeContainerTest/UINodeContainerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UINodeContainerTest/UINodeContainerTest.cpp index 6d06cb619e..e4bd80560f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UINodeContainerTest/UINodeContainerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UINodeContainerTest/UINodeContainerTest.cpp @@ -52,7 +52,7 @@ bool UINodeContainerTest::init() m_pUiLayer->addWidget(nodeContainer); Sprite* sprite = Sprite::create("cocosgui/ccicon.png"); - sprite->setPosition(Point(0, sprite->boundingBox().size.height / 4)); + sprite->setPosition(Point(0, sprite->getBoundingBox().size.height / 4)); nodeContainer->addRenderer(sprite, 0); return true; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 3e85c987b4..bba53b0444 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -67,8 +67,8 @@ void UITextFieldTest::textFieldEvent(Object *pSender, TextFiledEventType type) { UITextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.225, - Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); + textField->runAction(CCMoveTo::create(0.225f, + Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString()); } break; @@ -77,7 +77,7 @@ void UITextFieldTest::textFieldEvent(Object *pSender, TextFiledEventType type) { UITextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString()); } break; @@ -155,8 +155,8 @@ void UITextFieldTest_MaxLength::textFieldEvent(Object *pSender, TextFiledEventTy { UITextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.225, - Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); + textField->runAction(CCMoveTo::create(0.225f, + Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString()); } break; @@ -165,7 +165,7 @@ void UITextFieldTest_MaxLength::textFieldEvent(Object *pSender, TextFiledEventTy { UITextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString()); } break; @@ -249,8 +249,8 @@ void UITextFieldTest_Password::textFieldEvent(Object *pSender, TextFiledEventTyp { UITextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.225, - Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); + textField->runAction(CCMoveTo::create(0.225f, + Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME password")->getCString()); } break; @@ -259,7 +259,7 @@ void UITextFieldTest_Password::textFieldEvent(Object *pSender, TextFiledEventTyp { UITextField* textField = dynamic_cast(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); + textField->runAction(CCMoveTo::create(0.175f, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME password")->getCString()); } break;