From 0698f1abc29e7329510e1cf994fd13b6245fc58b Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 6 Oct 2012 18:17:57 +0200 Subject: [PATCH] Changed: Replaced string empty comparisons with empty() --- code/nel/src/net/message_recorder.cpp | 2 +- code/nel/src/net/varpath.cpp | 2 +- .../sound/source_sounds_builder/SoundPage.cpp | 2 +- .../source_sounds_builderDlg.cpp | 8 +-- .../client/src/animated_scene_object.cpp | 6 +- code/ryzom/common/src/game_share/object.cpp | 2 +- .../src/ai_service/npc_description_msg.cpp | 2 +- .../src/entities_game_service/admin.cpp | 2 +- .../creature_manager/creature_manager.cpp | 2 +- .../shop_type/shop_type_manager.cpp | 4 +- .../src/input_output_service/chat_manager.cpp | 2 +- .../tools/leveldesign/mp_generator/main.cpp | 56 +++++++++---------- .../named_items_2_csv/named_items_2_csv.cpp | 12 ++-- .../world_editor/dialog_properties.cpp | 2 +- 14 files changed, 52 insertions(+), 52 deletions(-) diff --git a/code/nel/src/net/message_recorder.cpp b/code/nel/src/net/message_recorder.cpp index 4da49cb3e..ec52ad1da 100644 --- a/code/nel/src/net/message_recorder.cpp +++ b/code/nel/src/net/message_recorder.cpp @@ -80,7 +80,7 @@ CMessageRecorder::CMessageRecorder() : _RecordAll(true) */ CMessageRecorder::~CMessageRecorder() { - if ( _Filename != "" ) + if ( !_Filename.empty() ) { nldebug( "MR:%s: End of recording", _Filename.c_str() ); } diff --git a/code/nel/src/net/varpath.cpp b/code/nel/src/net/varpath.cpp index d1ce0bcf3..729f52074 100644 --- a/code/nel/src/net/varpath.cpp +++ b/code/nel/src/net/varpath.cpp @@ -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; diff --git a/code/nel/tools/sound/source_sounds_builder/SoundPage.cpp b/code/nel/tools/sound/source_sounds_builder/SoundPage.cpp index 2664bc033..0ad410098 100644 --- a/code/nel/tools/sound/source_sounds_builder/SoundPage.cpp +++ b/code/nel/tools/sound/source_sounds_builder/SoundPage.cpp @@ -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 ); diff --git a/code/nel/tools/sound/source_sounds_builder/source_sounds_builderDlg.cpp b/code/nel/tools/sound/source_sounds_builder/source_sounds_builderDlg.cpp index e5643fba4..2ba1b70a5 100644 --- a/code/nel/tools/sound/source_sounds_builder/source_sounds_builderDlg.cpp +++ b/code/nel/tools/sound/source_sounds_builder/source_sounds_builderDlg.cpp @@ -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() ); } diff --git a/code/ryzom/client/src/animated_scene_object.cpp b/code/ryzom/client/src/animated_scene_object.cpp index 6367830db..9e1b4273c 100644 --- a/code/ryzom/client/src/animated_scene_object.cpp +++ b/code/ryzom/client/src/animated_scene_object.cpp @@ -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 ); } diff --git a/code/ryzom/common/src/game_share/object.cpp b/code/ryzom/common/src/game_share/object.cpp index 6d1feb2fe..a034ddb2e 100644 --- a/code/ryzom/common/src/game_share/object.cpp +++ b/code/ryzom/common/src/game_share/object.cpp @@ -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) { diff --git a/code/ryzom/server/src/ai_service/npc_description_msg.cpp b/code/ryzom/server/src/ai_service/npc_description_msg.cpp index a5a90ad29..62ba4d9f8 100644 --- a/code/ryzom/server/src/ai_service/npc_description_msg.cpp +++ b/code/ryzom/server/src/ai_service/npc_description_msg.cpp @@ -128,7 +128,7 @@ static bool LookupShopType(std::string name,std::vector &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;jasString(); string page = varPage->asString(); - if (host == "" || page == "") + if (host.empty() || page.empty()) return; char params[1024]; diff --git a/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.cpp b/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.cpp index 3def0fde0..7c0dc7780 100644 --- a/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.cpp @@ -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 - if (_UserModelId != "" && CDynamicSheetManager::getInstance()->scriptErrors(_PrimAlias, _UserModelId) == true) + if (!_UserModelId.empty() && CDynamicSheetManager::getInstance()->scriptErrors(_PrimAlias, _UserModelId) == true) { TDataSetRow row = creature->getEntityRowId(); ucstring name; diff --git a/code/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp b/code/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp index 504462410..6b1aa0d9d 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp @@ -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 &>(args)); diff --git a/code/ryzom/server/src/input_output_service/chat_manager.cpp b/code/ryzom/server/src/input_output_service/chat_manager.cpp index f86ec26e6..27d1c55e8 100644 --- a/code/ryzom/server/src/input_output_service/chat_manager.cpp +++ b/code/ryzom/server/src/input_output_service/chat_manager.cpp @@ -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"); } diff --git a/code/ryzom/tools/leveldesign/mp_generator/main.cpp b/code/ryzom/tools/leveldesign/mp_generator/main.cpp index bcf7fdf52..e61546a8d 100644 --- a/code/ryzom/tools/leveldesign/mp_generator/main.cpp +++ b/code/ryzom/tools/leveldesign/mp_generator/main.cpp @@ -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 += " \n"; - if ( icon != "" ) + if ( !icon.empty() ) { output += " \n"; } - if ( overlay != "" ) + if ( !overlay.empty() ) { output += " \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 ); diff --git a/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp b/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp index ca89cae2f..6ab9e2a26 100644 --- a/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp +++ b/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp @@ -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()); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index 31189622a..e39994fc4 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -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 (); }