Changed: Use empty() instead of comparison with ""

This commit is contained in:
kervala 2016-10-30 15:59:20 +01:00
parent e752b52ec4
commit d84b5f9bf4
28 changed files with 63 additions and 61 deletions

View file

@ -457,7 +457,7 @@ CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::stri
nlerror ("FT_New_Face() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error));
}
if (fontExFileName != "")
if (!fontExFileName.empty())
{
error = FT_Attach_File (_Face, fontExFileName.c_str ());
if (error)

View file

@ -213,9 +213,9 @@ void CLandscapeUser::refreshAllZonesAround(const CVector &pos, float radius, std
refreshZonesAround (pos, radius, za, zr);
// some zone added or removed??
if(za != "")
if(!za.empty())
zonesAdded.push_back(za);
if(zr != "")
if(!zr.empty())
zonesRemoved.push_back(zr);
_ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius);

View file

@ -1121,7 +1121,7 @@ void CInstanceGroup::setClusterSystemForInstances(CInstanceGroup *pIG)
void CInstanceGroup::getDynamicPortals (std::vector<std::string> &names)
{
for (uint32 i = 0; i < _Portals.size(); ++i)
if (_Portals[i].getName() != "")
if (!_Portals[i].getName().empty())
names.push_back (_Portals[i].getName());
}

View file

@ -572,7 +572,7 @@ namespace NLGUI
curl_easy_cleanup(it->curl);
string tmpfile = it->dest + ".tmp";
if(res != CURLE_OK || r < 200 || r >= 300 || ((it->md5sum != "") && (it->md5sum != getMD5(tmpfile).toString())))
if(res != CURLE_OK || r < 200 || r >= 300 || (!it->md5sum.empty() && (it->md5sum != getMD5(tmpfile).toString())))
{
NLMISC::CFile::deleteFile(tmpfile.c_str());
}

View file

@ -442,7 +442,7 @@ namespace NLGUI
if (sZeStart[sZeStart.size()-1] == ':')
sZeStart = sZeStart.substr(0, sZeStart.size()-1);
while (sZeStart != "")
while (!sZeStart.empty())
{
if (sEltId[0] == ':')
sTmp = sZeStart + sEltId;

View file

@ -2504,13 +2504,13 @@ class CHandlerInvCanDropTo : public IActionHandler
if (pCSDst != NULL)
{
// If we want to drop something on a reference slot (hand or equip)
if (pInv->getDBIndexPath(pCSDst) != "")
if (!pInv->getDBIndexPath(pCSDst).empty())
{
// We must drag'n'drop an item
if (pCSSrc && pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item)
if (pCSDst && pCSDst->getType() == CCtrlSheetInfo::SheetType_Item)
{
if (pInv->getDBIndexPath(pCSSrc) != "")
if (!pInv->getDBIndexPath(pCSSrc).empty())
{
// The item dragged comes from a slot check if this is the good type
if (pCSDst->canDropItem(pCSSrc))

View file

@ -52,7 +52,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet *
// Extract parameters from sheet
vector<CSString> params;
CSString param = eff.splitTo(':', true);
while (param != "")
while (!param.empty())
{
params.push_back(param);
param = eff.splitTo(':', true);

View file

@ -352,7 +352,7 @@ void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str)
p = s.splitTo('.', true);
while (p.size() > 0)
{
if (path == "")
if (path.empty())
path = p;
else
path += "." + p;

View file

@ -128,7 +128,7 @@ void CViewBitmapFaberMp::draw ()
{
CItemSheet *pIS = (CItemSheet*)pES;
if (pIS->getIconBack() != "")
if (!pIS->getIconBack().empty())
{
if (_AccIconBackString != pIS->getIconBack())
{
@ -140,7 +140,7 @@ void CViewBitmapFaberMp::draw ()
_AccIconBackId);
}
if (pIS->getIconMain() != "")
if (!pIS->getIconMain().empty())
{
if (_AccIconMainString != pIS->getIconMain())
{
@ -152,7 +152,7 @@ void CViewBitmapFaberMp::draw ()
_AccIconMainId);
}
if (pIS->getIconOver() != "")
if (!pIS->getIconOver().empty())
{
if (_AccIconOverString != pIS->getIconOver())
{

View file

@ -507,7 +507,7 @@ void impulseShardId(NLMISC::CBitMemStream &impulse)
string webHost;
impulse.serial(webHost);
if (webHost != "")
if (!webHost.empty())
{
WebServer = webHost;
}

View file

@ -125,7 +125,7 @@ const CObject *CPropertyAccessor::getPropertyValue(const CObject* componentParam
std::string str = propClass->toString();
while (!toRet && str != "")
while (!toRet && !str.empty())
{
CObjectGenerator* generator = _Factory->getGenerator(str);

View file

@ -503,7 +503,7 @@ void CRosace::init()
void CRosace::add(const string &name, const CRosaceContext &context)
{
// If the name is not empty.
if(name != "")
if(!name.empty())
_Contexts.insert(TContexts::value_type (name, context));
}// add //

View file

@ -647,7 +647,7 @@ bool CObjectString::set(const std::string& key, const std::string & value)
{
//H_AUTO(R2_CObjectString_set)
BOMB_IF( key != "", "Try to set the a sub value of an object that does not allowed it", return false);
BOMB_IF(!key.empty(), "Try to set the a sub value of an object that does not allowed it", return false);
_Value = value;
return true;
}
@ -808,7 +808,7 @@ bool CObjectNumber::set(const std::string& key, double value)
{
//H_AUTO(R2_CObjectNumber_set)
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
_Value = value;
return true;
@ -819,7 +819,7 @@ bool CObjectNumber::set(const std::string& key, const std::string & value)
{
//H_AUTO(R2_CObjectNumber_set)
//XXX
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
NLMISC::fromString(value, _Value);
return true;
}
@ -907,7 +907,7 @@ bool CObjectInteger::set(const std::string& key, sint64 value)
{
//H_AUTO(R2_CObjectInteger_set)
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
_Value = value;
return true;
@ -918,7 +918,7 @@ bool CObjectInteger::set(const std::string& key, const std::string & value)
{
//H_AUTO(R2_CObjectInteger_set)
//XXX
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
NLMISC::fromString(value, _Value);
return true;
}

View file

@ -2813,7 +2813,7 @@ void CServerEditionModule::createSession(NLNET::IModuleProxy *sender, TCharId ow
else if (first->first == "Rules" ) { info.setDMLess( first->second != "Mastered"); }
else if (first->first == "NevraxScenario" && first->second == "1") { nevraxScenario = true; }
else if (first->first == "TrialAllowed" && first->second == "1") { trialAllowed = true; }
else if (first->first == "MissionTag" && first->second != "") { missionTag = first->second; }
else if (first->first == "MissionTag" && !first->second.empty()) { missionTag = first->second; }
}
// info.setMissionTag(missionTag);
info.setSessionAnimatorCharId( ownerCharId);
@ -3863,7 +3863,7 @@ void CServerEditionModule::startScenario(NLNET::IModuleProxy *senderModuleProxy,
else if (first->first == "Rules" ) { info.setDMLess( first->second != "Mastered"); }
else if (first->first == "NevraxScenario" && first->second == "1") { nevraxScenario = true; }
else if (first->first == "TrialAllowed" && first->second == "1") { trialAllowed = true; }
else if (first->first == "MissionTag" && first->second != "") { missionTag = first->second; }
else if (first->first == "MissionTag" && !first->second.empty()) { missionTag = first->second; }
}
info.setSessionAnimatorCharId( charId);

View file

@ -479,14 +479,14 @@ void CStringManagerModule::translateAndForwardWithArg(TDataSetRow senderId,CChat
void CStringManagerModule::translateAndForward(TDataSetRow senderId,CChatGroup::TGroupType groupType,std::string id,TSessionId sessionId)
{
std::string toSend = getValue(sessionId.asInt(), id);
if(toSend != "")
if(!toSend.empty())
send(senderId,groupType,toSend);
}
void CStringManagerModule::send(TDataSetRow& senderId,CChatGroup::TGroupType groupType,const std::string& toSend)
{
if(toSend != "")
if(!toSend.empty())
{
ucstring uStr;
uStr.fromUtf8(toSend);

View file

@ -2071,7 +2071,7 @@ public:
_WorldMap.clear();
string ext = CFile::getExtension(name);
if (ext == "")
if (ext.empty())
ext = "cwmap2";
CIFile f(OutputPath+CFile::getFilenameWithoutExtension(name)+"."+ext);
f.serial(_WorldMap);
@ -2213,7 +2213,7 @@ public:
_WorldMap.clear();
string ext = CFile::getExtension(name);
if (ext == "")
if (ext.empty())
ext = "cw_map2";
CIFile f(CFile::getPath(name) + CFile::getFilenameWithoutExtension(name)+"."+ext);

View file

@ -1178,7 +1178,7 @@ void CScreenshotIslands::loadIslands()
}
// write the processed proximity map to an output file
if(fileName != "")
if(!fileName.empty())
{
writeProximityBufferToTgaFile(fileName, cleanBuffer, zones[i].getZoneWidth(), zones[i].getZoneHeight());
_TempFileNames.push_back(fileName);

View file

@ -167,7 +167,7 @@ public:
//---------------------------------------------------------------------------------------------
// housekeeping
if (outputName!="")
if (!outputName.empty())
flush(outputName);
}
@ -258,7 +258,7 @@ private:
if (i>=cols.size()
|| i>=lastTblCols.size()
|| cols[i]!=lastTblCols[i]
|| (cols[i]!="" && !headerIsOpen[tblColumnNames[i]]))
|| (!cols[i].empty() && !headerIsOpen[tblColumnNames[i]]))
{
CSString s=headers[tblColumnNames[i]];
for (uint32 j=1;j<cols.size()&&j<tblColumnNames.size();++j)
@ -302,7 +302,7 @@ private:
}
else if (keyword=="output")
{
if (outputName!="")
if (!outputName.empty())
{
flush(outputName);
}
@ -399,7 +399,7 @@ private:
{
// do nothing
}
else if (keyword=="")
else if (keyword.empty())
{
mode=DEFAULT;
closeFooters();

View file

@ -642,42 +642,42 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB)
// Ok set parameters from options first and with CFG if no options set
if (_Options->OutIGDir == "")
if (_Options->OutIGDir.empty())
_OutIGDir = CTools::normalizePath (ContinentCFG.OutIGDir);
else
_OutIGDir = CTools::normalizePath (_Options->OutIGDir);
if (_Options->LandFile == "")
if (_Options->LandFile.empty())
_LandFile = ContinentCFG.LandFile;
else
_LandFile = _Options->LandFile;
if (_Options->DfnDir == "")
if (_Options->DfnDir.empty())
_DfnDir = ContinentCFG.DfnDir;
else
_DfnDir = _Options->DfnDir;
if (_Options->GameElemDir == "")
if (_Options->GameElemDir.empty())
_GameElemDir = ContinentCFG.GameElemDir;
else
_GameElemDir = _Options->GameElemDir;
if (_Options->InLandscapeDir == "")
if (_Options->InLandscapeDir.empty())
_InLandscapeDir = ContinentCFG.LandZoneWDir; // Directory where to get .zonew files
else
_InLandscapeDir = _Options->InLandscapeDir;
if (_Options->LandFarBankFile == "")
if (_Options->LandFarBankFile.empty())
_LandBankFile = ContinentCFG.LandBankFile; // The .smallbank file associated with the landscape
else
_LandBankFile = _Options->LandBankFile;
if (_Options->LandFarBankFile == "")
if (_Options->LandFarBankFile.empty())
_LandFarBankFile = ContinentCFG.LandFarBankFile; // The .farbank file
else
_LandFarBankFile = _Options->LandFarBankFile;
if (_Options->LandTileNoiseDir == "")
if (_Options->LandTileNoiseDir.empty())
_LandTileNoiseDir = ContinentCFG.LandTileNoiseDir; // Directory where to get displacement map
else
_LandTileNoiseDir = _Options->LandTileNoiseDir;

View file

@ -27,7 +27,7 @@ using namespace NLMISC;
// ---------------------------------------------------------------------------
void CTools::mkdir (const string &dirName)
{
if (dirName == "")
if (dirName.empty())
return;
// Does the directory exist ?
string newDir = pwd();

View file

@ -80,7 +80,7 @@ public:
return getNpcFullName();
else if (subPart == "function")
return _NpcFunction;
else if (subPart == "")
else if (subPart.empty())
return _NpcLabel;
throw EParseException(NULL, toString("var_npc don't have a subpart '%s'", subPart.c_str()).c_str());
@ -137,7 +137,7 @@ public:
string evalVar(const string &subPart)
{
if (subPart == "")
if (subPart.empty())
return string("\"")+_NpcLabel+"\"";
throw EParseException(NULL, toString("var_npc_name don't have a subpart '%s'", subPart.c_str()).c_str());

View file

@ -1069,7 +1069,7 @@ void GenerateSpecialItem( int numMP, const CSString& nomMP, const MPCraftStats&
void parseSpecialAttributes(const CSString &specialAttributes, MPCraftStats &craftStats, CExtraInfo &extraInfo)
{
// evaluate DropOrSell according to CraftStats: can DropOrSell if it is a MP Craft
extraInfo.DropOrSell= craftStats.Craft != "";
extraInfo.DropOrSell= !craftStats.Craft.empty();
// parse attributes
vector<string> strArray;

View file

@ -254,7 +254,8 @@ int importCsv(const char *filename)
do
{
fields.push_back(s.splitTo(';', true));
} while (s != "");
}
while (!s.empty());
}
// read values for each item
@ -278,7 +279,8 @@ int importCsv(const char *filename)
{
val = s.splitTo(';', true);
items[n].push_back(val);
} while (s != "");
}
while (!s.empty());
}
fclose(f);
@ -376,7 +378,7 @@ void updateItemField(CVectorSString &lines, uint itemIndex, uint fieldIndex, uin
if (pos == string::npos)
continue;
if (val != "")
if (!val.empty())
{
// check if the attribute is the right one and not included in another one
// for example: Protection is in ProtectionFactor
@ -507,7 +509,7 @@ int main(int argc, char *argv[])
}
// create a .csv file
if (scriptFile != "")
if (!scriptFile.empty())
{
if (CFile::getFilename(scriptFile) == scriptFile)
scriptFile = curDir + scriptFile;
@ -545,7 +547,7 @@ int main(int argc, char *argv[])
}
// create a .txt file
if (csvFile != "")
if (!csvFile.empty())
{
if (CFile::getFilename(csvFile) == csvFile)
csvFile = curDir + csvFile;

View file

@ -205,7 +205,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
if (_ExportCB != NULL)
_ExportCB->dispPass ("Loading height map");
_HeightMap = NULL;
if (_Options->HeightMapFile != "")
if (!_Options->HeightMapFile.empty())
{
_HeightMap = new CBitmap;
try
@ -236,7 +236,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
if (_ExportCB != NULL)
_ExportCB->dispPass ("Loading height map");
_HeightMap2 = NULL;
if (_Options->HeightMapFile2 != "")
if (!_Options->HeightMapFile2.empty())
{
_HeightMap2 = new CBitmap;
try
@ -267,7 +267,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
if (_ExportCB != NULL)
_ExportCB->dispPass ("Loading color map");
_ColorMap = NULL;
if (_Options->ColorMapFile != "")
if (!_Options->ColorMapFile.empty())
{
_ColorMap = new CBitmap;
try
@ -314,12 +314,12 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
try
{
// Add zone files
if (_Options->OutZoneDir != "")
if (!_Options->OutZoneDir.empty())
NLMISC::CPath::getPathContent(_Options->OutZoneDir, true, false, true, allFiles);
// Add ig files
vector<string> allOtherFiles;
if (_Options->OutIGDir != "")
if (!_Options->OutIGDir.empty())
NLMISC::CPath::getPathContent(_Options->OutIGDir, true, false, true, allOtherFiles);
allFiles.insert(allFiles.end(), allOtherFiles.begin(), allOtherFiles.end());
}
@ -386,7 +386,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
_ZoneMaxX = nMaxX;
_ZoneMaxY = nMaxY;
if ((_Options->ZoneMin != "") && (_Options->ZoneMax != ""))
if (!_Options->ZoneMin.empty() && !_Options->ZoneMax.empty())
{
_Options->ZoneMin = strupr (_Options->ZoneMin);
_Options->ZoneMax = strupr (_Options->ZoneMax);

View file

@ -51,7 +51,7 @@ int main(int argc, char **argv)
}
}
if (inputfile == "")
if (inputfile.empty())
{
nlwarning("Error: missing input file(s)");
exit(EXIT_FAILURE);

View file

@ -735,7 +735,7 @@ public:
return UserCodes[i].UserCode;
// then look for a default code
for (i=0; i<UserCodes.size(); ++i)
if (UserCodes[i].Event == name && UserCodes[i].CodeSpecializer == "")
if (UserCodes[i].Event == name && UserCodes[i].CodeSpecializer.empty())
return UserCodes[i].UserCode;
return "";
}

View file

@ -669,7 +669,7 @@ NLMISC_COMMAND(pacsBuildProximityMap,"build a set of proximity maps from a cwmap
// load the collision map file and generate our buffer from it
CProximityMapBuffer buffer;
string ext = CFile::getExtension(name);
if (ext == "")
if (ext.empty())
ext = "cwmap2";
string fileName= OutputPath+CFile::getFilenameWithoutExtension(name)+"."+ext;
nlinfo("Building proximity map: Loading cwmap2 file: %s",fileName.c_str());

View file

@ -83,7 +83,7 @@ sint main(sint argc, char **argv)
{
if (string(argv[i]) == string("-"))
{
if (cmd != "")
if (!cmd.empty())
{
commands.push_back(cmd);
cmd.clear();
@ -91,13 +91,13 @@ sint main(sint argc, char **argv)
}
else
{
if (cmd != "")
if (!cmd.empty())
cmd += ' ';
cmd += argv[i];
}
}
if (cmd != "")
if (!cmd.empty())
commands.push_back(cmd);
NLMISC::createDebug ();