Changed: Replace size() comparisons by empty()

This commit is contained in:
kervala 2016-05-25 23:18:11 +02:00
parent e2655d95de
commit 23866079be
57 changed files with 133 additions and 128 deletions

View file

@ -163,7 +163,7 @@ public:
/** There is (OrderS/2+1) * (OrderT/2+1) tiles light influence.
* It indicates which static pointLight influence each corner of a TessBlock (block of 2*2 tiles).
*
* If size()==0, suppose no light influence. but CZone::retrieve() always return a
* If empty(), suppose no light influence. but CZone::retrieve() always return a
* size() == (OrderS/2+1) * (OrderT/2+1).
*
* They are stored in line first order, from S=0 to 1, and T=0 to 1.

View file

@ -120,7 +120,7 @@ public:
*/
std::string toString() const
{
if (_Ids.size()==0) return std::string("");
if (_Ids.empty()) return std::string("");
std::string str=_Ids[0];
for (unsigned i=1; i<_Ids.size(); i++)
str +=std::string(":")+ _Ids[i];

View file

@ -50,14 +50,14 @@ IDriver::~IDriver()
{
CSynchronized<TTexDrvInfoPtrMap>::CAccessor access(&_SyncTexDrvInfos);
TTexDrvInfoPtrMap &rTexDrvInfos = access.value();
nlassert( rTexDrvInfos.size() == 0 );
nlassert(rTexDrvInfos.empty());
}
nlassert(_TexDrvShares.size()==0);
nlassert(_MatDrvInfos.size()==0);
nlassert(_VBDrvInfos.size()==0);
nlassert(_IBDrvInfos.size()==0);
nlassert(_GPUPrgDrvInfos.size()==0);
nlassert(_TexDrvShares.empty());
nlassert(_MatDrvInfos.empty());
nlassert(_VBDrvInfos.empty());
nlassert(_IBDrvInfos.empty());
nlassert(_GPUPrgDrvInfos.empty());
}

View file

@ -528,7 +528,7 @@ void CDRU::drawTrianglesUnlit(const NLMISC::CTriangleUV *trilist, sint ntris,
// ***************************************************************************
void CDRU::drawTrianglesUnlit(const std::vector<NLMISC::CTriangleUV> &trilist, CMaterial &mat, IDriver& driver)
{
if(trilist.size()==0)
if(trilist.empty())
return;
CDRU::drawTrianglesUnlit( &(*trilist.begin()), (uint)trilist.size(), mat, driver);
@ -570,7 +570,7 @@ void CDRU::drawLinesUnlit(const NLMISC::CLine *linelist, sint nlines, CMateria
// ***************************************************************************
void CDRU::drawLinesUnlit(const std::vector<NLMISC::CLine> &linelist, CMaterial &mat, IDriver& driver)
{
if(linelist.size()==0)
if(linelist.empty())
return;
CDRU::drawLinesUnlit( &(*linelist.begin()), (sint)linelist.size(), mat, driver);
}

View file

@ -2859,7 +2859,7 @@ void CLandscape::setupAutomaticLightDir(const CVector &lightDir)
// ***************************************************************************
CVector CLandscape::getHeightFieldDeltaZ(float x, float y) const
{
if(_HeightField.ZPatchs.size()==0)
if(_HeightField.ZPatchs.empty())
return CVector::Null;
// map to _HeightField coordinates.

View file

@ -134,7 +134,7 @@ void CLandscapeVBAllocator::resetReallocation()
uint CLandscapeVBAllocator::allocateVertex()
{
// if no more free, allocate.
if( _VertexFreeMemory.size()==0 )
if( _VertexFreeMemory.empty() )
{
// enlarge capacity.
uint newResize;

View file

@ -52,7 +52,7 @@ namespace NL3D
static NLMISC::CAABBoxExt makeBBox(const std::vector<CVector> &Vertices)
{
NLMISC::CAABBox ret;
nlassert(Vertices.size());
nlassert(!Vertices.empty());
ret.setCenter(Vertices[0]);
for(sint i=0;i<(sint)Vertices.size();i++)
{
@ -167,7 +167,7 @@ void CMeshGeom::build (CMesh::CMeshBuild &m, uint numMaxMaterial)
sint i;
// Empty geometry?
if(m.Vertices.size()==0 || m.Faces.size()==0)
if(m.Vertices.empty() || m.Faces.empty())
{
_VBuffer.setNumVertices(0);
_VBuffer.setName("CMeshGeom");
@ -436,7 +436,7 @@ void CMeshGeom::build (CMesh::CMeshBuild &m, uint numMaxMaterial)
}
// Set the vertex buffer preferred memory
bool avoidVBHard= _Skinned || ( _MeshMorpher && _MeshMorpher->BlendShapes.size()>0 );
bool avoidVBHard= _Skinned || ( _MeshMorpher && !_MeshMorpher->BlendShapes.empty() );
_VBuffer.setPreferredMemory (avoidVBHard?CVertexBuffer::RAMPreferred:CVertexBuffer::StaticPreferred, false);
// End!!
@ -638,7 +638,7 @@ void CMeshGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount,
for(uint mb=0;mb<_MatrixBlocks.size();mb++)
{
CMatrixBlock &mBlock= _MatrixBlocks[mb];
if(mBlock.RdrPass.size()==0)
if(mBlock.RdrPass.empty())
continue;
// Global alpha ?
@ -790,7 +790,7 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM)
for(uint mb=0;mb<_MatrixBlocks.size();mb++)
{
CMatrixBlock &mBlock= _MatrixBlocks[mb];
if(mBlock.RdrPass.size()==0)
if(mBlock.RdrPass.empty())
continue;
// Render all pass.
@ -840,7 +840,7 @@ void CMeshGeom::renderSimpleWithMaterial(IDriver *drv, const CMatrix &worldMatri
for(uint mb=0;mb<_MatrixBlocks.size();mb++)
{
CMatrixBlock &mBlock= _MatrixBlocks[mb];
if(mBlock.RdrPass.size()==0)
if(mBlock.RdrPass.empty())
continue;
// Render all pass.
@ -998,10 +998,10 @@ void CMeshGeom::compileRunTime()
_PreciseClipping= _BBox.getRadius() >= NL3D_MESH_PRECISE_CLIP_THRESHOLD;
// Support MeshBlockRendering only if not skinned/meshMorphed.
bool supportMeshBlockRendering= !_Skinned && _MeshMorpher->BlendShapes.size()==0;
bool supportMeshBlockRendering= !_Skinned && _MeshMorpher->BlendShapes.empty();
// true only if one matrix block, and at least one rdrPass.
supportMeshBlockRendering= supportMeshBlockRendering && _MatrixBlocks.size()==1 && _MatrixBlocks[0].RdrPass.size()>0;
supportMeshBlockRendering= supportMeshBlockRendering && _MatrixBlocks.size()==1 && !_MatrixBlocks[0].RdrPass.empty();
if (supportMeshBlockRendering && _MeshVertexProgram)
{
supportMeshBlockRendering = supportMeshBlockRendering && _MeshVertexProgram->supportMeshBlockRendering();
@ -1021,7 +1021,7 @@ void CMeshGeom::compileRunTime()
if(supportMBRPerMaterial)
_SupportMBRFlags|= MBRSortPerMaterial;
bool avoidVBHard= _Skinned || ( _MeshMorpher && _MeshMorpher->BlendShapes.size()>0 );
bool avoidVBHard= _Skinned || ( _MeshMorpher && !_MeshMorpher->BlendShapes.empty() );
_VBuffer.setPreferredMemory (avoidVBHard?CVertexBuffer::RAMPreferred:CVertexBuffer::StaticPreferred, false);
}

View file

@ -407,9 +407,10 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri,
rFactor*= 0.01f;
uint32 numVertices= (uint32)rBS.VertRefs.size();
// don't know why, but cases happen where deltaNorm not empty while deltaPos is
bool hasPos= rBS.deltaPos.size()>0;
bool hasNorm= rBS.deltaNorm.size()>0;
bool hasUV= rBS.deltaUV.size()>0;
bool hasPos = !rBS.deltaPos.empty();
bool hasNorm = !rBS.deltaNorm.empty();
bool hasUV = !rBS.deltaUV.empty();
for (j = 0; j < numVertices; ++j)
{
// Get the vertex Index in the VBufferFinal

View file

@ -180,7 +180,7 @@ void CMeshMRMGeom::CLod::optimizeTriangleOrder()
static NLMISC::CAABBoxExt makeBBox(const std::vector<CVector> &Vertices)
{
NLMISC::CAABBox ret;
nlassert(Vertices.size());
nlassert(!Vertices.empty());
ret.setCenter(Vertices[0]);
for(sint i=0;i<(sint)Vertices.size();i++)
{
@ -236,7 +236,7 @@ void CMeshMRMGeom::build(CMesh::CMeshBuild &m, std::vector<CMesh::CMeshBuild*>
uint numMaxMaterial, const CMRMParameters &params)
{
// Empty geometry?
if(m.Vertices.size()==0 || m.Faces.size()==0)
if(m.Vertices.empty() || m.Faces.empty())
{
_VBufferFinal.setNumVertices(0);
_VBufferFinal.reserve(0);
@ -308,7 +308,7 @@ void CMeshMRMGeom::build(CMesh::CMeshBuild &m, std::vector<CMesh::CMeshBuild*>
_LevelDetail.MaxFaceUsed= 0;
_LevelDetail.MinFaceUsed= 0;
// Count of primitive block
if(_Lods.size()>0)
if (!_Lods.empty())
{
uint pb;
// Compute MinFaces.
@ -469,7 +469,7 @@ void CMeshMRMGeom::applyGeomorph(std::vector<CMRMWedgeGeom> &geoms, float alpha
void CMeshMRMGeom::applyGeomorphWithVBHardPtr(std::vector<CMRMWedgeGeom> &geoms, float alphaLod, uint8 *vertexDestPtr)
{
// no geomorphs? quit.
if(geoms.size()==0)
if(geoms.empty())
return;
clamp(alphaLod, 0.f, 1.f);
@ -900,7 +900,7 @@ inline sint CMeshMRMGeom::chooseLod(float alphaMRM, float &alphaLod)
void CMeshMRMGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, uint32 rdrFlags, float globalAlpha)
{
nlassert(drv);
if(_Lods.size()==0)
if(_Lods.empty())
return;
@ -922,7 +922,7 @@ void CMeshMRMGeom::render(IDriver *drv, CTransformShape *trans, float polygonCou
// Render the choosen Lod.
CLod &lod= _Lods[numLod];
if(lod.RdrPass.size()==0)
if(lod.RdrPass.empty())
return;
@ -1104,7 +1104,7 @@ void CMeshMRMGeom::renderSkin(CTransformShape *trans, float alphaMRM)
{
H_AUTO( NL3D_MeshMRMGeom_renderSkin );
if(_Lods.size()==0)
if(_Lods.empty())
return;
@ -1126,7 +1126,7 @@ void CMeshMRMGeom::renderSkin(CTransformShape *trans, float alphaMRM)
// Render the choosen Lod.
CLod &lod= _Lods[numLod];
if(lod.RdrPass.size()==0)
if(lod.RdrPass.empty())
return;
@ -1295,7 +1295,7 @@ sint CMeshMRMGeom::renderSkinGroupGeom(CMeshMRMInstance *mi, float alphaMRM, uin
// Render the choosen Lod.
CLod &lod= _Lods[numLod];
if(lod.RdrPass.size()==0)
if(lod.RdrPass.empty())
// return no vertices added
return 0;
@ -1942,7 +1942,7 @@ void CMeshMRMGeom::loadFirstLod(NLMISC::IStream &f)
// If empty MRM, quit.
if(_LodInfos.size()==0)
if(_LodInfos.empty())
return;
/* If the version is <4, then SkinWeights are serialised per Lod.
@ -2431,7 +2431,7 @@ void CMeshMRMGeom::compileRunTime()
_PreciseClipping= _BBox.getRadius() >= NL3D_MESH_PRECISE_CLIP_THRESHOLD;
// Compute if can support SkinGrouping rendering
if(_Lods.size()==0 || !_Skinned)
if(_Lods.empty() || !_Skinned)
{
_SupportSkinGrouping= false;
_SupportShadowSkinGrouping= false;
@ -2451,7 +2451,7 @@ void CMeshMRMGeom::compileRunTime()
}
// Support MeshBlockRendering only if not skinned/meshMorphed.
_SupportMeshBlockRendering= !_Skinned && _MeshMorpher.BlendShapes.size()==0;
_SupportMeshBlockRendering= !_Skinned && _MeshMorpher.BlendShapes.empty();
// \todo yoyo: support later MeshVertexProgram
_SupportMeshBlockRendering= _SupportMeshBlockRendering && _MeshVertexProgram==NULL;
@ -3367,7 +3367,7 @@ void CMeshMRMGeom::updateRawSkinNormal(bool enabled, CMeshMRMInstance *mi, sint
// Case of MeshMorpher
//========
if(_MeshMorpher.BlendShapes.size()>0)
if(!_MeshMorpher.BlendShapes.empty())
{
skinLod.VertexRemap.resize((uint32)vertexFinalRemap.size());

View file

@ -55,7 +55,7 @@ namespace NL3D
void CMeshMRMGeom::applySkin(CLod &lod, const CSkeletonModel *skeleton)
{
nlassert(_Skinned);
if(_SkinWeights.size()==0)
if(_SkinWeights.empty())
return;
// get vertexPtr.

View file

@ -380,7 +380,7 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh:
void CMeshMRMGeom::applySkinWithNormal(CLod &lod, const CSkeletonModel *skeleton)
{
nlassert(_Skinned);
if(_SkinWeights.size()==0)
if(_SkinWeights.empty())
return;
// get vertexPtr / normalOff.
@ -446,7 +446,7 @@ void CMeshMRMGeom::applySkinWithTangentSpace(CLod &lod, const CSkeletonModel *sk
uint tangentSpaceTexCoord)
{
nlassert(_Skinned);
if(_SkinWeights.size()==0)
if(_SkinWeights.empty())
return;
// get vertexPtr / normalOff / tangent space offset.
@ -1468,7 +1468,7 @@ void CMeshMRMGeom::applyArrayRawSkinNormal4(CRawVertexNormalSkin4 *src, uint8 *
void CMeshMRMGeom::applyRawSkinWithNormal(CLod &lod, CRawSkinNormalCache &rawSkinLod, const CSkeletonModel *skeleton, uint8 *vbHard, float alphaLod)
{
nlassert(_Skinned);
if(_SkinWeights.size()==0)
if(_SkinWeights.empty())
return;
// Some assert

View file

@ -160,7 +160,7 @@ void CMeshMRMSkinnedGeom::CLod::buildPrimitiveBlock(uint renderPass, const CInde
static NLMISC::CAABBoxExt makeBBox(const std::vector<CVector> &Vertices)
{
NLMISC::CAABBox ret;
nlassert(Vertices.size());
nlassert(!Vertices.empty());
ret.setCenter(Vertices[0]);
for(sint i=0;i<(sint)Vertices.size();i++)
{
@ -211,7 +211,7 @@ void CMeshMRMSkinnedGeom::build(CMesh::CMeshBuild &m,
uint numMaxMaterial, const CMRMParameters &params)
{
// Empty geometry?
if(m.Vertices.size()==0 || m.Faces.size()==0)
if(m.Vertices.empty() || m.Faces.empty())
{
_VBufferFinal.clear();
_Lods.clear();
@ -261,7 +261,7 @@ void CMeshMRMSkinnedGeom::build(CMesh::CMeshBuild &m,
_LevelDetail.MaxFaceUsed= 0;
_LevelDetail.MinFaceUsed= 0;
// Count of primitive block
if(_Lods.size()>0)
if(!_Lods.empty())
{
uint pb;
// Compute MinFaces.
@ -421,7 +421,7 @@ void CMeshMRMSkinnedGeom::applyGeomorph(std::vector<CMRMWedgeGeom> &geoms, floa
void CMeshMRMSkinnedGeom::applyGeomorphWithVBHardPtr(std::vector<CMRMWedgeGeom> &geoms, float alphaLod)
{
// no geomorphs? quit.
if(geoms.size()==0)
if(geoms.empty())
return;
clamp(alphaLod, 0.f, 1.f);
@ -579,7 +579,7 @@ inline sint CMeshMRMSkinnedGeom::chooseLod(float alphaMRM, float &alphaLod)
void CMeshMRMSkinnedGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, uint32 rdrFlags, float globalAlpha)
{
nlassert(drv);
if(_Lods.size()==0)
if(_Lods.empty())
return;
@ -597,7 +597,7 @@ void CMeshMRMSkinnedGeom::render(IDriver *drv, CTransformShape *trans, float pol
// Render the choosen Lod.
CLod &lod= _Lods[numLod];
if(lod.RdrPass.size()==0)
if(lod.RdrPass.empty())
return;
@ -757,7 +757,7 @@ sint CMeshMRMSkinnedGeom::renderSkinGroupGeom(CMeshMRMSkinnedInstance *mi, float
// Render the choosen Lod.
CLod &lod= _Lods[numLod];
if(lod.RdrPass.size()==0)
if(lod.RdrPass.empty())
// return no vertices added
return 0;

View file

@ -3119,7 +3119,7 @@ bool CMRMBuilder::buildMRMSewingMeshes(const CMesh::CMeshBuild &mbuild, uint nWa
{
nlassert(nWantedLods>=1);
nlassert(divisor>=1);
if(mbuild.Interfaces.size()==0)
if(mbuild.Interfaces.empty())
return false;
// must have same size
if(mbuild.InterfaceLinks.size()!=mbuild.Vertices.size())

View file

@ -604,7 +604,8 @@ void CPatch::addRefTessBlocks()
uint i;
TessBlockRefCount++;
if(TessBlocks.size()==0)
if (TessBlocks.empty())
{
// Allocate the tessblocks.
//==========
@ -1629,7 +1630,7 @@ void CPatch::serial(NLMISC::IStream &f)
// then just copy to TileColors.
TileColors.resize(tmpArray.size());
if(TileColors.size()>0)
if(!TileColors.empty())
{
memcpy(&TileColors[0], &tmpArray[0], TileColors.size()*sizeof(CTileColor));
}

View file

@ -1452,7 +1452,7 @@ void CPatch::computeSoftwareGeomorphAndAlpha()
// Need only to fill CTessVertex, so do it only for FarVertices
// Hence Geomorph is done twice on edges of patches!!.
// If not too near for precise, fast compute of geomorph.
if( TessBlocks.size()==0 )
if( TessBlocks.empty() )
{
// Just update all vertices of master block.
computeGeomorphVertexList(MasterBlock.FarVertexList);

View file

@ -540,7 +540,7 @@ bool CPatchDLMContext::generate(CPatch *patch, CTextureDLM *textureDLM, CPatch
#ifndef NL_DLM_TILE_RES
// retrieve patch tileColor pointer.
nlassert(_Patch->TileColors.size()>0);
nlassert(!_Patch->TileColors.empty());
CTileColor *tileColor= &_Patch->TileColors[0];
// skip 1 tiles colors per column and per row
@ -898,7 +898,7 @@ void CPatchDLMContext::compileLighting(TCompileType compType, CRGBA modulateCt
if(! (_IsSrcTextureFullBlack && _IsDstTextureFullBlack) )
{
// if lightMap allocated
if(_LightMap.size()>0 && _DLMTexture)
if(!_LightMap.empty() && _DLMTexture)
{
// If the srcTexture is full black (ie no pointLight influence touch it),
if(_IsSrcTextureFullBlack)

View file

@ -226,7 +226,7 @@ void CPSFace::step(TPSProcessPass pass)
else if (pass == PSMotion)
{
if (_PrecompBasis.size()) // do we use precomputed basis ?
if (!_PrecompBasis.empty()) // do we use precomputed basis ?
{
// rotate all precomputed basis
for (CPSVector< CPlaneBasisPair >::V::iterator it = _PrecompBasis.begin(); it != _PrecompBasis.end(); ++it)
@ -394,7 +394,7 @@ void CPSFace::deleteElement(uint32 index)
NL_PS_FUNC(CPSFace_deleteElement)
CPSQuad::deleteElement(index);
deletePlaneBasisElement(index);
if (_PrecompBasis.size()) // do we use precomputed basis ?
if (!_PrecompBasis.empty()) // do we use precomputed basis ?
{
// replace ourself by the last element...
_IndexInPrecompBasis[index] = _IndexInPrecompBasis[_Owner->getSize() - 1];
@ -407,7 +407,7 @@ void CPSFace::resize(uint32 size)
NL_PS_FUNC(CPSFace_resize)
nlassert(size < (1 << 16));
resizePlaneBasis(size);
if (_PrecompBasis.size()) // do we use precomputed basis ?
if (!_PrecompBasis.empty()) // do we use precomputed basis ?
{
_IndexInPrecompBasis.resize(size);
}

View file

@ -1994,7 +1994,7 @@ void CPSConstraintMesh::deleteElement(uint32 index)
deleteSizeElement(index);
deletePlaneBasisElement(index);
// TODO : avoid code cuplication with CPSFace ...
if (_PrecompBasis.size()) // do we use precomputed basis ?
if (!_PrecompBasis.empty()) // do we use precomputed basis ?
{
// replace ourself by the last element...
_IndexInPrecompBasis[index] = _IndexInPrecompBasis[_Owner->getSize() - 1];
@ -2011,7 +2011,7 @@ void CPSConstraintMesh::resize(uint32 size)
resizeSize(size);
resizePlaneBasis(size);
// TODO : avoid code cuplication with CPSFace ...
if (_PrecompBasis.size()) // do we use precomputed basis ?
if (!_PrecompBasis.empty()) // do we use precomputed basis ?
{
_IndexInPrecompBasis.resize(size);
}

View file

@ -229,7 +229,7 @@ void CQuadEffect::processPoly(const TPoint2DVect &poly
static TRasters rDest;
float currY;
makeRasters(poly, quadWidth, quadHeight, rDest, currY);
if (dest.size())
if (!dest.empty())
{
TRasters::const_iterator it, endIt = rDest.end();
for (it = rDest.begin(); it != endIt; ++it)

View file

@ -705,7 +705,7 @@ void CShadowMapManager::renderProject(CScene *scene)
}
driver->activeVertexBuffer (CopyQuads);
if (_ShadowCasters.size()>0)
if (!_ShadowCasters.empty())
{
// get the transform to compute shadow map.
CTransform *sc= _ShadowCasters[0];

View file

@ -119,7 +119,7 @@ bool CTextureDLM::canCreateLightMap(uint w, uint h)
return true;
// If empty, test if there is an empty block.
return _EmptyBlocks.size()>0;
return !_EmptyBlocks.empty();
}
@ -166,7 +166,7 @@ bool CTextureDLM::createLightMap(uint w, uint h, uint &x, uint &y)
if(_FreeBlocks[lMapType]==NULL)
{
// list is empty => allocate a block from _EmptyBlocks.
nlassert(_EmptyBlocks.size()>0);
nlassert(!_EmptyBlocks.empty());
// pop a block from empty list
CBlock *block= &_Blocks[_EmptyBlocks.back()];

View file

@ -108,7 +108,7 @@ void CTileBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
if (f.isReading())
{
// Checks
nlassert (_DisplacementMap.size()>0);
nlassert (!_DisplacementMap.empty());
// Set first empty
_DisplacementMap[0].setEmpty ();
@ -543,7 +543,7 @@ CTileNoiseMap *CTileBank::getTileNoiseMap (uint tileNumber, uint tileSubNoise)
}
}
if (_DisplacementMap.size()==0 || _DisplacementMap[0]._TileNoiseMap)
if (_DisplacementMap.empty() || _DisplacementMap[0]._TileNoiseMap)
return NULL;
// Checks

View file

@ -71,7 +71,7 @@ void CVegetableBlendLayerModel::render(IDriver *driver)
nlassert(VegetableManager);
if(SortBlocks.size()==0)
if(SortBlocks.empty())
return;
// Setup VegetableManager renderState (like pre-setuped material)

View file

@ -1019,12 +1019,12 @@ void CVegetableManager::reserveIgCompile(CVegetableInstanceGroup *ig, const CV
{
CVegetableInstanceGroup::CVegetableRdrPass &vegetRdrPass= ig->_RdrPass[rdrPass];
nlassert(vegetRdrPass.TriangleIndices.getNumIndexes()==0);
nlassert(vegetRdrPass.TriangleLocalIndices.size()==0);
nlassert(vegetRdrPass.Vertices.size()==0);
nlassert(vegetRdrPass.LightedInstances.size()==0);
nlassert(vegetRdrPass.TriangleLocalIndices.empty());
nlassert(vegetRdrPass.Vertices.empty());
nlassert(vegetRdrPass.LightedInstances.empty());
}
// Do the same for all quadrants of the zsort rdrPass.
nlassert(ig->_TriangleQuadrantOrderArray.size()==0);
nlassert(ig->_TriangleQuadrantOrderArray.empty());
nlassert(ig->_TriangleQuadrantOrderNumTriangles==0);
@ -2553,7 +2553,7 @@ bool CVegetableManager::updateLightingIGPart()
}
CVegetableInstanceGroup::CVegetableRdrPass &vegetRdrPass= _ULRootIg->_RdrPass[_ULCurrentIgRdrPass];
// if all instances are processed for this pass (especially if size()==0 !!)
// if all instances are processed for this pass (especially if empty() !!)
if(_ULCurrentIgInstance>= vegetRdrPass.LightedInstances.size())
{
// skip to the next rdrPass.

View file

@ -186,7 +186,7 @@ bool CVegetableVBAllocator::exceedMaxVertexInBufferHard(uint numAddVerts) cons
uint CVegetableVBAllocator::allocateVertex()
{
// if no more free, allocate.
if( _VertexFreeMemory.size()==0 )
if( _VertexFreeMemory.empty() )
{
// enlarge capacity.
uint newResize;

View file

@ -500,7 +500,7 @@ void CWaterModel::traverseRender()
sint startY;
projPoly.computeBorders(rasters, startY);
if (rasters.size())
if (!rasters.empty())
{
//===========================//
// perform Water animation //

View file

@ -1126,7 +1126,7 @@ void CZone::refineAll()
{
nlassert(Compiled);
if(Patchs.size()==0)
if(Patchs.empty())
return;
// DO NOT do a forceNoRenderClip(), to avoid big allocation of Near/Far VB vertices in driver.
@ -1150,7 +1150,7 @@ void CZone::averageTesselationVertices()
{
nlassert(Compiled);
if(Patchs.size()==0)
if(Patchs.empty())
return;
// averageTesselationVertices of ALL patchs.
@ -1250,8 +1250,10 @@ void CZone::resetRenderFarAndDeleteVBFV()
void CZone::forceMergeAtTileLevel()
{
CPatch *pPatch=0;
if(Patchs.size()>0)
if (!Patchs.empty())
pPatch= &(*Patchs.begin());
for(sint n=(sint)Patchs.size();n>0;n--, pPatch++)
{
pPatch->forceMergeAtTileLevel();
@ -1446,7 +1448,7 @@ void CZone::applyHeightField(const CLandscape &landScape)
vector<CBezierPatch> patchs;
// no patch, do nothing.
if(Patchs.size()==0)
if(Patchs.empty())
return;
// 0. Unpack patchs to Bezier Patchs.

View file

@ -3113,7 +3113,7 @@ void CZoneLighter::addWaterShape(CWaterShape *shape, const NLMISC::CMatrix &MT)
// ***********************************************************
void CZoneLighter::makeQuadGridFromWaterShapes(NLMISC::CAABBox zoneBBox)
{
if (!_WaterShapes.size()) return;
if (_WaterShapes.empty()) return;
NLMISC::CAABBox tmpBox;

View file

@ -159,7 +159,7 @@ namespace NLGUI
}
// resize H
if(entries.size()>0)
if (!entries.empty())
{
CInterfaceGroup *colEnclosing = entries[0]->getTargetColumn();
if (colEnclosing && !colEnclosing->getGroups().empty())

View file

@ -262,7 +262,7 @@ namespace NLGUI
{
tabB->setId(string("tab") + NLMISC::toString(_Buttons.size()));
if(_Buttons.size()==0)
if(_Buttons.empty())
{
tabB->setParentPos(NULL);
tabB->setParentPosRef(Hotspot_TL);
@ -453,7 +453,7 @@ namespace NLGUI
// ***************************************************************************
void CGroupTab::updateFirstTabButton()
{
if(!_HideOutTabs || (_Selection<0) || (_Buttons.size()==0) || (_Parent->getWReal()<0)
if(!_HideOutTabs || (_Selection<0) || _Buttons.empty() || (_Parent->getWReal()<0)
|| _FirstTabIndex>=(sint)_Buttons.size())
return;

View file

@ -193,7 +193,7 @@ namespace NLGUI
xmlKeepBlanksDefault(0);
//parse all interface files and build a single xml document
xmlNodePtr globalEnclosing;
nlassert (strings.size());
nlassert (!strings.empty());
CIXml read;
string nextFileName;
static const char *SCRIPT_AS_STRING = "<script as string>";

View file

@ -1218,7 +1218,7 @@ const IPrimitive *IPrimitive::getPrimitive (const std::string &absoluteOrRelativ
path.erase(0,2);
}
while (path.size()>0)
while (!path.empty())
{
if (path.find("/")==0)
{

View file

@ -278,7 +278,7 @@ ICDBNode * CCDBNodeBranch::getNode (const CTextId& id, bool bCreate)
{
// Yoyo: must not be SERVER or LOCAL, cause definied through xml.
// This may cause some important crash error
//nlassert(id.size()>0);
//nlassert(!id.empty());
//nlassert(id.getElement(0)!="SERVER");
//nlassert(id.getElement(0)!="LOCAL");
ICDBNode *newNode;

View file

@ -105,7 +105,7 @@ void CPolygon::clip(const CPlane *planes, uint nPlanes)
// ***************************************************************************
void CPolygon::clip(const std::vector<CPlane> &planes)
{
if(planes.size()==0)
if(planes.empty())
return;
clip(&(*planes.begin()), (uint)planes.size());
}

View file

@ -139,7 +139,7 @@ bool CSystemUtils::updateProgressBar(uint value, uint total)
bool CSystemUtils::copyTextToClipboard(const ucstring &text)
{
if (!text.size()) return false;
if (text.empty()) return false;
bool res = false;

View file

@ -430,7 +430,7 @@ void serviceGetView (uint32 rid, const string &rawvarpath, TAdminViewResult &ans
else
{
if (strs.size()>0)
if (!strs.empty())
{
str = strs[0].substr(0,strs[0].size()-1);
// replace all spaces into udnerscore because space is a reserved char
@ -717,7 +717,7 @@ void updateAdmin()
ICommand::execute(Alarms[i].Name, logDisplayVars, true, false);
const std::deque<std::string> &strs = mdDisplayVars.lockStrings();
if (strs.size()>0)
if (!strs.empty())
{
str = strs[0].substr(0,strs[0].size()-1);
}

View file

@ -155,7 +155,7 @@ bool CBufSock::flush( uint *nbBytesRemaining )
{
SendFifo.front( tmpbuffer, size );
}
while ( ! SendFifo.empty() && ( (_ReadyToSendBuffer.size()==0) || (_ReadyToSendBuffer.size() +size < MaxTCPPacketSize) ) )
while ( ! SendFifo.empty() && ( _ReadyToSendBuffer.empty() || (_ReadyToSendBuffer.size() +size < MaxTCPPacketSize) ) )
{
// Compute the size and add it into the beginning of the buffer
netlen = htonl( (TBlockSize)size );
@ -252,7 +252,7 @@ bool CBufSock::flush( uint *nbBytesRemaining )
}
}
while ( !SendFifo.empty() && _ReadyToSendBuffer.size()==0 );
while ( !SendFifo.empty() && _ReadyToSendBuffer.empty() );
return true;
}

View file

@ -288,7 +288,7 @@ string CLoginClient::confirmConnection(sint32 shardId)
// S05: create and send the "CS" message with the shardid choice to the LS
//
if (!ShardList.size())
if (ShardList.empty())
{
_LSCallbackClient->disconnect();
return "No shard available";
@ -358,7 +358,7 @@ string CLoginClient::selectShardBegin(sint32 shardId)
ShardChooseShardReason = "";
ShardChooseShard = false;
if (!ShardList.size())
if (ShardList.empty())
{
_LSCallbackClient->disconnect();
delete _LSCallbackClient;

View file

@ -420,7 +420,7 @@ bool CNamingClient::lookup (const std::string &name, CInetAddress &addr)
vector<CInetAddress> addrs;
find (name, addrs);
if (addrs.size()==0)
if (addrs.empty())
return false;
nlassert (addrs.size()==1);
@ -436,7 +436,7 @@ bool CNamingClient::lookup (TServiceId sid, CInetAddress &addr)
vector<CInetAddress> addrs;
find (sid, addrs);
if (addrs.size()==0)
if (addrs.empty())
return false;
nlassert (addrs.size()==1);
@ -465,7 +465,7 @@ bool CNamingClient::lookupAlternate (const std::string &name, CInetAddress &addr
vector<CInetAddress> addrs;
find (name, addrs);
if (addrs.size()==0)
if (addrs.empty())
return false;
nlassert (addrs.size()==1);

View file

@ -1460,7 +1460,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName,
mdDisplayVars.clear ();
ICommand::execute(varName, logDisplayVars, true);
const std::deque<std::string> &strs = mdDisplayVars.lockStrings();
if (strs.size()>0)
if (!strs.empty())
{
str += strs[0].substr(0,strs[0].size()-1);
}

View file

@ -197,7 +197,7 @@ CSoundDriverAL::~CSoundDriverAL()
// Remove the allocated (but not exported) source and buffer names-
// Release internal resources of all remaining ISource instances
if (_Sources.size())
if (!_Sources.empty())
{
nlwarning("AL: _Sources.size(): '%u'", (uint32)_Sources.size());
set<CSourceAL *>::iterator it(_Sources.begin()), end(_Sources.end());
@ -206,7 +206,7 @@ CSoundDriverAL::~CSoundDriverAL()
}
if (!_Buffers.empty()) alDeleteBuffers(compactAliveNames(_Buffers, alIsBuffer), &*_Buffers.begin());
// Release internal resources of all remaining IEffect instances
if (_Effects.size())
if (!_Effects.empty())
{
nlwarning("AL: _Effects.size(): '%u'", (uint32)_Effects.size());
set<CEffectAL *>::iterator it(_Effects.begin()), end(_Effects.end());

View file

@ -254,7 +254,7 @@ bool CSourceAL::play()
if (!_IsPlaying) // set start time if not playing yet
_StartTime = CTime::getLocalTime();
_IsPlaying = true; // this play always virtually succeed but may not actually be playing
if (_QueuedBuffers.size()) // ensure buffers have actually queued
if (!_QueuedBuffers.empty()) // ensure buffers have actually queued
{
alSourcePlay(_Source);
if (alGetError() != AL_NO_ERROR)
@ -306,7 +306,7 @@ void CSourceAL::stop()
alSourceStop(_Source);
alTestError();
// unqueue buffers
while (_QueuedBuffers.size())
while (!_QueuedBuffers.empty())
{
ALuint bufferName = _QueuedBuffers.front()->bufferName();
alSourceUnqueueBuffers(_Source, 1, &bufferName);

View file

@ -215,7 +215,7 @@ void CSoundDriverXAudio2::release()
// the created instances must still be released by the user!
// Release internal resources of all remaining ISource instances
if (_Sources.size())
if (!_Sources.empty())
{
nlwarning(NLSOUND_XAUDIO2_PREFIX "_Sources.size(): '%u'", (uint32)_Sources.size());
set<CSourceXAudio2 *>::iterator it(_Sources.begin()), end(_Sources.end());
@ -223,7 +223,7 @@ void CSoundDriverXAudio2::release()
_Sources.clear();
}
// Release internal resources of all remaining IBuffer instances
if (_Buffers.size())
if (!_Buffers.empty())
{
nlwarning(NLSOUND_XAUDIO2_PREFIX "_Buffers.size(): '%u'", (uint32)_Buffers.size());
set<CBufferXAudio2 *>::iterator it(_Buffers.begin()), end(_Buffers.end());
@ -231,7 +231,7 @@ void CSoundDriverXAudio2::release()
_Buffers.clear();
}
// Release internal resources of all remaining IEffect instances
if (_Effects.size())
if (!_Effects.empty())
{
nlwarning(NLSOUND_XAUDIO2_PREFIX "_Effects.size(): '%u'", (uint32)_Effects.size());
set<CEffectXAudio2 *>::iterator it(_Effects.begin()), end(_Effects.end());

View file

@ -672,7 +672,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", "<AddScreenshot>
sys = "Language "+CI18N::getCurrentLanguageName().toString() +" ";
if (args.size()>0)
if (!args.empty())
{
uint8 quality;
fromString(args[0], quality);
@ -1205,9 +1205,9 @@ static bool talkInChan(uint32 nb,std::vector<std::string>args)
{
return false;
}
if(args.size()>0)
if(!args.empty())
{
std::string tmp="";
std::string tmp;
std::vector<std::string>::const_iterator first(args.begin()),last(args.end());
for(;first!=last;++first)

View file

@ -1604,7 +1604,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText)
}
// append a \n before
if(mbInfo.size())
if(!mbInfo.empty())
{
// add spell level header
ucstring spellRuleFmt= CI18N::get("uihelpItemMagicBonusHeader");

View file

@ -105,7 +105,8 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn
// get the family of item plan (for selection) from the rootBrick. It is stored in the Property0.
_FaberPlanBrickFamilies.clear();
if(rootBrick->Properties.size()>0)
if (!rootBrick->Properties.empty())
{
string prop= NLMISC::toUpper(rootBrick->Properties[0].Text);
vector<string> strList;

View file

@ -639,8 +639,8 @@ void CDBCtrlSheet::initSheet(const std::string &dbBranchId, const CCtrlSheetInfo
{
H_AUTO ( RZ_CDBCtrlSheet_initSheet )
nlassert((ctrlInfo._Type == SheetType_Macro) || (dbBranchId.size()>0));
nlassert((ctrlInfo._Type == SheetType_Macro) || (_Id.size()>0));
nlassert((ctrlInfo._Type == SheetType_Macro) || !dbBranchId.empty());
nlassert((ctrlInfo._Type == SheetType_Macro) || !_Id.empty());
// init
*static_cast<CCtrlSheetInfo*>(this)= ctrlInfo;

View file

@ -3021,7 +3021,7 @@ void CGroupMap::addRespawnPoints(const CRespawnPointsMsg &rpm)
for (uint32 i = 0; i < rpm.RespawnPoints.size(); ++i)
_RespawnPos.push_back(rpm.RespawnPoints[i]);
// Ensure there is at least one respawn point
// nlassert(_RespawnPos.size()>0);
// nlassert(!_RespawnPos.empty());
// Choose the good map ! (select the first respawn point and check for first matching bounding box map
if (_MapMode != MapMode_Death) return;

View file

@ -643,7 +643,7 @@ void CInterfaceManager::initLogin()
ActionsContext.addActionsManager(&EditActions, RZ_CATEGORY_EDIT);
if (ClientCfg.XMLLoginInterfaceFiles.size()==0)
if (ClientCfg.XMLLoginInterfaceFiles.empty())
{
nlinfo("no xml login config files in client.cfg");
return;
@ -729,7 +729,7 @@ void CInterfaceManager::initOutGame()
//NLMEMORY::CheckHeap (true);
if (ClientCfg.XMLOutGameInterfaceFiles.size()==0)
if (ClientCfg.XMLOutGameInterfaceFiles.empty())
{
nlinfo("no xml outgame config files in client.cfg");
return;
@ -889,7 +889,7 @@ void CInterfaceManager::initInGame()
// NLMEMORY::CheckHeap (true);
if (ClientCfg.XMLInterfaceFiles.size()==0)
if (ClientCfg.XMLInterfaceFiles.empty())
{
nlinfo("no xml config files in client.cfg");
return;

View file

@ -1346,7 +1346,7 @@ sint CSPhraseManager::getPhraseSuccessRate(const CSPhraseCom &phrase)
CSBrickManager *pBM= CSBrickManager::getInstance();
CSkillManager *pSM= CSkillManager::getInstance();
if(phrase.Bricks.size()==0)
if(phrase.Bricks.empty())
return 0;
CSBrickSheet *rootBrick= pBM->getBrick(phrase.Bricks[0]);
if(!rootBrick)
@ -1432,7 +1432,7 @@ sint CSPhraseManager::getCraftPhraseSuccessRate(const CSPhraseCom &phrase, SK
{
CSkillManager *pSM= CSkillManager::getInstance();
if(phrase.Bricks.size()==0)
if(phrase.Bricks.empty())
return 0;
// take skill value of the skill
@ -1450,7 +1450,7 @@ sint CSPhraseManager::getForageExtractionPhraseSuccessRate(const CSPhraseCom
{
CSkillManager *pSM= CSkillManager::getInstance();
if(phrase.Bricks.size()==0)
if(phrase.Bricks.empty())
return 0;
// take skill value of the skill
@ -1505,7 +1505,7 @@ void CSPhraseManager::getPhraseCastTime(const CSPhraseCom &phrase, uint32 tot
castTime= 0;
castTimeMalus= 0;
if(phrase.Bricks.size()==0)
if(phrase.Bricks.empty())
return;
CSBrickSheet *rootBrick= pBM->getBrick(phrase.Bricks[0]);
if(!rootBrick)
@ -1576,7 +1576,7 @@ void CSPhraseManager::getPhraseMagicRange(const CSPhraseCom &phrase, uint32 t
range= 0;
rangeMalus= 0;
if(phrase.Bricks.size()==0)
if(phrase.Bricks.empty())
return;
CSBrickSheet *rootBrick= pBM->getBrick(phrase.Bricks[0]);
if(!rootBrick)

View file

@ -978,7 +978,7 @@ bool login()
void removeSpace(string &s)
{
uint i = 0;
while (s.size()>0)
while (!s.empty())
{
if (s[i] == ' ')
s.erase(i, 1);

View file

@ -370,7 +370,7 @@ private:
ServerPath = serverPath;
Available = true;
if (ServerPath.size()>0 && ServerPath[ServerPath.size()-1] != '/')
if (!ServerPath.empty() && ServerPath[ServerPath.size()-1] != '/')
ServerPath += '/';
std::string::size_type pos = ServerPath.find ("@");

View file

@ -111,7 +111,7 @@ bool CMovieShooter::addFrame(double time, UDriver *pDriver)
nlassert(bitmap.getPixelFormat()==CBitmap::RGBA);
// add the frame.
if(bitmap.getPixels().size()==0)
if(bitmap.getPixels().empty())
return false;
return addFrame(time, (CRGBA*)(&bitmap.getPixels()[0]), bitmap.getWidth(), bitmap.getHeight());
}

View file

@ -2499,7 +2499,7 @@ void impulseRemoteAdmin (NLMISC::CBitMemStream &impulse)
}
else
{
if (strs.size()>0)
if (!strs.empty())
{
str = strs[0].substr(0,strs[0].size()-1);
// replace all spaces into underscore because space is a reserved char

View file

@ -5808,7 +5808,7 @@ void CEditor::scenarioUpdated(CObject* highLevel, bool willTP, uint32 initialAct
playerPos.y <= ci.YMin ||
playerPos.y >= ci.YMax)
{
if(ci.EntryPoints.size()>0)
if(!ci.EntryPoints.empty())
{
const CScenarioEntryPoints::CShortEntryPoint & shortEntryPoint = ci.EntryPoints[0];
CVector dest((float) shortEntryPoint.X, (float) shortEntryPoint.Y, 0.f);

View file

@ -63,14 +63,14 @@ void CToolPick::setIgnoreInstances(const std::string & ignoreInstances)
allKind = allKind.substr(e+1,allKind.size());
}
while(tmp.size()>0 && tmp[0]==' ')
while(!tmp.empty() && tmp[0]==' ')
{
if(tmp.size()==1)
tmp="";
else
tmp = tmp.substr(1,tmp.size());
}
while(tmp.size()>0 && tmp[tmp.size()]==' ')
while(!tmp.empty() && tmp[tmp.size()]==' ')
{
if(tmp.size()==1)
tmp="";
@ -98,7 +98,7 @@ void CToolPick::updateAfterRender()
_CandidateInstance = NULL;
CInstance *instanceUnder = checkInstanceUnderMouse();
bool ignoreInstanceUnder = false;
if(instanceUnder && _IgnoreInstances.size()>0)
if(instanceUnder && !_IgnoreInstances.empty())
{
for(uint i=0; i<_IgnoreInstances.size(); i++)
{

View file

@ -425,7 +425,7 @@ void CScenarioEntryPoints::loadFromXMLFile()
}
if(entryPoints.size()>0)
if(!entryPoints.empty())
{
completeIsland.EntryPoints = entryPoints;
_CompleteIslands.push_back(completeIsland);