Changed: Replaced string empty comparisons with empty()

This commit is contained in:
kervala 2012-10-06 18:17:57 +02:00
parent 94fbb51b90
commit 283dd36338
14 changed files with 52 additions and 52 deletions

View file

@ -80,7 +80,7 @@ CMessageRecorder::CMessageRecorder() : _RecordAll(true)
*/
CMessageRecorder::~CMessageRecorder()
{
if ( _Filename != "" )
if ( !_Filename.empty() )
{
nldebug( "MR:%s: End of recording", _Filename.c_str() );
}

View file

@ -143,7 +143,7 @@ void CVarPath::decode ()
Destination.push_back (make_pair(RawVarPath, string("")));
return;
}
else if (val != "." && val != "" && val != "=")
else if (val != "." && !val.empty() && val != "=")
{
nlwarning ("VP: Malformated VarPath '%s' before position %d", RawVarPath.c_str (), TokenPos);
return;

View file

@ -413,7 +413,7 @@ void CSoundPage::apply()
nlassert( _Tree );
if ( m_Filename != "" )
if ( !m_Filename.empty() )
{
CString s = ((CSource_sounds_builderDlg*)GetOwner())->SoundName( _HItem ) + " (" + m_Filename + ")";
_Tree->SetItemText( _HItem, s );

View file

@ -364,7 +364,7 @@ CString CSource_sounds_builderDlg::SoundName( HTREEITEM hitem )
{
CString s = m_Tree.GetItemText( hitem );
sint last;
if ( s != "" )
if ( !s.empty() )
{
if ( s[s.GetLength()-1] == '*' )
{
@ -425,13 +425,13 @@ void CSource_sounds_builderDlg::OnSave()
}
nameset.insert( (*ips)->getName() );
}
if ( duplicates != "" )
if ( !duplicates.empty() )
{
CString s;
s.Format( "Warning: the following names are duplicates. The first occurence of each one was not written in the output file. Correct the names and save again:\n\n%s", duplicates.c_str() );
AfxMessageBox( s, MB_ICONWARNING );
}
if ( blanksounds != "" )
if ( !blanksounds.empty() )
{
CString s;
s.Format( "Warning: the following sounds have no wave file specified:\n\n%s", blanksounds.c_str() );
@ -569,7 +569,7 @@ void CSource_sounds_builderDlg::OnImport()
if ( hitem == NULL )
{
string sname = string(name);
if ( sname != "" ) // prevent from taking blank names
if ( !sname.empty() ) // prevent from taking blank names
{
AddSound( sname.c_str() );
}

View file

@ -105,7 +105,7 @@ CAnimatedSceneObject::CAnimatedSceneObject( const string& ObjectName, const stri
}
// load skeleton, bind mesh and init position, rotation, cluster
if(_SkeletonName != "" )
if(!_SkeletonName.empty())
{
_Skeleton = Scene->createSkeleton(_SkeletonName);
if( _Skeleton == NULL )
@ -340,12 +340,12 @@ void CAnimatedSceneObject::resetInitialPos( void )
// Destructor
CAnimatedSceneObject::~CAnimatedSceneObject()
{
if( _Instance != NULL && _MeshName != "" )
if( _Instance != NULL && !_MeshName.empty() )
{
Scene->deleteInstance( _Instance );
}
if( _Skeleton != NULL && _SkeletonName != "" )
if( _Skeleton != NULL && !_SkeletonName.empty() )
{
Scene->deleteSkeleton( _Skeleton );
}

View file

@ -602,7 +602,7 @@ bool CObjectString::set(const std::string& key, const std::string & value)
bool CObjectString::setObject(const std::string& key, CObject* value)
{
//H_AUTO(R2_CObjectString_setObject)
BOMB_IF( key != "" || ! (value->isString() || value->isNumber()) , "Try to set the a sub value of an object that does not allowed it", return false);
BOMB_IF( !key.empty() || ! (value->isString() || value->isNumber()) , "Try to set the a sub value of an object that does not allowed it", return false);
bool canSet = set(key, value->toString());
if (canSet)
{

View file

@ -128,7 +128,7 @@ static bool LookupShopType(std::string name,std::vector<uint32> &shopList)
uint i;
for ( i=0; i < cvShopType.size(); ++i )
{
if ( cvShopType.asString(i) != "" )
if ( !cvShopType.asString(i).empty() )
{
// make sure the string doesn't turn up more than once in input data
for (uint j=0;j<ShopTypeNames.size();++j)

View file

@ -2967,7 +2967,7 @@ void audit(const CAdminCommand *cmd, const string &rawCommand, const CEntityId &
string host = varHost->asString();
string page = varPage->asString();
if (host == "" || page == "")
if (host.empty() || page.empty())
return;
char params[1024];

View file

@ -117,7 +117,7 @@ void CGenNpcDescMsgImp::callback (const std::string &serviceName, NLNET::TServic
//if the creature has a user model and if the user model's script contains parse errors, change
//the creature's name to <usermodelId:ERROR>
if (_UserModelId != "" && CDynamicSheetManager::getInstance()->scriptErrors(_PrimAlias, _UserModelId) == true)
if (!_UserModelId.empty() && CDynamicSheetManager::getInstance()->scriptErrors(_PrimAlias, _UserModelId) == true)
{
TDataSetRow row = creature->getEntityRowId();
ucstring name;

View file

@ -242,7 +242,7 @@ void CShopTypeManager::initShopBase()
CConfigFile::CVar& cvShopType = ShopConfigFile.getVar("ShopCategory");
for (uint i = 0; i < cvShopType.size(); ++i )
{
if ( cvShopType.asString(i) != "" )
if ( !cvShopType.asString(i).empty() )
{
_CategoryName.push_back( cvShopType.asString( i ) );
}
@ -252,7 +252,7 @@ void CShopTypeManager::initShopBase()
CConfigFile::CVar& cvShopAlias = ShopConfigFile.getVar("ShopNameAliases");
for ( uint i = 0; i < cvShopAlias.size(); ++i )
{
if ( cvShopAlias.asString(i) != "" )
if ( !cvShopAlias.asString(i).empty() )
{
CVectorSString args;
explode(cvShopAlias.asString(i), string(":"), reinterpret_cast<vector<string> &>(args));

View file

@ -132,7 +132,7 @@ void CChatManager::onServiceDown(const std::string &serviceShortName)
*/
void CChatManager::resetChatLog()
{
std::string logPath = (LogChatDirectory.get() == "" ? Bsi.getLocalPath() : LogChatDirectory.get());
std::string logPath = (LogChatDirectory.get().empty() ? Bsi.getLocalPath() : LogChatDirectory.get());
_Displayer.setParam(CPath::standardizePath(logPath) + "chat.log");
}

View file

@ -113,13 +113,13 @@ void LoadCraftParts()
data.readFromFile( "rm_item_parts.csv" );
while ( data != "" )
while ( !data.empty() )
{
ligne = data.splitTo( "\n", true );
// on recherche la ligne correspondant à notre craft part
info = ligne.splitTo( ";", true );
if ( info != "" )
if ( !info.empty() )
{
index = info.c_str()[0] - 'A';
@ -179,13 +179,13 @@ void InitCreatureMP()
data.readFromFile( "creature_models.csv" );
while ( data != "" )
while ( !data.empty() )
{
ligneN = data.splitTo( "\n", true );
ligneM = data.splitTo( "\n", true );
// on vérifie que la ligne est valide
if ( ligneN.splitTo( ";", true ) != "" )
if ( !ligneN.splitTo( ";", true ).empty() )
{
ligneM.splitTo( ";", true );
@ -195,7 +195,7 @@ void InitCreatureMP()
ligneN.splitTo( ";", true );
ligneM.splitTo( ";", true );
while ( ligneN != "" )
while ( !ligneN.empty() )
{
ListeCreatureMP listeCreatureMP;
@ -426,7 +426,7 @@ int GetNumeroMP( const CSString& nomMP )
result = FamilyTypContent.splitFrom( buffer );
// si oui, on retourne son numéro de MP
if ( result != "" )
if ( !result.empty() )
res = result.splitTo( "\"" ).atoi();
else
{
@ -478,7 +478,7 @@ int GetNumeroGroupe( const CSString& groupe )
result = GroupTypContent.splitFrom( buffer );
// si oui, on retourne son numéro de groupe
if ( result != "" )
if ( !result.empty() )
res = result.splitTo( "\"" ).atoi();
else
{
@ -557,14 +557,14 @@ void CreateParentSItem( int numMP,
// 3d
output += " <STRUCT Name=\"3d\">\n";
if ( icon != "" )
if ( !icon.empty() )
{
output += " <ATOM Name=\"icon\" Value=\"";
output += icon;
output += "\"/>\n";
}
if ( overlay != "" )
if ( !overlay.empty() )
{
output += " <ATOM Name=\"text overlay\" Value=\"";
output += overlay;
@ -787,13 +787,13 @@ void CreateSheet( int numMP, const CSString& nomMP,
break;
}
if ( ( eco == 'c' ) && creature && ( craftStats.Craft == "" ) )
if ( ( eco == 'c' ) && creature && ( craftStats.Craft.empty() ) )
return;
outputFileName = toString( "m%04d%s%c%c%02d.sitem", numMP, code.c_str(), eco,
'a' + level, variation );
if ( craftStats.Craft == "" )
if ( craftStats.Craft.empty() )
{
CSString levelZone = toString( "%c", 'a' + level );
currentDocItem.push( DtLevelZone, levelZone.toUpper() );
@ -825,7 +825,7 @@ void CreateSheet( int numMP, const CSString& nomMP,
output += " <ATOM Name=\"MpColor\" Value=\"";
// materiaux de missions toujours Beige
if ( craftStats.Craft == "" )
if ( craftStats.Craft.empty() )
{
output += "Beige\"/>\n";
if(craftStats.UsedAsCraftRequirement)
@ -894,7 +894,7 @@ void CreateSheet( int numMP, const CSString& nomMP,
CSString statEnergy;
if ( ( variation == 2 ) && ( numMP == 695 ) ) // cas particulier pour le kitin trophy (beurk)
statEnergy = "0";
else if ( !creature || ( craftStats.Craft == "" ) )
else if ( !creature || ( craftStats.Craft.empty() ) )
statEnergy = toString( "%d", GetStatEnergy( level ) );
else if ( variation < 2 )
statEnergy = toString( "%d", GetStatEnergy( level + 1 ) );
@ -912,7 +912,7 @@ void CreateSheet( int numMP, const CSString& nomMP,
outputFileName = toString( "m%04d%s%c%c%02d", numMP, code.c_str(), eco, 'a' + level, variation );
output = outputFileName;
GenerateItemNames( nomMP, eco, level, ( craftStats.Craft == "" ), creature, itemName );
GenerateItemNames( nomMP, eco, level, ( craftStats.Craft.empty() ), creature, itemName );
output += "\t" + itemName;
itemNames.insert( output );
}
@ -947,7 +947,7 @@ void GenerateDepositItems( int numMP, const CSString& nomMP, const MPCraftStats&
code = "cxx";
// pas de craft = items de mission
if ( craftStats.Craft == "" )
if ( craftStats.Craft.empty() )
{
if ( loc != "G" )
CreateSheet( numMP, nomMP, code, 'c', 0, craftStats );
@ -1000,7 +1000,7 @@ void GenerateCreatureItems( int numMP, CSString& nomMP, const MPCraftStats& craf
CSString creatureFileName = "c";
creatureFileName += (*itMP)->codeCreature.toLower();
if ( craftStats.Craft != "" )
if ( !craftStats.Craft.empty() )
{
quality = statQuality[creatureLevel-1];
if ( quality != 6 )
@ -1107,7 +1107,7 @@ void NewMP( CSString& ligne )
// nouveau nom de famille
nomMP = ligne.splitTo( ";", true );
if ( nomMP == "" )
if ( nomMP.empty() )
{
// cette ligne ne contient pas d'info
return;
@ -1126,37 +1126,37 @@ void NewMP( CSString& ligne )
ligne.splitTo( ";", true );
stat = ligne.splitTo( ";", true );
if ( stat.firstWord() != "" )
if ( !stat.firstWord().empty() )
craftStats.bestStatA = stat.atoi();
else
craftStats.bestStatA = -1;
stat = ligne.splitTo( ";", true );
if ( stat.firstWord() != "" )
if ( !stat.firstWord().empty() )
craftStats.worstStatA1 = stat.atoi();
else
craftStats.worstStatA1 = -1;
stat = ligne.splitTo( ";", true );
if ( stat.firstWord() != "" )
if ( !stat.firstWord().empty() )
craftStats.worstStatA2 = stat.atoi();
else
craftStats.worstStatA2 = -1;
stat = ligne.splitTo( ";", true );
if ( stat.firstWord() != "" )
if ( !stat.firstWord().empty() )
craftStats.bestStatB = stat.atoi();
else
craftStats.bestStatB = -1;
stat = ligne.splitTo( ";", true );
if ( stat.firstWord() != "" )
if ( !stat.firstWord().empty() )
craftStats.worstStatB1 = stat.atoi();
else
craftStats.worstStatB1 = -1;
stat = ligne.splitTo( ";", true );
if ( stat.firstWord() != "" )
if ( !stat.firstWord().empty() )
craftStats.worstStatB2 = stat.atoi();
else
craftStats.worstStatB2 = -1;
@ -1168,19 +1168,19 @@ void NewMP( CSString& ligne )
specialOnly = stat.firstWord().contains( "x" );
// cas particuliers
while ( ligne != "" )
while ( !ligne.empty() )
{
if ( !ligne.contains( ";" ) )
{
special = ligne;
if ( special.firstWord() != "" )
if ( !special.firstWord().empty() )
specialNames.insert( special );
ligne = "";
}
else
{
special = ligne.splitTo( ";", true );
if ( special != "" )
if ( !special.empty() )
specialNames.insert( special );
}
}
@ -1357,7 +1357,7 @@ void LoadCustomizedProperties()
fileName = CPath::lookup( name, false, false, true );
// on vérifie que le fichier concerné existe
if ( fileName != "" )
if ( !fileName.empty() )
{
CSString zone = prop.splitTo( ".", true );
str.readFromFile( fileName );
@ -1530,7 +1530,7 @@ void LoadFamillesMP()
ligne = fileData.splitTo( "\n", true );
while ( ligne != "" )
while ( !ligne.empty() )
{
NewMP( ligne );
ligne = fileData.splitTo( "\n", true );

View file

@ -67,7 +67,7 @@ int verifItemsFile (const char *filename)
string s(buffer);
// null or comment
if (s == "" || s.find("//") == 0)
if (s.empty() || s.find("//") == 0)
continue;
if (s.find("_LocSlot") == string::npos)
@ -113,7 +113,7 @@ int verifCsvFile (const char *filename)
void processItemLine(const string &s)
{
// null or comment
if (s == "" || s.find("//") == 0)
if (s.empty() || s.find("//") == 0)
return;
// other stuff
@ -176,7 +176,7 @@ int getFieldsFromFile(const char *filename)
s = s.strtok("\n");
// skip null or comment
if (s == "" || s.find("//") == 0)
if (s.empty() || s.find("//") == 0)
continue;
// add the field
@ -294,7 +294,7 @@ void getItemBounds(const CVectorSString &lines, uint num, uint &a, uint &b)
while (++i < lines.size() && !ok)
{
if (lines[i] == "" || lines[i].find("//") != string::npos)
if (lines[i].empty() || lines[i].find("//") != string::npos)
continue;
// get item number
@ -404,7 +404,7 @@ void updateItemField(CVectorSString &lines, uint itemIndex, uint fieldIndex, uin
}
// param not found
if (!found && val != "" && val != "nul")
if (!found && !val.empty() && val != "nul")
{
// add it
if (field.find("_CraftParameters") == string::npos)
@ -552,7 +552,7 @@ int main(int argc, char *argv[])
// load csv values
importCsv(csvFile.c_str());
if (itemsFile != "" && CFile::isExists(itemsFile.c_str()))
if (!itemsFile.empty() && CFile::isExists(itemsFile.c_str()))
updateItems(itemsFile.c_str());
else
nlerror("Can't find file : %s", itemsFile.c_str());

View file

@ -216,7 +216,7 @@ void CDialogProperties::removeWidgets ()
else if (widget.Parameter.Type == CPrimitiveClass::CParameter::StringArray)
{
widget.MultiLineEditBox.DestroyWindow ();
if (widget.Parameter.Folder != "" || !widget.Parameter.FileExtension.empty())
if (!widget.Parameter.Folder.empty() || !widget.Parameter.FileExtension.empty())
{
widget.CheckBox.DestroyWindow ();
}