From 0c70660551c90bae2acffa288122174ec0988a5d Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Thu, 29 Jan 2015 01:36:22 +0100 Subject: [PATCH] Fixed warnings - signed/unsigned mismatch - printing enum with %d - using int as bool --- cocos/3d/CCAnimate3D.cpp | 4 +-- cocos/3d/CCBundle3D.cpp | 36 +++++++++---------- cocos/3d/CCBundleReader.cpp | 4 +-- cocos/3d/CCMeshSkin.cpp | 2 +- .../cocosbuilder/CCBAnimationManager.cpp | 2 +- .../cocosbuilder/CCNodeLoader.cpp | 2 +- .../cocostudio/ActionTimeline/CCFrame.cpp | 4 +-- cocos/renderer/CCMeshCommand.cpp | 4 +-- cocos/renderer/CCRenderer.cpp | 4 +-- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cocos/3d/CCAnimate3D.cpp b/cocos/3d/CCAnimate3D.cpp index 1242b38905..74b9c330ab 100644 --- a/cocos/3d/CCAnimate3D.cpp +++ b/cocos/3d/CCAnimate3D.cpp @@ -110,8 +110,8 @@ void Animate3D::startWithTarget(Node *target) _boneCurves.clear(); auto skin = sprite->getSkeleton(); bool hasCurve = false; - for (unsigned int i = 0; i < skin->getBoneCount(); i++) { - auto bone = skin->getBoneByIndex(i); + for (int i = 0; i < skin->getBoneCount(); i++) { + auto bone = skin->getBoneByIndex(static_cast(i)); auto curve = _animation->getBoneCurveByName(bone->getName()); if (curve) { diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index b430d55e45..2d9eea21d6 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -113,9 +113,9 @@ void getChildMap(std::map >& map, SkinData* skinData, cons skinData->nodeBoneOriginMatrices.push_back(transform); parent_name_index = skinData->getBoneNameIndex(parent_name); } - else if (parent_name_index < skinData->skinBoneNames.size()) + else if (parent_name_index < static_cast(skinData->skinBoneNames.size())) { - skinData->skinBoneOriginMatrices[parent_name_index] = (transform); + skinData->skinBoneOriginMatrices[parent_name_index] = transform; } // set root bone index @@ -246,7 +246,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD meshdata->attribs.push_back(attrib); } auto vertexNum = shapes.positions.size() / 3; - for(auto i = 0; i < vertexNum; i++) + for(unsigned int i = 0; i < vertexNum; i++) { meshdata->vertex.push_back(shapes.positions[i * 3]); meshdata->vertex.push_back(shapes.positions[i * 3 + 1]); @@ -372,7 +372,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas) CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str()); return false; } - for(int i = 0; i < meshSize ; i++ ) + for(unsigned int i = 0; i < meshSize ; i++ ) { MeshData* meshData = new (std::nothrow) MeshData(); unsigned int attribSize=0; @@ -489,7 +489,7 @@ bool Bundle3D::loadMeshDatasBinary_0_1(MeshDatas& meshdatas) // backward compatibility VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD, }; - for (ssize_t i = 0; i < attribSize; i++) + for (unsigned int i = 0; i < attribSize; i++) { unsigned int vUsage, vSize; if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1) @@ -598,7 +598,7 @@ bool Bundle3D::loadMeshDatasBinary_0_2(MeshDatas& meshdatas) // backward compatibility VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD, }; - for (ssize_t i = 0; i < attribSize; i++) + for (unsigned int i = 0; i < attribSize; i++) { unsigned int vUsage, vSize; if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1) @@ -695,7 +695,7 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas) MeshVertexAttrib tempAttrib; meshData->attribCount=mesh_vertex_attribute.Size(); meshData->attribs.resize(meshData->attribCount); - for (int i = 0; i < mesh_vertex_attribute.Size(); i++) + for (rapidjson::SizeType i = 0; i < mesh_vertex_attribute.Size(); i++) { const rapidjson::Value& mesh_vertex_attribute_val = mesh_vertex_attribute[i]; @@ -856,7 +856,7 @@ bool Bundle3D::loadMaterialsBinary(MaterialDatas& materialdatas) return false; unsigned int materialnum = 1; _binaryReader.read(&materialnum, 4, 1); - for (int i = 0; i < materialnum; i++) + for (unsigned int i = 0; i < materialnum; i++) { NMaterialData materialData; materialData.id = _binaryReader.readString(); @@ -865,7 +865,7 @@ bool Bundle3D::loadMaterialsBinary(MaterialDatas& materialdatas) unsigned int textruenum = 1; _binaryReader.read(&textruenum, 4, 1); - for(int j = 0; j < textruenum ; j++ ) + for(unsigned int j = 0; j < textruenum ; j++ ) { NTextureData textureData; textureData.id = _binaryReader.readString(); @@ -924,7 +924,7 @@ bool Bundle3D::loadMaterialsBinary_0_2(MaterialDatas& materialdatas) unsigned int materialnum = 1; _binaryReader.read(&materialnum, 4, 1); - for (int i = 0; i < materialnum; i++) + for (unsigned int i = 0; i < materialnum; i++) { NMaterialData materialData; @@ -1051,14 +1051,14 @@ bool Bundle3D::loadBinary(const std::string& path) // Read all refs CC_SAFE_DELETE_ARRAY(_references); _references = new (std::nothrow) Reference[_referenceCount]; - for (ssize_t i = 0; i < _referenceCount; ++i) + for (unsigned int i = 0; i < _referenceCount; ++i) { if ((_references[i].id = _binaryReader.readString()).empty() || _binaryReader.read(&_references[i].type, 4, 1) != 1 || _binaryReader.read(&_references[i].offset, 4, 1) != 1) { clear(); - CCLOG("warning: Failed to read ref number %d for bundle '%s'.", (int)i, path.c_str()); + CCLOG("warning: Failed to read ref number %u for bundle '%s'.", i, path.c_str()); CC_SAFE_DELETE_ARRAY(_references); return false; } @@ -1376,17 +1376,17 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani if (!_jsonReader.HasMember(anim.c_str())) return false; int the_index = -1; - const rapidjson::Value& animation_data_array = _jsonReader[anim.c_str()]; + const rapidjson::Value& animation_data_array = _jsonReader[anim.c_str()]; if (animation_data_array.Size()==0) return false; if(!id.empty()) { - for(int i=0 ;i(i); } } if(the_index < 0) return false; @@ -1797,7 +1797,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton) CCLOG("warning: Failed to read nodedata: uvMapping '%s'.", _path.c_str()); return nullptr; } - for(int j = 0 ; j < uvMapping ; j++) + for(unsigned int j = 0; j < uvMapping; j++) { unsigned int textureIndexSize=0; if (_binaryReader.read(&textureIndexSize, 4, 1) != 1) @@ -1805,7 +1805,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton) CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str()); return nullptr; } - for(unsigned int k = 0; k < textureIndexSize ; k++) + for(unsigned int k = 0; k < textureIndexSize; k++) { unsigned int index=0; if (_binaryReader.read(&index, 4, 1) != 1) diff --git a/cocos/3d/CCBundleReader.cpp b/cocos/3d/CCBundleReader.cpp index 33ba3acfb2..113aede322 100644 --- a/cocos/3d/CCBundleReader.cpp +++ b/cocos/3d/CCBundleReader.cpp @@ -170,7 +170,7 @@ std::string BundleReader::readString() std::string str; ssize_t validLength = _length - _position; - if (length > 0 && length <= validLength) + if (length > 0 && static_cast(length) <= validLength) { str.resize(length); if (read(&str[0], 1, length) != length) @@ -187,4 +187,4 @@ bool BundleReader::readMatrix(float* m) return (read(m, sizeof(float), 16) == 16); } -} \ No newline at end of file +NS_CC_END diff --git a/cocos/3d/CCMeshSkin.cpp b/cocos/3d/CCMeshSkin.cpp index d192796df4..878e4d1eed 100644 --- a/cocos/3d/CCMeshSkin.cpp +++ b/cocos/3d/CCMeshSkin.cpp @@ -70,7 +70,7 @@ ssize_t MeshSkin::getBoneCount() const //get bone Bone3D* MeshSkin::getBoneByIndex(unsigned int index) const { - if (index < _skinBones.size()) + if (static_cast(index) < _skinBones.size()) return _skinBones.at(index); return nullptr; diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index c0ee2f2ae8..5ecd070692 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -609,7 +609,7 @@ ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, CCBK } else { - log("CCBReader: Unkown easing type %d", easingType); + log("CCBReader: Unkown easing type %d", static_cast(easingType)); return pAction; } } diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index bd560ca67a..071f3e3e68 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -361,7 +361,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe break; } default: - ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type); + ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(static_cast(type)); break; } } diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index a68d3af35b..02a36a7aed 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -722,10 +722,10 @@ void EventFrame::setNode(cocos2d::Node* node) void EventFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { - if(_frameIndex < _action->getStartFrame() || _frameIndex > _action->getEndFrame()) + if (static_cast(_frameIndex) < _action->getStartFrame() || static_cast(_frameIndex) > _action->getEndFrame()) return; - if(currentFrameIndex >= _frameIndex) + if (currentFrameIndex >= static_cast(_frameIndex)) emitEvent(); } diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 48685f2c64..f58341ee84 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -184,8 +184,8 @@ MeshCommand::~MeshCommand() void MeshCommand::applyRenderState() { - _renderStateCullFace = glIsEnabled(GL_CULL_FACE); - _renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST); + _renderStateCullFace = glIsEnabled(GL_CULL_FACE) != GL_FALSE; + _renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE; glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite); if (_cullFaceEnabled && !_renderStateCullFace) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 9754bea3d5..cd1e5d47b1 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -137,8 +137,8 @@ void RenderQueue::clear() void RenderQueue::saveRenderState() { - _isDepthEnabled = glIsEnabled(GL_DEPTH_TEST); - _isCullEnabled = glIsEnabled(GL_CULL_FACE); + _isDepthEnabled = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE; + _isCullEnabled = glIsEnabled(GL_CULL_FACE) != GL_FALSE; glGetBooleanv(GL_DEPTH_WRITEMASK, &_isDepthWrite); CHECK_GL_ERROR_DEBUG();