ActorUtil: retry is simpler and more obvious with tail-calls
This commit is contained in:
+3
-12
@@ -34,18 +34,11 @@ void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
|
||||
|
||||
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||
{
|
||||
bool done = false;
|
||||
// comply with VS C4701.
|
||||
RageFileManager::FileType ft = RageFileManager::TYPE_NONE;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
// Does this have to be collapsed every time?
|
||||
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.
|
||||
ft = FILEMAN->GetFileType( sPath );
|
||||
RageFileManager::FileType ft = FILEMAN->GetFileType( sPath );
|
||||
if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR )
|
||||
{
|
||||
vector<RString> asPaths;
|
||||
@@ -61,7 +54,7 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||
break;
|
||||
case Dialog::retry:
|
||||
FILEMAN->FlushDirCache();
|
||||
continue;
|
||||
return ResolvePath( sPath, sName );
|
||||
case Dialog::ignore:
|
||||
return false;
|
||||
default:
|
||||
@@ -82,7 +75,7 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||
break;
|
||||
case Dialog::retry:
|
||||
FILEMAN->FlushDirCache();
|
||||
continue;
|
||||
return ResolvePath( sPath, sName );
|
||||
case Dialog::ignore:
|
||||
asPaths.erase( asPaths.begin()+1, asPaths.end() );
|
||||
break;
|
||||
@@ -93,8 +86,6 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||
|
||||
sPath = asPaths[0];
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
|
||||
if( ft == RageFileManager::TYPE_DIR )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user