From fbc605302dbe24fa151f64cebbbee833177a2727 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 24 Jan 2013 22:38:24 -0500 Subject: [PATCH] More goto removals. Note: unsure if the path must be collapsed each time. --- src/ActorUtil.cpp | 92 +++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index e7a4658b61..bc8134bf18 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -34,58 +34,66 @@ void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn ) bool ActorUtil::ResolvePath( RString &sPath, const RString &sName ) { -retry: - CollapsePath( sPath ); - - // If we know this is an exact match, don't bother with the GetDirListing, - // so "foo" doesn't partial match "foobar" if "foo" exists. - RageFileManager::FileType ft = FILEMAN->GetFileType( sPath ); - if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR ) + bool done = false; + // comply with VS C4701. + RageFileManager::FileType ft = RageFileManager::TYPE_NONE; + + while (!done) { - vector asPaths; - GetDirListing( sPath + "*", asPaths, false, true ); // return path too + // Does this have to be collapsed every time? + CollapsePath( sPath ); - if( asPaths.empty() ) + // If we know this is an exact match, don't bother with the GetDirListing, + // so "foo" doesn't partial match "foobar" if "foo" exists. + ft = FILEMAN->GetFileType( sPath ); + if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR ) { - RString sError = ssprintf( "%s: references a file \"%s\" which doesn't exist", sName.c_str(), sPath.c_str() ); - switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) ) + vector asPaths; + GetDirListing( sPath + "*", asPaths, false, true ); // return path too + + if( asPaths.empty() ) { - case Dialog::abort: - RageException::Throw( "%s", sError.c_str() ); - break; - case Dialog::retry: - FILEMAN->FlushDirCache(); - goto retry; - case Dialog::ignore: - return false; - default: - FAIL_M("Invalid response to Abort/Retry/Ignore dialog"); + RString sError = ssprintf( "%s: references a file \"%s\" which doesn't exist", sName.c_str(), sPath.c_str() ); + switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) ) + { + case Dialog::abort: + RageException::Throw( "%s", sError.c_str() ); + break; + case Dialog::retry: + FILEMAN->FlushDirCache(); + continue; + case Dialog::ignore: + return false; + default: + FAIL_M("Invalid response to Abort/Retry/Ignore dialog"); + } } - } - THEME->FilterFileLanguages( asPaths ); + THEME->FilterFileLanguages( asPaths ); - if( asPaths.size() > 1 ) - { - RString sError = ssprintf( "%s: references a file \"%s\" which has multiple matches", sName.c_str(), sPath.c_str() ); - sError += "\n" + join( "\n", asPaths ); - switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) ) + if( asPaths.size() > 1 ) { - case Dialog::abort: - RageException::Throw( "%s", sError.c_str() ); - break; - case Dialog::retry: - FILEMAN->FlushDirCache(); - goto retry; - case Dialog::ignore: - asPaths.erase( asPaths.begin()+1, asPaths.end() ); - break; - default: - FAIL_M("Invalid response to Abort/Retry/Ignore dialog"); + RString sError = ssprintf( "%s: references a file \"%s\" which has multiple matches", sName.c_str(), sPath.c_str() ); + sError += "\n" + join( "\n", asPaths ); + switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) ) + { + case Dialog::abort: + RageException::Throw( "%s", sError.c_str() ); + break; + case Dialog::retry: + FILEMAN->FlushDirCache(); + continue; + case Dialog::ignore: + asPaths.erase( asPaths.begin()+1, asPaths.end() ); + break; + default: + FAIL_M("Invalid response to Abort/Retry/Ignore dialog"); + } } - } - sPath = asPaths[0]; + sPath = asPaths[0]; + } + done = true; } if( ft == RageFileManager::TYPE_DIR )