Merge pull request #10268 from kompjoefriek/Fixing-warnings

Fixed some compiler warnings
This commit is contained in:
minggo 2015-02-13 10:04:19 +08:00
commit 87e444873f
12 changed files with 44 additions and 41 deletions

View File

@ -587,6 +587,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\..\external\unzip\ioapi.h" />
<ClInclude Include="..\..\external\unzip\unzip.h" />
<ClInclude Include="..\..\external\xxhash\xxhash.h" />
<ClInclude Include="..\3d\3dExport.h" />
<ClInclude Include="..\3d\CCAABB.h" />
<ClInclude Include="..\3d\CCAnimate3D.h" />
<ClInclude Include="..\3d\CCAnimation3D.h" />
@ -657,6 +658,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\base\ccMacros.h" />
<ClInclude Include="..\base\CCMap.h" />
<ClInclude Include="..\base\CCNS.h" />
<ClInclude Include="..\base\CCPlatformConfig.h" />
<ClInclude Include="..\base\CCPlatformMacros.h" />
<ClInclude Include="..\base\CCProfiling.h" />
<ClInclude Include="..\base\CCProtocols.h" />
<ClInclude Include="..\base\ccRandom.h" />
@ -822,8 +825,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\platform\CCFileUtils.h" />
<ClInclude Include="..\platform\CCGLView.h" />
<ClInclude Include="..\platform\CCImage.h" />
<ClInclude Include="..\platform\CCPlatformConfig.h" />
<ClInclude Include="..\platform\CCPlatformMacros.h" />
<ClInclude Include="..\platform\CCSAXParser.h" />
<ClInclude Include="..\platform\CCThread.h" />
<ClInclude Include="..\platform\desktop\CCGLViewImpl-desktop.h" />

View File

@ -1639,6 +1639,12 @@
<ClInclude Include="..\base\CCNS.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCPlatformConfig.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCPlatformMacros.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCProfiling.h">
<Filter>base</Filter>
</ClInclude>
@ -1870,6 +1876,9 @@
<ClInclude Include="..\base\ccRandom.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\3d\3dExport.h">
<Filter>3d</Filter>
</ClInclude>
<ClInclude Include="..\3d\CCAABB.h">
<Filter>3d</Filter>
</ClInclude>
@ -2539,12 +2548,6 @@
<ClInclude Include="..\physics\CCPhysicsHelper.h">
<Filter>physics</Filter>
</ClInclude>
<ClInclude Include="..\platform\CCPlatformConfig.h">
<Filter>platform</Filter>
</ClInclude>
<ClInclude Include="..\platform\CCPlatformMacros.h">
<Filter>platform</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\math\Mat4.inl">

View File

@ -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<unsigned int>(i));
auto curve = _animation->getBoneCurveByName(bone->getName());
if (curve)
{

View File

@ -113,9 +113,9 @@ void getChildMap(std::map<int, std::vector<int> >& 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<int>(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;
}
@ -1382,11 +1382,11 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
if(!id.empty())
{
for(int i=0 ;i<animation_data_array.Size();i++)
for (rapidjson::SizeType i = 0; i < animation_data_array.Size(); i++)
{
if(animation_data_array[i][ID].GetString() ==id )
if(animation_data_array[i][ID].GetString() == id)
{
the_index = i;
the_index = static_cast<int>(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)

View File

@ -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<ssize_t>(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);
}
}
NS_CC_END

View File

@ -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<int>(index) < _skinBones.size())
return _skinBones.at(index);
return nullptr;

View File

@ -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<int>(easingType));
return pAction;
}
}

View File

@ -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<int>(type));
break;
}
}

View File

@ -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<int>(_frameIndex) < _action->getStartFrame() || static_cast<int>(_frameIndex) > _action->getEndFrame())
return;
if(currentFrameIndex >= _frameIndex)
if (currentFrameIndex >= static_cast<int>(_frameIndex))
emitEvent();
}

View File

@ -192,8 +192,8 @@ MeshCommand::~MeshCommand()
void MeshCommand::applyRenderState()
{
_renderStateCullFaceEnabled = glIsEnabled(GL_CULL_FACE);
_renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST);
_renderStateCullFaceEnabled = glIsEnabled(GL_CULL_FACE) != GL_FALSE;
_renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE;
glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite);
GLint cullface;
glGetIntegerv(GL_CULL_FACE_MODE, &cullface);

View File

@ -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();

View File

@ -245,7 +245,6 @@ Camera3DTestDemo::Camera3DTestDemo(void)
, _bZoomIn(false)
, _bRotateLeft(false)
, _bRotateRight(false)
, _cameraType(CameraType::Free)
{
}
Camera3DTestDemo::~Camera3DTestDemo(void)