Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
kervala 9 years ago
commit 86084649a2

@ -163,7 +163,7 @@ public:
/** There is (OrderS/2+1) * (OrderT/2+1) tiles light influence. /** 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). * 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). * size() == (OrderS/2+1) * (OrderT/2+1).
* *
* They are stored in line first order, from S=0 to 1, and T=0 to 1. * They are stored in line first order, from S=0 to 1, and T=0 to 1.

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

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

@ -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) void CDRU::drawTrianglesUnlit(const std::vector<NLMISC::CTriangleUV> &trilist, CMaterial &mat, IDriver& driver)
{ {
if(trilist.size()==0) if(trilist.empty())
return; return;
CDRU::drawTrianglesUnlit( &(*trilist.begin()), (uint)trilist.size(), mat, driver); 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) void CDRU::drawLinesUnlit(const std::vector<NLMISC::CLine> &linelist, CMaterial &mat, IDriver& driver)
{ {
if(linelist.size()==0) if(linelist.empty())
return; return;
CDRU::drawLinesUnlit( &(*linelist.begin()), (sint)linelist.size(), mat, driver); CDRU::drawLinesUnlit( &(*linelist.begin()), (sint)linelist.size(), mat, driver);
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1994,7 +1994,7 @@ void CPSConstraintMesh::deleteElement(uint32 index)
deleteSizeElement(index); deleteSizeElement(index);
deletePlaneBasisElement(index); deletePlaneBasisElement(index);
// TODO : avoid code cuplication with CPSFace ... // 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... // replace ourself by the last element...
_IndexInPrecompBasis[index] = _IndexInPrecompBasis[_Owner->getSize() - 1]; _IndexInPrecompBasis[index] = _IndexInPrecompBasis[_Owner->getSize() - 1];
@ -2011,7 +2011,7 @@ void CPSConstraintMesh::resize(uint32 size)
resizeSize(size); resizeSize(size);
resizePlaneBasis(size); resizePlaneBasis(size);
// TODO : avoid code cuplication with CPSFace ... // 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); _IndexInPrecompBasis.resize(size);
} }

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

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

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

@ -108,7 +108,7 @@ void CTileBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
if (f.isReading()) if (f.isReading())
{ {
// Checks // Checks
nlassert (_DisplacementMap.size()>0); nlassert (!_DisplacementMap.empty());
// Set first empty // Set first empty
_DisplacementMap[0].setEmpty (); _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; return NULL;
// Checks // Checks

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -155,7 +155,7 @@ bool CBufSock::flush( uint *nbBytesRemaining )
{ {
SendFifo.front( tmpbuffer, size ); 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 // Compute the size and add it into the beginning of the buffer
netlen = htonl( (TBlockSize)size ); 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; return true;
} }

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

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

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

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

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

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

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

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

@ -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. // get the family of item plan (for selection) from the rootBrick. It is stored in the Property0.
_FaberPlanBrickFamilies.clear(); _FaberPlanBrickFamilies.clear();
if(rootBrick->Properties.size()>0)
if (!rootBrick->Properties.empty())
{ {
string prop= NLMISC::toUpper(rootBrick->Properties[0].Text); string prop= NLMISC::toUpper(rootBrick->Properties[0].Text);
vector<string> strList; vector<string> strList;

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

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

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

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

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

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

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

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

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

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

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

@ -38,6 +38,8 @@ extern NLMISC::CCmdArgs Args;
CClientConfigDialog::CClientConfigDialog( QWidget *parent ) : CClientConfigDialog::CClientConfigDialog( QWidget *parent ) :
QDialog( parent ) QDialog( parent )
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setupUi( this ); setupUi( this );
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL( clicked() ), this, SLOT( close() ) ); connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL( clicked() ), this, SLOT( close() ) );
connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), this, SLOT( onClickOK() ) ); connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), this, SLOT( onClickOK() ) );

@ -33,6 +33,7 @@ CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(
{ {
s_instance = this; s_instance = this;
m_language = QLocale::system().name().left(2); // only keep language ISO 639 code
m_defaultConfigPath = QApplication::applicationDirPath() + "/installer.ini"; m_defaultConfigPath = QApplication::applicationDirPath() + "/installer.ini";
m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/installer.ini"; m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/installer.ini";
} }
@ -52,7 +53,7 @@ bool CConfigFile::load(const QString &filename)
QSettings settings(filename, QSettings::IniFormat); QSettings settings(filename, QSettings::IniFormat);
settings.beginGroup("common"); settings.beginGroup("common");
m_language = settings.value("language").toString(); m_language = settings.value("language", m_language).toString();
m_srcDirectory = settings.value("source_directory").toString(); m_srcDirectory = settings.value("source_directory").toString();
m_installationDirectory = settings.value("installation_directory").toString(); m_installationDirectory = settings.value("installation_directory").toString();
m_use64BitsClient = settings.value("use_64bits_client").toBool(); m_use64BitsClient = settings.value("use_64bits_client").toBool();
@ -82,13 +83,19 @@ bool CConfigFile::load(const QString &filename)
server.clientDownloadFilename = settings.value("client_download_filename").toString(); server.clientDownloadFilename = settings.value("client_download_filename").toString();
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
server.clientFilename = settings.value("client_filename_windows").toString(); server.clientFilename = settings.value("client_filename_windows").toString();
server.clientFilenameOld = settings.value("client_filename_old_windows").toString();
server.configurationFilename = settings.value("configuration_filename_windows").toString(); server.configurationFilename = settings.value("configuration_filename_windows").toString();
server.installerFilename = settings.value("installer_filename_windows").toString();
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
server.clientFilename = settings.value("client_filename_osx").toString(); server.clientFilename = settings.value("client_filename_osx").toString();
server.clientFilenameOld = settings.value("client_filename_old_osx").toString();
server.configurationFilename = settings.value("configuration_filename_osx").toString(); server.configurationFilename = settings.value("configuration_filename_osx").toString();
server.installerFilename = settings.value("installer_filename_osx").toString();
#else #else
server.clientFilename = settings.value("client_filename_linux").toString(); server.clientFilename = settings.value("client_filename_linux").toString();
server.clientFilenameOld = settings.value("client_filename_old_linux").toString();
server.configurationFilename = settings.value("configuration_filename_linux").toString(); server.configurationFilename = settings.value("configuration_filename_linux").toString();
server.installerFilename = settings.value("installer_filename_linux").toString();
#endif #endif
server.comments = settings.value("comments").toString(); server.comments = settings.value("comments").toString();
@ -157,13 +164,19 @@ bool CConfigFile::save() const
settings.setValue("client_download_filename", server.clientDownloadFilename); settings.setValue("client_download_filename", server.clientDownloadFilename);
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
settings.setValue("client_filename_windows", server.clientFilename); settings.setValue("client_filename_windows", server.clientFilename);
settings.setValue("client_filename_old_windows", server.clientFilenameOld);
settings.setValue("configuration_filename_windows", server.configurationFilename); settings.setValue("configuration_filename_windows", server.configurationFilename);
settings.setValue("installer_filename_windows", server.installerFilename);
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
settings.setValue("client_filename_osx", server.clientFilename); settings.setValue("client_filename_osx", server.clientFilename);
settings.setValue("client_filename_old_osx", server.clientFilenameOld);
settings.setValue("configuration_filename_osx", server.configurationFilename); settings.setValue("configuration_filename_osx", server.configurationFilename);
settings.setValue("installer_filename_osx", server.installerFilename);
#else #else
settings.setValue("client_filename_linux", server.clientFilename); settings.setValue("client_filename_linux", server.clientFilename);
settings.setValue("client_filename_old_linux", server.clientFilenameOld);
settings.setValue("configuration_filename_linux", server.configurationFilename); settings.setValue("configuration_filename_linux", server.configurationFilename);
settings.setValue("installer_filename_linux", server.installerFilename);
#endif #endif
settings.setValue("comments", server.comments); settings.setValue("comments", server.comments);
@ -398,6 +411,51 @@ QString CConfigFile::getOldInstallationDirectory()
#endif #endif
} }
QString CConfigFile::getOldInstallationLanguage()
{
#if defined(Q_OS_WIN)
// NSIS previous official installer
#ifdef Q_OS_WIN64
// use WOW6432Node in 64 bits (64 bits OS and 64 bits Installer) because Ryzom old installer was in 32 bits
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\WOW6432Node\\Nevrax\\Ryzom", QSettings::NativeFormat);
#else
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Nevrax\\Ryzom", QSettings::NativeFormat);
#endif
if (settings.contains("Language"))
{
QString languageCode = settings.value("Language").toString();
// 1036 = French (France), 1033 = English (USA), 1031 = German
if (languageCode == "1036") return "fr";
if (languageCode == "1031") return "de";
if (languageCode == "1033") return "en";
}
#endif
return "";
}
QString CConfigFile::getNewInstallationLanguage()
{
#if defined(Q_OS_WIN)
// NSIS new official installer
#ifdef Q_OS_WIN64
// use WOW6432Node in 64 bits (64 bits OS and 64 bits Installer) because Ryzom old installer was in 32 bits
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\WOW6432Node\\Nevrax\\Ryzom", QSettings::NativeFormat);
#else
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Nevrax\\Ryzom", QSettings::NativeFormat);
#endif
if (settings.contains("Ryzom Install Path"))
{
return QDir::fromNativeSeparators(settings.value("Ryzom Install Path").toString());
}
#endif
return "";
}
QString CConfigFile::getNewInstallationDirectory() QString CConfigFile::getNewInstallationDirectory()
{ {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
@ -421,8 +479,8 @@ bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const
// at least 200 BNP in data directory // at least 200 BNP in data directory
if (dir.entryList(QStringList() << "*.bnp", QDir::Files).size() < 200) return false; if (dir.entryList(QStringList() << "*.bnp", QDir::Files).size() < 200) return false;
// fonts.bnp is required // ryzom.ttf or fonts.bnp is required
if (!dir.exists("fonts.bnp")) return false; if (!dir.exists("fonts/ryzom.ttf") && !dir.exists("fonts.bnp")) return false;
// gamedev.bnp is required // gamedev.bnp is required
if (!dir.exists("gamedev.bnp")) return false; if (!dir.exists("gamedev.bnp")) return false;
@ -445,10 +503,19 @@ bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
// client_default.cfg doesn't exist // client_default.cfg doesn't exist
if (!dir.exists("client_default.cfg")) return false; if (!dir.exists("client_default.cfg")) return false;
QString clientFilename = getServer().clientFilename; // current server
CServer server = getServer();
// check if client is defined and exists QString clientFilename = server.clientFilename;
if (!clientFilename.isEmpty() && !dir.exists(clientFilename)) return false;
// check if new client is defined and exists
if (!clientFilename.isEmpty() && !dir.exists(clientFilename))
{
clientFilename = server.clientFilenameOld;
// check if old client is defined and exists
if (!dir.exists(clientFilename)) return false;
}
// TODO: more checks // TODO: more checks
@ -525,7 +592,22 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
// only show wizard if installation directory undefined // only show wizard if installation directory undefined
if (getInstallationDirectory().isEmpty()) if (getInstallationDirectory().isEmpty())
{ {
return ShowWizard; // if launched from current directory, it means we just patched files
QString currentDirectory = getCurrentDirectory();
if (!isRyzomInstalledIn(currentDirectory))
{
// Ryzom is in the same directory as Ryzom Installer
currentDirectory = getApplicationDirectory();
if (!isRyzomInstalledIn(currentDirectory))
{
currentDirectory.clear();
}
}
// install or migrate depending if Ryzom was found in current directory
return currentDirectory.isEmpty() ? ShowInstallWizard:ShowMigrateWizard;
} }
QString serverDirectory = getInstallationDirectory() + "/" + server.id; QString serverDirectory = getInstallationDirectory() + "/" + server.id;
@ -575,7 +657,7 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
} }
else else
{ {
return ShowWizard; return ShowInstallWizard;
} }
} }
@ -591,21 +673,25 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
{ {
return ExtractBnpClient; return ExtractBnpClient;
} }
else
{
QString clientFile = getInstallationDirectory() + "/" + server.clientDownloadFilename;
// when file is not finished, it has .part extension QString clientFile = getInstallationDirectory() + "/" + server.clientDownloadFilename;
if (!QFile::exists(clientFile))
{
return DownloadClient;
}
return ExtractDownloadedClient; // when file is not finished, it has .part extension
if (!QFile::exists(clientFile))
{
return DownloadClient;
} }
return ExtractDownloadedClient;
} }
} }
// if installer not found in installation directory, extract it from BNP
if (!QFile::exists(getInstallationDirectory() + "/" + server.installerFilename))
{
return CopyInstaller;
}
// no default profile // no default profile
if (profile.id.isEmpty()) if (profile.id.isEmpty())
{ {
@ -626,5 +712,12 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
return CreateShortcuts; return CreateShortcuts;
} }
#ifdef Q_OS_WIN
// check that Add/Remove entry is created under Windows
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat);
if (!settings.contains("InstallLocation")) return CreateAddRemoveEntry;
#endif
return Done; return Done;
} }

@ -35,7 +35,9 @@ struct CServer
QString clientDownloadUrl; QString clientDownloadUrl;
QString clientDownloadFilename; QString clientDownloadFilename;
QString clientFilename; QString clientFilename;
QString clientFilenameOld;
QString configurationFilename; QString configurationFilename;
QString installerFilename;
QString comments; QString comments;
}; };
@ -80,7 +82,8 @@ public:
enum InstallationStep enum InstallationStep
{ {
DisplayNoServerError, DisplayNoServerError,
ShowWizard, ShowInstallWizard,
ShowMigrateWizard,
DownloadData, DownloadData,
ExtractDownloadedData, ExtractDownloadedData,
DownloadClient, DownloadClient,
@ -89,8 +92,10 @@ public:
CopyProfileFiles, CopyProfileFiles,
CleanFiles, CleanFiles,
ExtractBnpClient, ExtractBnpClient,
CopyInstaller,
CreateProfile, CreateProfile,
CreateShortcuts, CreateShortcuts,
CreateAddRemoveEntry,
Done Done
}; };
@ -144,10 +149,14 @@ public:
static QString getApplicationDirectory(); static QString getApplicationDirectory();
static QString getOldInstallationDirectory(); static QString getOldInstallationDirectory();
static QString getNewInstallationDirectory(); static QString getNewInstallationDirectory();
static QString getOldInstallationLanguage();
static QString getNewInstallationLanguage();
// status of installation
bool isRyzomInstalledIn(const QString &directory) const; bool isRyzomInstalledIn(const QString &directory) const;
bool areRyzomDataInstalledIn(const QString &directory) const; bool areRyzomDataInstalledIn(const QString &directory) const;
bool isRyzomClientInstalledIn(const QString &directory) const; bool isRyzomClientInstalledIn(const QString &directory) const;
bool foundTemporaryFiles(const QString &directory) const; bool foundTemporaryFiles(const QString &directory) const;
bool shouldCreateDesktopShortcut() const; bool shouldCreateDesktopShortcut() const;

@ -38,7 +38,7 @@ void CFilesCopier::setSourceDirectory(const QString &src)
m_sourceDirectory = src; m_sourceDirectory = src;
} }
void CFilesCopier::setDesinationDirectory(const QString &dst) void CFilesCopier::setDestinationDirectory(const QString &dst)
{ {
m_destinationDirectory = dst; m_destinationDirectory = dst;
} }
@ -48,9 +48,9 @@ void CFilesCopier::setIncludeFilter(const QStringList &filter)
m_includeFilter = filter; m_includeFilter = filter;
} }
void CFilesCopier::setExcludeFilter(const QStringList &filter) void CFilesCopier::addFile(const QString &filename)
{ {
m_excludeFilter = filter; m_files << filename;
} }
bool CFilesCopier::exec() bool CFilesCopier::exec()
@ -127,6 +127,24 @@ void CFilesCopier::getFilesList(FilesToCopy &files)
files << file; files << file;
} }
} }
// copy additional files
foreach(const QString &fullpath, m_files)
{
QFileInfo fileInfo(fullpath);
if (fileInfo.isFile())
{
FileToCopy file;
file.filename = fileInfo.fileName();
file.src = fileInfo.filePath();
file.dst = m_destinationDirectory + "/" + fileInfo.fileName();
file.size = fileInfo.size();
file.date = fileInfo.lastModified().toTime_t();
files << file;
}
}
} }
bool CFilesCopier::copyFiles(const FilesToCopy &files) bool CFilesCopier::copyFiles(const FilesToCopy &files)

@ -32,10 +32,11 @@ public:
virtual ~CFilesCopier(); virtual ~CFilesCopier();
void setSourceDirectory(const QString &src); void setSourceDirectory(const QString &src);
void setDesinationDirectory(const QString &src); void setDestinationDirectory(const QString &src);
void setIncludeFilter(const QStringList &filter); void setIncludeFilter(const QStringList &filter);
void setExcludeFilter(const QStringList &filter);
void addFile(const QString &file);
bool exec(); bool exec();
@ -61,7 +62,7 @@ protected:
QString m_destinationDirectory; QString m_destinationDirectory;
QStringList m_includeFilter; QStringList m_includeFilter;
QStringList m_excludeFilter; QStringList m_files;
}; };
#endif #endif

@ -15,8 +15,9 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h" #include "stdpch.h"
#include "wizarddialog.h" #include "installwizarddialog.h"
#include "configfile.h" #include "configfile.h"
#include "utils.h"
#include "nel/misc/system_info.h" #include "nel/misc/system_info.h"
#include "nel/misc/common.h" #include "nel/misc/common.h"
@ -25,63 +26,17 @@
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
QString qBytesToHumanReadable(qint64 bytes) CInstallWizardDialog::CInstallWizardDialog():QDialog()
{
static std::vector<std::string> units;
if (units.empty())
{
units.push_back(QObject::tr("B").toUtf8().constData());
units.push_back(QObject::tr("KiB").toUtf8().constData());
units.push_back(QObject::tr("MiB").toUtf8().constData());
units.push_back(QObject::tr("GiB").toUtf8().constData());
units.push_back(QObject::tr("TiB").toUtf8().constData());
units.push_back(QObject::tr("PiB").toUtf8().constData());
}
return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str());
}
CWizardDialog::CWizardDialog():QDialog()
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setupUi(this); setupUi(this);
currentDirectoryRadioButton->setVisible(false);
oldDirectoryRadioButton->setVisible(false); oldDirectoryRadioButton->setVisible(false);
// enable download radio button by default // enable download radio button by default
internetRadioButton->setChecked(true); internetRadioButton->setChecked(true);
// if launched from current directory, it means we just patched files
m_currentDirectory = CConfigFile::getInstance()->getCurrentDirectory();
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{
// current directory is a child of Ryzom root directory
m_currentDirectory = CConfigFile::getInstance()->getParentDirectory();
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{
// Ryzom is in the same directory as Ryzom Installer
m_currentDirectory = CConfigFile::getInstance()->getApplicationDirectory();
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{
m_currentDirectory.clear();
}
}
}
// display found directory
if (!m_currentDirectory.isEmpty())
{
currentDirectoryRadioButton->setText(tr("Current directory: %1").arg(m_currentDirectory));
currentDirectoryRadioButton->setVisible(true);
currentDirectoryRadioButton->setChecked(true);
}
m_oldDirectory = CConfigFile::getInstance()->getOldInstallationDirectory(); m_oldDirectory = CConfigFile::getInstance()->getOldInstallationDirectory();
// found a previous installation // found a previous installation
@ -89,8 +44,7 @@ CWizardDialog::CWizardDialog():QDialog()
{ {
oldDirectoryRadioButton->setText(tr("Old installation: %1").arg(m_oldDirectory)); oldDirectoryRadioButton->setText(tr("Old installation: %1").arg(m_oldDirectory));
oldDirectoryRadioButton->setVisible(true); oldDirectoryRadioButton->setVisible(true);
oldDirectoryRadioButton->setChecked(true);
if (m_currentDirectory.isEmpty()) oldDirectoryRadioButton->setChecked(true);
} }
updateAnotherLocationText(); updateAnotherLocationText();
@ -128,18 +82,18 @@ CWizardDialog::CWizardDialog():QDialog()
connect(advancedCheckBox, SIGNAL(stateChanged(int)), SLOT(onShowAdvancedParameters(int))); connect(advancedCheckBox, SIGNAL(stateChanged(int)), SLOT(onShowAdvancedParameters(int)));
} }
CWizardDialog::~CWizardDialog() CInstallWizardDialog::~CInstallWizardDialog()
{ {
} }
void CWizardDialog::onShowAdvancedParameters(int state) void CInstallWizardDialog::onShowAdvancedParameters(int state)
{ {
advancedFrame->setVisible(state != Qt::Unchecked); advancedFrame->setVisible(state != Qt::Unchecked);
adjustSize(); adjustSize();
} }
void CWizardDialog::onAnotherLocationBrowseButtonClicked() void CInstallWizardDialog::onAnotherLocationBrowseButtonClicked()
{ {
QString directory; QString directory;
@ -162,7 +116,7 @@ void CWizardDialog::onAnotherLocationBrowseButtonClicked()
updateAnotherLocationText(); updateAnotherLocationText();
} }
void CWizardDialog::onDestinationBrowseButtonClicked() void CInstallWizardDialog::onDestinationBrowseButtonClicked()
{ {
QString directory = QFileDialog::getExistingDirectory(this, tr("Please choose directory where to install Ryzom")); QString directory = QFileDialog::getExistingDirectory(this, tr("Please choose directory where to install Ryzom"));
@ -173,17 +127,17 @@ void CWizardDialog::onDestinationBrowseButtonClicked()
updateDestinationText(); updateDestinationText();
} }
void CWizardDialog::updateAnotherLocationText() void CInstallWizardDialog::updateAnotherLocationText()
{ {
anotherLocationRadioButton->setText(tr("Another location: %1").arg(m_anotherDirectory.isEmpty() ? tr("Undefined"):m_anotherDirectory)); anotherLocationRadioButton->setText(tr("Another location: %1").arg(m_anotherDirectory.isEmpty() ? tr("Undefined"):m_anotherDirectory));
} }
void CWizardDialog::updateDestinationText() void CInstallWizardDialog::updateDestinationText()
{ {
destinationLabel->setText(m_dstDirectory); destinationLabel->setText(m_dstDirectory);
} }
void CWizardDialog::accept() void CInstallWizardDialog::accept()
{ {
// check free disk space // check free disk space
qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData());
@ -196,11 +150,7 @@ void CWizardDialog::accept()
return; return;
} }
if (currentDirectoryRadioButton->isChecked()) if (oldDirectoryRadioButton->isChecked())
{
CConfigFile::getInstance()->setSrcServerDirectory(m_currentDirectory);
}
else if (oldDirectoryRadioButton->isChecked())
{ {
CConfigFile::getInstance()->setSrcServerDirectory(m_oldDirectory); CConfigFile::getInstance()->setSrcServerDirectory(m_oldDirectory);
} }

@ -14,10 +14,10 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef WIZARDDIALOG_H #ifndef INSTALLWIZARDDIALOG_H
#define WIZARDDIALOG_H #define INSTALLWIZARDDIALOG_H
#include "ui_wizard.h" #include "ui_installwizard.h"
/** /**
* Wizard displayed at first launch, that asks user to choose source and destination directories. * Wizard displayed at first launch, that asks user to choose source and destination directories.
@ -25,13 +25,13 @@
* \author Cedric 'Kervala' OCHS * \author Cedric 'Kervala' OCHS
* \date 2016 * \date 2016
*/ */
class CWizardDialog : public QDialog, public Ui::WizardDialog class CInstallWizardDialog : public QDialog, public Ui::InstallWizardDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CWizardDialog(); CInstallWizardDialog();
virtual ~CWizardDialog(); virtual ~CInstallWizardDialog();
private slots: private slots:
void onShowAdvancedParameters(int state); void onShowAdvancedParameters(int state);
@ -44,7 +44,6 @@ private:
void updateAnotherLocationText(); void updateAnotherLocationText();
void updateDestinationText(); void updateDestinationText();
QString m_currentDirectory;
QString m_oldDirectory; QString m_oldDirectory;
QString m_anotherDirectory; QString m_anotherDirectory;
QString m_dstDirectory; QString m_dstDirectory;

@ -17,7 +17,8 @@
#include "stdpch.h" #include "stdpch.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "configfile.h" #include "configfile.h"
#include "wizarddialog.h" #include "migratewizarddialog.h"
#include "installwizarddialog.h"
#include "operationdialog.h" #include "operationdialog.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
@ -57,6 +58,8 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
// TODO: parameters -u (uinstall) and -s (silent)
QApplication::setApplicationName("Ryzom"); QApplication::setApplicationName("Ryzom");
QApplication::setApplicationVersion(RYZOM_VERSION); QApplication::setApplicationVersion(RYZOM_VERSION);
QApplication::setWindowIcon(QIcon(":/icons/ryzom.ico")); QApplication::setWindowIcon(QIcon(":/icons/ryzom.ico"));
@ -89,13 +92,20 @@ int main(int argc, char *argv[])
bool displayMainWindow = true; bool displayMainWindow = true;
if (step == CConfigFile::ShowWizard) if (step == CConfigFile::ShowMigrateWizard)
{
CMigrateWizardDialog dialog;
if (!dialog.exec()) displayMainWindow = false;
}
else if (step == CConfigFile::ShowInstallWizard)
{ {
CWizardDialog dialog; CInstallWizardDialog dialog;
if (!dialog.exec()) displayMainWindow = false; if (!dialog.exec()) displayMainWindow = false;
} }
if (displayMainWindow) if (displayMainWindow)
{ {
step = config.getNextStep(); step = config.getNextStep();

@ -17,7 +17,6 @@
#include "stdpch.h" #include "stdpch.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "downloader.h" #include "downloader.h"
#include "wizarddialog.h"
#include "profilesdialog.h" #include "profilesdialog.h"
#include "configfile.h" #include "configfile.h"
#include "config.h" #include "config.h"
@ -27,7 +26,7 @@
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
CMainWindow::CMainWindow():QMainWindow(), m_statusLabel(NULL) CMainWindow::CMainWindow():QMainWindow()
{ {
setupUi(this); setupUi(this);
@ -48,13 +47,7 @@ CMainWindow::CMainWindow():QMainWindow(), m_statusLabel(NULL)
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onProfileChanged(int))); connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onProfileChanged(int)));
m_statusLabel = new QLabel();
statusBar()->addWidget(m_statusLabel);
updateProfiles(); updateProfiles();
// setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
} }
CMainWindow::~CMainWindow() CMainWindow::~CMainWindow()

@ -57,8 +57,6 @@ protected:
QWinTaskbarButton *m_button; QWinTaskbarButton *m_button;
CDownloader *m_downloader; CDownloader *m_downloader;
QLabel *m_statusLabel;
}; };
#endif #endif

@ -0,0 +1,128 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "migratewizarddialog.h"
#include "configfile.h"
#include "utils.h"
#include "nel/misc/system_info.h"
#include "nel/misc/common.h"
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
CMigrateWizardDialog::CMigrateWizardDialog():QDialog()
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setupUi(this);
// if launched from current directory, it means we just patched files
m_currentDirectory = CConfigFile::getInstance()->getCurrentDirectory();
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{
// Ryzom is in the same directory as Ryzom Installer
m_currentDirectory = CConfigFile::getInstance()->getApplicationDirectory();
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{
m_currentDirectory.clear();
}
}
m_dstDirectory = CConfigFile::getNewInstallationDirectory();
updateDestinationText();
// check whether OS architecture is 32 or 64 bits
// TODO: 64 bits client only supported under Vista+
if (CConfigFile::has64bitsOS())
{
clientArchGroupBox->setVisible(true);
clientArch64RadioButton->setChecked(true);
}
else
{
clientArchGroupBox->setVisible(false);
clientArch32RadioButton->setChecked(true);
}
const CServer &server = CConfigFile::getInstance()->getServer();
destinationGroupBox->setTitle(tr("Files will be installed to (requires %1):").arg(qBytesToHumanReadable(server.dataUncompressedSize)));
connect(destinationBrowseButton, SIGNAL(clicked()), SLOT(onDestinationBrowseButtonClicked()));
connect(continueButton, SIGNAL(clicked()), SLOT(accept()));
connect(quitButton, SIGNAL(clicked()), SLOT(reject()));
// TODO: if found a folder with initial data, get its total size and check if at least that size is free on the disk
// by default, advanced parameters are hidden
onShowAdvancedParameters(Qt::Unchecked);
connect(advancedCheckBox, SIGNAL(stateChanged(int)), SLOT(onShowAdvancedParameters(int)));
}
CMigrateWizardDialog::~CMigrateWizardDialog()
{
}
void CMigrateWizardDialog::onShowAdvancedParameters(int state)
{
advancedFrame->setVisible(state != Qt::Unchecked);
adjustSize();
}
void CMigrateWizardDialog::onDestinationBrowseButtonClicked()
{
QString directory = QFileDialog::getExistingDirectory(this, tr("Please choose directory where to install Ryzom"));
if (directory.isEmpty()) return;
m_dstDirectory = directory;
updateDestinationText();
}
void CMigrateWizardDialog::updateDestinationText()
{
destinationLabel->setText(m_dstDirectory);
}
void CMigrateWizardDialog::accept()
{
// check free disk space
qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData());
const CServer &server = CConfigFile::getInstance()->getServer();
if (freeSpace < server.dataUncompressedSize)
{
QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Not enough free disk space"), tr("You don't have enough free space on this disk, please make more space or choose a directory on another disk."));
return;
}
CConfigFile::getInstance()->setSrcServerDirectory(m_currentDirectory);
CConfigFile::getInstance()->setInstallationDirectory(m_dstDirectory);
CConfigFile::getInstance()->setUse64BitsClient(clientArch64RadioButton->isChecked());
CConfigFile::getInstance()->save();
QDialog::accept();
}

@ -0,0 +1,49 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef MIGRATEWIZARDDIALOG_H
#define MIGRATEWIZARDDIALOG_H
#include "ui_migratewizard.h"
/**
* Wizard displayed at first launch, that asks user to choose source and destination directories.
*
* \author Cedric 'Kervala' OCHS
* \date 2016
*/
class CMigrateWizardDialog : public QDialog, public Ui::MigrateWizardDialog
{
Q_OBJECT
public:
CMigrateWizardDialog();
virtual ~CMigrateWizardDialog();
private slots:
void onShowAdvancedParameters(int state);
void onDestinationBrowseButtonClicked();
void accept();
private:
void updateDestinationText();
QString m_currentDirectory;
QString m_dstDirectory;
};
#endif

@ -17,7 +17,6 @@
#include "stdpch.h" #include "stdpch.h"
#include "operationdialog.h" #include "operationdialog.h"
#include "downloader.h" #include "downloader.h"
#include "wizarddialog.h"
#include "profilesdialog.h" #include "profilesdialog.h"
#include "configfile.h" #include "configfile.h"
#include "config.h" #include "config.h"
@ -34,6 +33,10 @@
#include <QtWinExtras/QWinTaskbarButton> #include <QtWinExtras/QWinTaskbarButton>
#endif #endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
@ -58,7 +61,7 @@ COperationDialog::COperationDialog():QDialog(), m_aborting(false)
connect(m_downloader, SIGNAL(downloadInit(qint64, qint64)), SLOT(onProgressInit(qint64, qint64))); connect(m_downloader, SIGNAL(downloadInit(qint64, qint64)), SLOT(onProgressInit(qint64, qint64)));
connect(m_downloader, SIGNAL(downloadStart()), SLOT(onProgressStart())); connect(m_downloader, SIGNAL(downloadStart()), SLOT(onProgressStart()));
connect(m_downloader, SIGNAL(downloadStop()), SLOT(onProgressStop())); connect(m_downloader, SIGNAL(downloadStop()), SLOT(onProgressStop()));
connect(m_downloader, SIGNAL(downloadProgress(qint64)), SLOT(onProgressProgress(qint64))); connect(m_downloader, SIGNAL(downloadProgress(qint64, QString)), SLOT(onProgressProgress(qint64, QString)));
connect(m_downloader, SIGNAL(downloadSuccess(qint64)), SLOT(onProgressSuccess(qint64))); connect(m_downloader, SIGNAL(downloadSuccess(qint64)), SLOT(onProgressSuccess(qint64)));
connect(m_downloader, SIGNAL(downloadFail(QString)), SLOT(onProgressFail(QString))); connect(m_downloader, SIGNAL(downloadFail(QString)), SLOT(onProgressFail(QString)));
@ -99,7 +102,10 @@ void COperationDialog::processNextStep()
case CConfigFile::DisplayNoServerError: case CConfigFile::DisplayNoServerError:
break; break;
case CConfigFile::ShowWizard: case CConfigFile::ShowMigrateWizard:
break;
case CConfigFile::ShowInstallWizard:
break; break;
case CConfigFile::DownloadData: case CConfigFile::DownloadData:
@ -130,6 +136,10 @@ void COperationDialog::processNextStep()
QtConcurrent::run(this, &COperationDialog::extractBnpClient); QtConcurrent::run(this, &COperationDialog::extractBnpClient);
break; break;
case CConfigFile::CopyInstaller:
QtConcurrent::run(this, &COperationDialog::copyIntaller);
break;
case CConfigFile::CleanFiles: case CConfigFile::CleanFiles:
QtConcurrent::run(this, &COperationDialog::cleanFiles); QtConcurrent::run(this, &COperationDialog::cleanFiles);
break; break;
@ -142,6 +152,10 @@ void COperationDialog::processNextStep()
createDefaultShortcuts(); createDefaultShortcuts();
break; break;
case CConfigFile::CreateAddRemoveEntry:
createAddRemoveEntry();
break;
case CConfigFile::Done: case CConfigFile::Done:
accept(); accept();
break; break;
@ -305,7 +319,7 @@ void COperationDialog::copyServerFiles()
CFilesCopier copier(this); CFilesCopier copier(this);
copier.setSourceDirectory(config->getSrcServerDirectory()); copier.setSourceDirectory(config->getSrcServerDirectory());
copier.setDesinationDirectory(config->getInstallationDirectory() + "/" + server.id); copier.setDestinationDirectory(config->getInstallationDirectory() + "/" + server.id);
copier.setIncludeFilter(serverFiles); copier.setIncludeFilter(serverFiles);
if (copier.exec()) if (copier.exec())
@ -341,7 +355,7 @@ void COperationDialog::copyProfileFiles()
CFilesCopier copier(this); CFilesCopier copier(this);
copier.setSourceDirectory(config->getSrcProfileDirectory()); copier.setSourceDirectory(config->getSrcProfileDirectory());
copier.setDesinationDirectory(config->getProfileDirectory() + "/" + profile.id); copier.setDestinationDirectory(config->getProfileDirectory() + "/" + profile.id);
copier.setIncludeFilter(profileFiles); copier.setIncludeFilter(profileFiles);
if (copier.exec()) if (copier.exec())
@ -401,6 +415,53 @@ void COperationDialog::extractBnpClient()
emit done(); emit done();
} }
void COperationDialog::copyIntaller()
{
CConfigFile *config = CConfigFile::getInstance();
// default server
const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Copy installer to new location");
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
QString destinationDirectory = config->getInstallationDirectory();
// rename old client to installer
QString newInstallerFilename = server.installerFilename;
if (!newInstallerFilename.isEmpty())
{
QString oldInstallerFullPath = QApplication::applicationFilePath();
QString newInstallerFullPath = config->getInstallationDirectory() + "/" + newInstallerFilename;
if (!QFile::exists(newInstallerFullPath))
{
QStringList filter;
filter << "msvcp100.dll";
filter << "msvcr100.dll";
CFilesCopier copier(this);
copier.setIncludeFilter(filter);
copier.addFile(oldInstallerFullPath);
copier.setSourceDirectory(config->getSrcServerDirectory());
copier.setDestinationDirectory(config->getInstallationDirectory());
copier.exec();
// copied file
oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName();
// rename old filename if different
if (oldInstallerFullPath != newInstallerFullPath)
{
QFile::rename(oldInstallerFullPath, newInstallerFullPath);
}
}
}
emit done();
}
void COperationDialog::cleanFiles() void COperationDialog::cleanFiles()
{ {
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
@ -425,7 +486,7 @@ bool COperationDialog::createDefaultProfile()
CServer server = config->getServer(config->getDefaultServerIndex()); CServer server = config->getServer(config->getDefaultServerIndex());
m_currentOperation = QApplication::tr("Create default profile"); m_currentOperation = QApplication::tr("Create default profile");
m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); // m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
CProfile profile; CProfile profile;
@ -458,6 +519,56 @@ bool COperationDialog::createDefaultShortcuts()
return true; return true;
} }
bool COperationDialog::createAddRemoveEntry()
{
CConfigFile *config = CConfigFile::getInstance();
const CServer &server = config->getServer();
QString oldInstallerFilename = server.clientFilenameOld;
QString newInstallerFilename = server.installerFilename;
if (!oldInstallerFilename.isEmpty() && !newInstallerFilename.isEmpty())
{
QString oldInstallerFullPath = config->getSrcServerDirectory() + "/" + oldInstallerFilename;
QString newInstallerFullPath = config->getInstallationDirectory() + "/" + newInstallerFilename;
if (QFile::exists(newInstallerFullPath))
{
#ifdef Q_OS_WIN
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat);
QStringList versionTokens = QString(RYZOM_VERSION).split('.');
settings.setValue("Comments", "");
settings.setValue("DisplayIcon", QDir::toNativeSeparators(newInstallerFullPath) + ",0");
settings.setValue("DisplayName", "Ryzom");
settings.setValue("DisplayVersion", RYZOM_VERSION);
settings.setValue("EstimatedSize", 1500000); // TODO: compute real size
settings.setValue("InstallDate", QDateTime::currentDateTime().toString("Ymd"));
settings.setValue("InstallLocation", config->getInstallationDirectory());
settings.setValue("MajorVersion", versionTokens[0].toInt());
settings.setValue("MinorVersion", versionTokens[1].toInt());
settings.setValue("NoModify", 0);
settings.setValue("NoRemove", 0);
settings.setValue("NoRepair", 0);
settings.setValue("Publisher", AUTHOR);
settings.setValue("QuietUninstallString", QDir::toNativeSeparators(newInstallerFullPath) + " -u -s");
settings.setValue("UninstallString", QDir::toNativeSeparators(newInstallerFullPath) + " -u");
settings.setValue("URLUpdateInfo", "http://ryzom.fr/info");
settings.setValue("URLInfoAbout", "http://ryzom.fr/info2");
// settings.setValue("sEstimatedSize2", 0);
settings.setValue("HelpLink", "http://ryzom.fr/support");
// ModifyPath
#endif
}
}
emit done();
return true;
}
void COperationDialog::operationPrepare() void COperationDialog::operationPrepare()
{ {
emit prepare(); emit prepare();

@ -87,9 +87,11 @@ protected:
void copyServerFiles(); void copyServerFiles();
void copyProfileFiles(); void copyProfileFiles();
void extractBnpClient(); void extractBnpClient();
void copyIntaller();
void cleanFiles(); void cleanFiles();
bool createDefaultProfile(); bool createDefaultProfile();
bool createDefaultShortcuts(); bool createDefaultShortcuts();
bool createAddRemoveEntry();
// from CFilesCopier // from CFilesCopier
virtual void operationPrepare(); virtual void operationPrepare();

@ -17,6 +17,23 @@
#include "stdpch.h" #include "stdpch.h"
#include "utils.h" #include "utils.h"
QString qBytesToHumanReadable(qint64 bytes)
{
static std::vector<std::string> units;
if (units.empty())
{
units.push_back(QObject::tr("B").toUtf8().constData());
units.push_back(QObject::tr("KiB").toUtf8().constData());
units.push_back(QObject::tr("MiB").toUtf8().constData());
units.push_back(QObject::tr("GiB").toUtf8().constData());
units.push_back(QObject::tr("TiB").toUtf8().constData());
units.push_back(QObject::tr("PiB").toUtf8().constData());
}
return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str());
}
QString qFromUtf8(const std::string &str) QString qFromUtf8(const std::string &str)
{ {
return QString::fromUtf8(str.c_str()); return QString::fromUtf8(str.c_str());

@ -28,6 +28,8 @@
* \date 2016 * \date 2016
*/ */
QString qBytesToHumanReadable(qint64 bytes);
// Convert a UTF-8 string to QString // Convert a UTF-8 string to QString
QString qFromUtf8(const std::string &str); QString qFromUtf8(const std::string &str);

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>WizardDialog</class> <class>InstallWizardDialog</class>
<widget class="QDialog" name="WizardDialog"> <widget class="QDialog" name="InstallWizardDialog">
<property name="windowModality"> <property name="windowModality">
<enum>Qt::ApplicationModal</enum> <enum>Qt::ApplicationModal</enum>
</property> </property>
@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>402</width> <width>402</width>
<height>464</height> <height>435</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -28,10 +28,13 @@
<property name="text"> <property name="text">
<string>Welcome to Ryzom Installer! <string>Welcome to Ryzom Installer!
This program will allow you to download, install, migrate, configure or manage Ryzom on your computer. This program will allow you to download, install, configure or manage Ryzom on your computer.
Just follow the different steps and make your choice between the different propositions.</string> Just follow the different steps and make your choice between the different propositions.</string>
</property> </property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignJustify|Qt::AlignTop</set> <set>Qt::AlignJustify|Qt::AlignTop</set>
</property> </property>
@ -94,16 +97,6 @@ Just follow the different steps and make your choice between the different propo
<string>Files will be installed from:</string> <string>Files will be installed from:</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="currentDirectoryRadioButton">
<property name="text">
<string>Current directory</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="oldDirectoryRadioButton"> <widget class="QRadioButton" name="oldDirectoryRadioButton">
<property name="text"> <property name="text">
@ -213,7 +206,6 @@ Just follow the different steps and make your choice between the different propo
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>currentDirectoryRadioButton</tabstop>
<tabstop>oldDirectoryRadioButton</tabstop> <tabstop>oldDirectoryRadioButton</tabstop>
<tabstop>anotherLocationRadioButton</tabstop> <tabstop>anotherLocationRadioButton</tabstop>
<tabstop>anotherLocationBrowseButton</tabstop> <tabstop>anotherLocationBrowseButton</tabstop>
@ -227,7 +219,7 @@ Just follow the different steps and make your choice between the different propo
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>WizardDialog</receiver> <receiver>InstallWizardDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
@ -243,7 +235,7 @@ Just follow the different steps and make your choice between the different propo
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>WizardDialog</receiver> <receiver>InstallWizardDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">

@ -2,13 +2,23 @@
<ui version="4.0"> <ui version="4.0">
<class>MainWindow</class> <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow"> <widget class="QMainWindow" name="MainWindow">
<property name="geometry"> <property name="sizePolicy">
<rect> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<x>0</x> <horstretch>0</horstretch>
<y>0</y> <verstretch>0</verstretch>
<width>579</width> </sizepolicy>
<height>406</height> </property>
</rect> <property name="minimumSize">
<size>
<width>547</width>
<height>386</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>547</width>
<height>386</height>
</size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Ryzom Installer</string> <string>Ryzom Installer</string>
@ -97,7 +107,7 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>579</width> <width>547</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
@ -120,11 +130,6 @@ p, li { white-space: pre-wrap; }
<addaction name="menu_File"/> <addaction name="menu_File"/>
<addaction name="menu_Help"/> <addaction name="menu_Help"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar">
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
</widget>
<action name="actionAboutQt"> <action name="actionAboutQt">
<property name="text"> <property name="text">
<string>About Qt</string> <string>About Qt</string>

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MigrateWizardDialog</class>
<widget class="QDialog" name="MigrateWizardDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>331</height>
</rect>
</property>
<property name="windowTitle">
<string>Ryzom Installer</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,0">
<item>
<widget class="QLabel" name="messageLabel">
<property name="text">
<string>Welcome to Ryzom Installer!
This program will migrate Ryzom version 2.1 to 3.0. Your files will be updated, cleaned and moved to a new location.
Just press Continue button and follow the different steps until everything is done.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="advancedLayout">
<item>
<spacer name="advancedHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="advancedCheckBox">
<property name="text">
<string>Show advanced parameters (expert)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="advancedFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="advancedMainLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="destinationGroupBox">
<property name="title">
<string>Files will be installed to (requires 10 GiB):</string>
</property>
<layout class="QHBoxLayout" name="destinationLayout" stretch="1,0">
<item>
<widget class="QLabel" name="destinationLabel">
<property name="text">
<string>c:\</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="destinationBrowseButton">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="clientArchGroupBox">
<property name="title">
<string>Do you prefer to use a 64 or 32 bits client?</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="clientArch64RadioButton">
<property name="text">
<string>64 bits (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="clientArch32RadioButton">
<property name="text">
<string>32 bits</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="buttonsLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="continueButton">
<property name="text">
<string>Continue</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="quitButton">
<property name="text">
<string>Quit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>destinationBrowseButton</tabstop>
<tabstop>clientArch64RadioButton</tabstop>
<tabstop>clientArch32RadioButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

@ -13,6 +13,24 @@
<height>106</height> <height>106</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>106</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>106</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Ryzom Installer</string> <string>Ryzom Installer</string>
</property> </property>

Loading…
Cancel
Save