Changed: Use empty() to check if a string is empty

This commit is contained in:
kervala 2016-10-25 15:52:14 +02:00
parent f11527442c
commit 56b8a61b16
12 changed files with 25 additions and 25 deletions

View file

@ -320,7 +320,7 @@ public:
// For edition: change the tileVegetableDesc. NB: only the TileVegetableDescFileName is serialised.
void setTileVegetableDesc (const CTileVegetableDesc &tvd);
/** try to load the vegetable tile desc associated with the fileName (nlinfo() if can't)
* lookup into CPath. no-op if string=="".
* lookup into CPath. no-op if string empty
*/
void loadTileVegetableDesc();

View file

@ -1831,9 +1831,9 @@ void CLandscape::loadTile(uint16 tileId)
if(tile)
textName= tile->getRelativeFileName(CTile::additive);
else
textName= "";
textName.clear();
// If no additive for this tile, rdrpass is NULL.
if(textName=="")
if(textName.empty())
tileInfo->AdditiveRdrPass= NULL;
else
{
@ -1844,7 +1844,7 @@ void CLandscape::loadTile(uint16 tileId)
// We may have an alpha part for additive.
textName= tile->getRelativeFileName (CTile::alpha);
if(textName!="")
if(!textName.empty())
// Must Use clamp for alpha (although NVidia drivers are buggy), because the texture doesn't tile at all
pass.TextureAlpha= findTileTexture(TileBank.getAbsPath()+textName, true);
@ -1866,7 +1866,7 @@ void CLandscape::loadTile(uint16 tileId)
if(tile)
{
textName= tile->getRelativeFileName(CTile::diffuse);
if(textName!="")
if(!textName.empty())
// Avoid using Clamp for diffuse, because of recent NVidia GL drivers Bugs in 77.72
pass.TextureDiffuse= findTileTexture(TileBank.getAbsPath()+textName, false);
else
@ -1880,7 +1880,7 @@ void CLandscape::loadTile(uint16 tileId)
if(tile)
{
textName= tile->getRelativeFileName (CTile::alpha);
if(textName!="")
if(!textName.empty())
// Must Use clamp for alpha (although NVidia drivers are buggy), because the texture doesn't tile at all
pass.TextureAlpha= findTileTexture(TileBank.getAbsPath()+textName, true);
}

View file

@ -174,7 +174,7 @@ UInstanceGroup *CLandscapeIGManager::loadZoneIG(const std::string &name)
{
NL3D_HAUTO_LAND_MNGR_LOAD_ZONEIG
if(name=="")
if(name.empty())
return NULL;
// try to find this InstanceGroup.
@ -232,7 +232,7 @@ void CLandscapeIGManager::unloadArrayZoneIG(const std::vector<std::string> &name
void CLandscapeIGManager::unloadZoneIG(const std::string &name)
{
NL3D_HAUTO_LAND_MNGR_UNLOAD_ZONEIG
if(name=="")
if(name.empty())
return;
// try to find this InstanceGroup.
@ -255,7 +255,7 @@ void CLandscapeIGManager::unloadZoneIG(const std::string &name)
// ***************************************************************************
bool CLandscapeIGManager::isIGAddedToScene(const std::string &name) const
{
if(name=="")
if(name.empty())
return false;
// try to find this InstanceGroup.
@ -272,7 +272,7 @@ bool CLandscapeIGManager::isIGAddedToScene(const std::string &name) const
// ***************************************************************************
UInstanceGroup *CLandscapeIGManager::getIG(const std::string &name) const
{
if(name=="")
if(name.empty())
return NULL;
// try to find this InstanceGroup.

View file

@ -264,7 +264,7 @@ sint CTileBank::getNumBitmap (CTile::TBitmap bitmap) const
if (!_TileVector[i].isFree())
{
const std::string &str=_TileVector[i].getRelativeFileName (bitmap);
if (str!="")
if (!str.empty())
{
std::vector<char> vect (str.length()+1);
memcpy (&*vect.begin(), str.c_str(), str.length()+1);
@ -583,7 +583,7 @@ void CTileBank::removeDisplacementMap (uint mapId)
if (mapId==_DisplacementMap.size()-1)
{
// Resize the array ?
while ((mapId>0)&&(_DisplacementMap[mapId]._FileName==""))
while ((mapId>0)&&(_DisplacementMap[mapId]._FileName.empty()))
_DisplacementMap.resize (mapId--);
}
}
@ -608,7 +608,7 @@ uint CTileBank::getDisplacementMap (const string &fileName)
for (noiseTile=0; noiseTile<_DisplacementMap.size(); noiseTile++)
{
// Same name ?
if (_DisplacementMap[noiseTile]._FileName=="")
if (_DisplacementMap[noiseTile]._FileName.empty())
break;
}
if (noiseTile==_DisplacementMap.size())
@ -1433,7 +1433,7 @@ void CTileSet::deleteBordersIfLast (const CTileBank& bank, CTile::TBitmap type)
while (ite!=_Tile128.end())
{
// If the file name is valid
if (bank.getTile (*ite)->getRelativeFileName(type)!="")
if (!bank.getTile (*ite)->getRelativeFileName(type).empty())
{
// Don't delete,
bDelete=false;
@ -1450,7 +1450,7 @@ void CTileSet::deleteBordersIfLast (const CTileBank& bank, CTile::TBitmap type)
while (ite!=_Tile256.end())
{
// If the file name is valid
if (bank.getTile (*ite)->getRelativeFileName(type)!="")
if (!bank.getTile (*ite)->getRelativeFileName(type).empty())
{
// Don't delete,
bDelete=false;
@ -1474,7 +1474,7 @@ void CTileSet::deleteBordersIfLast (const CTileBank& bank, CTile::TBitmap type)
if (nTile!=-1)
{
// If the file name is valid
if (bank.getTile (nTile)->getRelativeFileName(type)!="")
if (!bank.getTile (nTile)->getRelativeFileName(type).empty())
{
// Don't delete,
bDelete=false;
@ -1564,7 +1564,7 @@ const CTileVegetableDesc &CTileSet::getTileVegetableDesc() const
// ***************************************************************************
void CTileSet::loadTileVegetableDesc()
{
if(_TileVegetableDescFileName!="")
if(!_TileVegetableDescFileName.empty())
{
try
{

View file

@ -1797,7 +1797,7 @@ void CAudioMixerUser::addSource( CSourceCommon *source )
_Sources.insert( source );
// _profile(( "AM: ADDSOURCE, SOUND: %d, TRACK: %p, NAME=%s", source->getSound(), source->getTrack(),
// source->getSound() && (source->getSound()->getName()!="") ? source->getSound()->getName().c_str() : "" ));
// source->getSound() && (!source->getSound()->getName().empty()) ? source->getSound()->getName().c_str() : "" ));
}

View file

@ -2798,7 +2798,7 @@ class CAHScenarioControl : public IActionHandler
// description
string description = sessionBrowser._LastDescription;
if(description!="")
if(!description.empty())
{
result = scenarioWnd->findFromShortId(string("edit_small_description"));
if(result)

View file

@ -171,7 +171,7 @@ public:
// hide every static fxs
void hideStaticFXs();
// Create the loading instance. return false if shapeName!="" while still fails to load. else return true.
// Create the loading instance. return false if shapeName is not empty while still fails to load. else return true.
bool createLoading(const std::string &shapeName, const std::string &stickPoint=std::string(""), sint texture=-1, bool clearIfFail= true);
// Apply Colors

View file

@ -2588,7 +2588,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler
for(uint i=0; i<errors.size(); i++)
{
string comment = parseCommentError(res, errors[i]);
if(comment!="")
if(!comment.empty())
error += "- " + comment + "\n";
}

View file

@ -993,7 +993,7 @@ void CDisplayerVisualEntity::updateName()
else
actName = act->toString("Title"); //obsolete
if(actName!=firstPart && actName!="")
if(actName!=firstPart && !actName.empty())
actName = firstPart+":"+actName;
}
else

View file

@ -385,7 +385,7 @@ void CScenarioEntryPoints::loadFromXMLFile()
shortEntryPoint.Y = entryPoint.Y;
entryPoints.push_back(shortEntryPoint);
if(package=="")
if(package.empty())
package=entryPoint.Package;
else if(package!=entryPoint.Package)
nlinfo("Different packages for island '%s' in file %s", island, _EntryPointsFilename.c_str());

View file

@ -225,7 +225,7 @@ void CStringTableManager::setValue(uint32 tableId,const std::string& localId, co
if(found2!=localTable->end())
{
std::string oldValue = _StringMgr.getString(found2->second);
if (oldValue=="") nlwarning("error! no string %u in string manager! ",found2->second);
if (oldValue.empty()) nlwarning("error! no string %u in string manager! ",found2->second);
_StringMgr.unregisterString(oldValue);
found2->second = _StringMgr.registerString(value);
}

View file

@ -469,7 +469,7 @@ static std::string formatString(std::string str,std::vector<float> args)
void CStringManagerModule::translateAndForwardWithArg(TDataSetRow senderId,CChatGroup::TGroupType groupType,std::string id,TSessionId sessionId,std::vector<float>& args)
{
std::string text = getValue(sessionId.asInt(), id );
if (text!="")
if (!text.empty())
{
std::string toSend = formatString(text,args);
send(senderId,groupType,toSend);