replace gotos with do/while logic where appropriate
This commit is contained in:
+5
-6
@@ -751,12 +751,11 @@ void RageSemaphore::Post()
|
|||||||
|
|
||||||
void RageSemaphore::Wait( bool bFailOnTimeout )
|
void RageSemaphore::Wait( bool bFailOnTimeout )
|
||||||
{
|
{
|
||||||
retry:
|
do
|
||||||
if( m_pSema->Wait() )
|
{
|
||||||
return;
|
if( m_pSema->Wait() )
|
||||||
|
return;
|
||||||
if( !bFailOnTimeout || RageThread::GetIsShowingDialog() )
|
} while( !bFailOnTimeout || RageThread::GetIsShowingDialog() );
|
||||||
goto retry;
|
|
||||||
|
|
||||||
/* We waited too long. We're probably deadlocked, though unlike mutexes, we can't
|
/* We waited too long. We're probably deadlocked, though unlike mutexes, we can't
|
||||||
* tell which thread we're stuck on. */
|
* tell which thread we're stuck on. */
|
||||||
|
|||||||
+11
-12
@@ -390,20 +390,19 @@ bool ScreenSelectMaster::Move( PlayerNumber pn, MenuDir dir )
|
|||||||
|
|
||||||
int iSwitchToIndex = m_iChoice[pn];
|
int iSwitchToIndex = m_iChoice[pn];
|
||||||
set<int> seen;
|
set<int> seen;
|
||||||
try_again:
|
|
||||||
|
|
||||||
map<int,int>::const_iterator iter = m_mapCurrentChoiceToNextChoice[dir].find( iSwitchToIndex );
|
do
|
||||||
if( iter != m_mapCurrentChoiceToNextChoice[dir].end() )
|
{
|
||||||
iSwitchToIndex = iter->second;
|
map<int,int>::const_iterator iter = m_mapCurrentChoiceToNextChoice[dir].find( iSwitchToIndex );
|
||||||
|
if( iter != m_mapCurrentChoiceToNextChoice[dir].end() )
|
||||||
|
iSwitchToIndex = iter->second;
|
||||||
|
|
||||||
if( iSwitchToIndex < 0 || iSwitchToIndex >= (int) m_aGameCommands.size() ) // out of choice range
|
if( iSwitchToIndex < 0 || iSwitchToIndex >= (int) m_aGameCommands.size() ) // out of choice range
|
||||||
return false; // can't go that way
|
return false; // can't go that way
|
||||||
if( seen.find(iSwitchToIndex) != seen.end() )
|
if( seen.find(iSwitchToIndex) != seen.end() )
|
||||||
return false; // went full circle and none found
|
return false; // went full circle and none found
|
||||||
seen.insert( iSwitchToIndex );
|
seen.insert( iSwitchToIndex );
|
||||||
|
} while( !m_aGameCommands[iSwitchToIndex].IsPlayable() && !DO_SWITCH_ANYWAYS );
|
||||||
if( !m_aGameCommands[iSwitchToIndex].IsPlayable() && !DO_SWITCH_ANYWAYS )
|
|
||||||
goto try_again;
|
|
||||||
|
|
||||||
return ChangeSelection( pn, dir, iSwitchToIndex );
|
return ChangeSelection( pn, dir, iSwitchToIndex );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,58 +332,58 @@ void CSMPackageInstallDlg::OnOK()
|
|||||||
ProgressInit = 1;
|
ProgressInit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retry_unzip:
|
Dialog::Result result;
|
||||||
|
do
|
||||||
// Extract the files
|
|
||||||
const RString sFile = vs[i];
|
|
||||||
LOG->Trace( "Extracting: "+sFile );
|
|
||||||
|
|
||||||
RString sError;
|
|
||||||
{
|
{
|
||||||
int iErr;
|
// Extract the files
|
||||||
RageFileBasic *pFileFrom = zip.Open( sFile, RageFile::READ, iErr );
|
const RString sFile = vs[i];
|
||||||
if( pFileFrom == NULL )
|
LOG->Trace( "Extracting: "+sFile );
|
||||||
|
|
||||||
|
RString sError;
|
||||||
{
|
{
|
||||||
sError = ssprintf( ERROR_OPENING_SOURCE_FILE.GetValue(), sFile.c_str(), ssprintf("%d",iErr).c_str() );
|
int iErr;
|
||||||
goto show_error;
|
RageFileBasic *pFileFrom = zip.Open( sFile, RageFile::READ, iErr );
|
||||||
|
if( pFileFrom == NULL )
|
||||||
|
{
|
||||||
|
sError = ssprintf( ERROR_OPENING_SOURCE_FILE.GetValue(), sFile.c_str(), ssprintf("%d",iErr).c_str() );
|
||||||
|
goto show_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iError;
|
||||||
|
RageFileBasic *pFileTo = dir.Open( sFile, RageFile::WRITE, iError );
|
||||||
|
if( pFileTo == NULL )
|
||||||
|
{
|
||||||
|
sError = ssprintf( ERROR_OPENING_DESTINATION_FILE.GetValue(), sFile.c_str(), pFileTo->GetError().c_str() );
|
||||||
|
goto show_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
RString sErr;
|
||||||
|
if( !FileCopy(*pFileFrom, *pFileTo, sErr) )
|
||||||
|
{
|
||||||
|
sError = ssprintf( ERROR_COPYING_FILE.GetValue(), sFile.c_str(), sErr.c_str() );
|
||||||
|
goto show_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
SAFE_DELETE( pFileFrom );
|
||||||
|
SAFE_DELETE( pFileTo );
|
||||||
}
|
}
|
||||||
|
|
||||||
int iError;
|
break;
|
||||||
RageFileBasic *pFileTo = dir.Open( sFile, RageFile::WRITE, iError );
|
|
||||||
if( pFileTo == NULL )
|
|
||||||
{
|
|
||||||
sError = ssprintf( ERROR_OPENING_DESTINATION_FILE.GetValue(), sFile.c_str(), pFileTo->GetError().c_str() );
|
|
||||||
goto show_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
RString sErr;
|
|
||||||
if( !FileCopy(*pFileFrom, *pFileTo, sErr) )
|
|
||||||
{
|
|
||||||
sError = ssprintf( ERROR_COPYING_FILE.GetValue(), sFile.c_str(), sErr.c_str() );
|
|
||||||
goto show_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
SAFE_DELETE( pFileFrom );
|
|
||||||
SAFE_DELETE( pFileTo );
|
|
||||||
}
|
|
||||||
|
|
||||||
goto done_with_file;
|
|
||||||
|
|
||||||
show_error:
|
show_error:
|
||||||
switch( Dialog::AbortRetryIgnore(sError) )
|
Dialog::Result result = Dialog::AbortRetryIgnore(sError);
|
||||||
{
|
switch( result )
|
||||||
case Dialog::abort:
|
{
|
||||||
exit(1); // better way to exit?
|
case Dialog::abort:
|
||||||
break;
|
exit(1); // better way to exit?
|
||||||
case Dialog::retry:
|
break;
|
||||||
goto retry_unzip;
|
case Dialog::retry:
|
||||||
break;
|
break;
|
||||||
case Dialog::ignore:
|
case Dialog::ignore:
|
||||||
// do nothing
|
// do nothing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} while( result == Dialog::retry );
|
||||||
done_with_file:
|
|
||||||
|
|
||||||
pProgress1->StepIt(); //increase the progress bar of 1 step
|
pProgress1->StepIt(); //increase the progress bar of 1 step
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user