Fix minor windows pedantic warnings.

This commit is contained in:
Jason Felds
2016-03-27 22:03:15 -04:00
parent 534909d30a
commit bec18a0d36
31 changed files with 173 additions and 67 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ void AutoKeysounds::LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain )
for( int t = 0; t < iNumTracks; t++ ) for( int t = 0; t < iNumTracks; t++ )
{ {
int iRow = -1; int iRow = -1;
while(1) for(;;)
{ {
/* Find the next row that either player has a note on. */ /* Find the next row that either player has a note on. */
int iNextRow = INT_MAX; int iNextRow = INT_MAX;
+1 -1
View File
@@ -80,7 +80,7 @@ public:
// ... meanwhile DWORD WINAPI ZipReceiverThread(void *dat) // ... meanwhile DWORD WINAPI ZipReceiverThread(void *dat)
// { HANDLE hread = (HANDLE)dat; // { HANDLE hread = (HANDLE)dat;
// char buf[1000]; // char buf[1000];
// while (true) // for(;;)
// { DWORD red; ReadFile(hread,buf,1000,&red,NULL); // { DWORD red; ReadFile(hread,buf,1000,&red,NULL);
// // ... and do something with this zip data we're receiving // // ... and do something with this zip data we're receiving
// if (red==0) break; // if (red==0) break;
+1 -1
View File
@@ -31,7 +31,7 @@ bool CsvFile::ReadFile( RageFileBasic &f )
// hi,"hi2,","""hi3""" // hi,"hi2,","""hi3"""
while( 1 ) for(;;)
{ {
RString line; RString line;
switch( f.GetLine(line) ) switch( f.GetLine(line) )
+1 -1
View File
@@ -166,7 +166,7 @@ void StepsDisplayList::UpdatePositions()
/* If less than total (and Rows.size()) are displayed, fill in the empty /* If less than total (and Rows.size()) are displayed, fill in the empty
* space intelligently. */ * space intelligently. */
while(1) for(;;)
{ {
const int sum = (first_end - first_start) + (second_end - second_start); const int sum = (first_end - first_start) + (second_end - second_start);
if( sum >= (int) Rows.size() || sum >= total) if( sum >= (int) Rows.size() || sum >= total)
+4 -2
View File
@@ -238,7 +238,7 @@ void FileTransfer::HTTPUpdate()
// Keep this as a code block, as there may be need to "if" it out some time. // Keep this as a code block, as there may be need to "if" it out some time.
/* If you need a conditional for a large block of code, stick it in /* If you need a conditional for a large block of code, stick it in
* a function and return. */ * a function and return. */
while(1) for(;;)
{ {
char Buffer[1024]; char Buffer[1024];
int iSize = m_wSocket.ReadData( Buffer, 1024 ); int iSize = m_wSocket.ReadData( Buffer, 1024 );
@@ -359,15 +359,17 @@ bool FileTransfer::ParseHTTPAddress( const RString &URL, RString &sProto, RStrin
void FileTransfer::Finish() void FileTransfer::Finish()
{ {
while( true ) for(;;)
{ {
float fSleepSeconds = 0.1f; float fSleepSeconds = 0.1f;
this->Update( fSleepSeconds ); this->Update( fSleepSeconds );
usleep( int( fSleepSeconds * 1000000.0 ) ); usleep( int( fSleepSeconds * 1000000.0 ) );
if( this->IsFinished() ) if( this->IsFinished() )
{
break; break;
} }
} }
}
#endif #endif
/* /*
+12 -4
View File
@@ -2369,15 +2369,18 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(); const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
Difficulty d = GetClosestShownDifficulty(pn); Difficulty d = GetClosestShownDifficulty(pn);
while( 1 ) for(;;)
{ {
d = enum_add2( d, dir ); d = enum_add2( d, dir );
if( d < 0 || d >= NUM_Difficulty ) if( d < 0 || d >= NUM_Difficulty )
{
return false; return false;
}
if( find(v.begin(), v.end(), d) != v.end() ) if( find(v.begin(), v.end(), d) != v.end() )
{
break; // found break; // found
} }
}
m_PreferredDifficulty[pn].Set( d ); m_PreferredDifficulty[pn].Set( d );
return true; return true;
} }
@@ -2424,17 +2427,22 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
const vector<CourseDifficulty> &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); const vector<CourseDifficulty> &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue();
CourseDifficulty cd = m_PreferredCourseDifficulty[pn]; CourseDifficulty cd = m_PreferredCourseDifficulty[pn];
while( 1 ) for(;;)
{ {
cd = enum_add2( cd, dir ); cd = enum_add2( cd, dir );
if( cd < 0 || cd >= NUM_Difficulty ) if( cd < 0 || cd >= NUM_Difficulty )
{
return false; return false;
}
if( find(v.begin(),v.end(),cd) == v.end() ) if( find(v.begin(),v.end(),cd) == v.end() )
{
continue; /* not available */ continue; /* not available */
}
if( !pCourse || pCourse->GetTrail( GetCurrentStyle(pn)->m_StepsType, cd ) ) if( !pCourse || pCourse->GetTrail( GetCurrentStyle(pn)->m_StepsType, cd ) )
{
break; break;
} }
}
return ChangePreferredCourseDifficulty( pn, cd ); return ChangePreferredCourseDifficulty( pn, cd );
} }
+4 -3
View File
@@ -36,11 +36,11 @@ bool IniFile::ReadFile( RageFileBasic &f )
RString keyname; RString keyname;
// keychild is used to cache the node that values are being added to. -Kyz // keychild is used to cache the node that values are being added to. -Kyz
XNode* keychild= NULL; XNode* keychild= NULL;
while( 1 ) for(;;)
{ {
RString line; RString line;
// Read lines until we reach a line that doesn't end in a backslash // Read lines until we reach a line that doesn't end in a backslash
while( true ) for(;;)
{ {
RString s; RString s;
switch( f.GetLine(s) ) switch( f.GetLine(s) )
@@ -57,8 +57,9 @@ bool IniFile::ReadFile( RageFileBasic &f )
line += s; line += s;
if( line.empty() || line[line.size()-1] != '\\' ) if( line.empty() || line[line.size()-1] != '\\' )
{
break; break;
}
line.erase( line.end()-1 ); line.erase( line.end()-1 );
} }
+1 -1
View File
@@ -187,7 +187,7 @@ bool InputQueueCode::Load( RString sButtonsNames )
bool bHold = false; bool bHold = false;
bool bNotHold = false; bool bNotHold = false;
while(1) for(;;)
{ {
if( sButtonName.Left(1) == "+" ) if( sButtonName.Left(1) == "+" )
{ {
+3 -2
View File
@@ -26,11 +26,12 @@ namespace
/* Look at the first class. If it has a base class that needs to be registered, /* Look at the first class. If it has a base class that needs to be registered,
* go there first. */ * go there first. */
LuaBinding *pBinding = mapToRegister.begin()->second; LuaBinding *pBinding = mapToRegister.begin()->second;
while(1) for(;;)
{ {
if( !pBinding->IsDerivedClass() ) if( !pBinding->IsDerivedClass() )
{
break; break;
}
RString sBase = pBinding->GetBaseClassName(); RString sBase = pBinding->GetBaseClassName();
map<RString, LuaBinding *>::const_iterator it = mapToRegister.find(sBase); map<RString, LuaBinding *>::const_iterator it = mapToRegister.find(sBase);
if( it != mapToRegister.end() ) if( it != mapToRegister.end() )
+7 -2
View File
@@ -32,12 +32,14 @@ bool LyricsLoader::LoadFromLRCFile(const RString& sPath, Song& out)
out.m_LyricSegments.clear(); out.m_LyricSegments.clear();
while( 1 ) for(;;)
{ {
RString line; RString line;
int ret = input.GetLine( line ); int ret = input.GetLine( line );
if( ret == 0 ) if( ret == 0 )
{
break; break;
}
if( ret == -1 ) if( ret == -1 )
{ {
LuaHelpers::ReportScriptErrorFmt("Error reading %s: %s", input.GetPath().c_str(), input.GetError().c_str() ); LuaHelpers::ReportScriptErrorFmt("Error reading %s: %s", input.GetPath().c_str(), input.GetError().c_str() );
@@ -47,15 +49,18 @@ bool LyricsLoader::LoadFromLRCFile(const RString& sPath, Song& out)
utf8_remove_bom( line ); utf8_remove_bom( line );
if(!line.compare(0, 2, "//")) if(!line.compare(0, 2, "//"))
{
continue; continue;
}
// (most tags are in the format of...) // (most tags are in the format of...)
// "[data1] data2". Ignore whitespace at the beginning of the line. // "[data1] data2". Ignore whitespace at the beginning of the line.
static Regex x("^ *\\[([^]]+)\\] *(.*)$"); static Regex x("^ *\\[([^]]+)\\] *(.*)$");
vector<RString> matches; vector<RString> matches;
if(!x.Compare(line, matches)) if(!x.Compare(line, matches))
{
continue; continue;
}
ASSERT( matches.size() == 2 ); ASSERT( matches.size() == 2 );
RString &sValueName = matches[0]; RString &sValueName = matches[0];
+8 -3
View File
@@ -70,19 +70,22 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
* would do as I would expect. */ * would do as I would expect. */
split( sSMNoteData, ",", start, size, end, true ); // Ignore empty is important. split( sSMNoteData, ",", start, size, end, true ); // Ignore empty is important.
if( start == end ) if( start == end )
{
break; break;
}
// Partial string split. // Partial string split.
int measureLineStart = start, measureLineSize = -1; int measureLineStart = start, measureLineSize = -1;
const int measureEnd = start + size; const int measureEnd = start + size;
aMeasureLines.clear(); aMeasureLines.clear();
while( true ) for(;;)
{ {
// Ignore empty is clearly important here. // Ignore empty is clearly important here.
split( sSMNoteData, "\n", measureLineStart, measureLineSize, measureEnd, true ); split( sSMNoteData, "\n", measureLineStart, measureLineSize, measureEnd, true );
if( measureLineStart == measureEnd ) if( measureLineStart == measureEnd )
{
break; break;
}
//RString &line = sSMNoteData.substr( measureLineStart, measureLineSize ); //RString &line = sSMNoteData.substr( measureLineStart, measureLineSize );
const char *beginLine = sSMNoteData.data() + measureLineStart; const char *beginLine = sSMNoteData.data() + measureLineStart;
const char *endLine = beginLine + measureLineSize; const char *endLine = beginLine + measureLineSize;
@@ -706,11 +709,13 @@ void LightTransformHelper( const NoteData &in, NoteData &out, const vector<int>
* until we've extended to the end of the latest overlapping hold note. */ * until we've extended to the end of the latest overlapping hold note. */
int iHoldStart = r; int iHoldStart = r;
int iHoldEnd = -1; int iHoldEnd = -1;
while(1) for(;;)
{ {
int iMaxTailRow = FindLongestOverlappingHoldNoteForAnyTrack( in, r ); int iMaxTailRow = FindLongestOverlappingHoldNoteForAnyTrack( in, r );
if( iMaxTailRow == -1 ) if( iMaxTailRow == -1 )
{
break; break;
}
iHoldEnd = iMaxTailRow; iHoldEnd = iMaxTailRow;
r = iMaxTailRow; r = iMaxTailRow;
} }
+9 -2
View File
@@ -924,7 +924,7 @@ void NoteField::DrawPrimitives()
FOREACH_BackgroundLayer( j ) FOREACH_BackgroundLayer( j )
iter[j] = GAMESTATE->m_pCurSong->GetBackgroundChanges(j).begin(); iter[j] = GAMESTATE->m_pCurSong->GetBackgroundChanges(j).begin();
while( 1 ) for(;;)
{ {
float fLowestBeat = FLT_MAX; float fLowestBeat = FLT_MAX;
vector<BackgroundLayer> viLowestIndex; vector<BackgroundLayer> viLowestIndex;
@@ -932,8 +932,9 @@ void NoteField::DrawPrimitives()
FOREACH_BackgroundLayer( j ) FOREACH_BackgroundLayer( j )
{ {
if( iter[j] == GAMESTATE->m_pCurSong->GetBackgroundChanges(j).end() ) if( iter[j] == GAMESTATE->m_pCurSong->GetBackgroundChanges(j).end() )
{
continue; continue;
}
float fBeat = iter[j]->m_fStartBeat; float fBeat = iter[j]->m_fStartBeat;
if( fBeat < fLowestBeat ) if( fBeat < fLowestBeat )
{ {
@@ -950,7 +951,9 @@ void NoteField::DrawPrimitives()
if( viLowestIndex.empty() ) if( viLowestIndex.empty() )
{ {
FOREACH_BackgroundLayer( j ) FOREACH_BackgroundLayer( j )
{
ASSERT( iter[j] == GAMESTATE->m_pCurSong->GetBackgroundChanges(j).end() ); ASSERT( iter[j] == GAMESTATE->m_pCurSong->GetBackgroundChanges(j).end() );
}
break; break;
} }
@@ -963,15 +966,19 @@ void NoteField::DrawPrimitives()
const BackgroundChange& change = *iter[*bl]; const BackgroundChange& change = *iter[*bl];
RString s = change.GetTextDescription(); RString s = change.GetTextDescription();
if( *bl!=0 ) if( *bl!=0 )
{
s = ssprintf("%d: ",*bl) + s; s = ssprintf("%d: ",*bl) + s;
}
vsBGChanges.push_back( s ); vsBGChanges.push_back( s );
} }
DrawBGChangeText(fLowestBeat, join("\n",vsBGChanges), text_glow); DrawBGChangeText(fLowestBeat, join("\n",vsBGChanges), text_glow);
} }
FOREACH_CONST( BackgroundLayer, viLowestIndex, bl ) FOREACH_CONST( BackgroundLayer, viLowestIndex, bl )
{
iter[*bl]++; iter[*bl]++;
} }
} }
}
break; break;
default: default:
FAIL_M(ssprintf("Invalid edit mode: %i", mode)); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
+1 -1
View File
@@ -116,7 +116,7 @@ bool NoteSkinManager::LoadNoteSkinDataRecursive( const RString &sNoteSkinName_,
int iDepth = 0; int iDepth = 0;
bool bLoadedCommon = false; bool bLoadedCommon = false;
bool bLoadedBase = false; bool bLoadedBase = false;
while(1) for(;;)
{ {
++iDepth; ++iDepth;
if(iDepth >= 20) if(iDepth >= 20)
+7 -3
View File
@@ -327,12 +327,13 @@ int RageFileObj::GetLine( RString &sOut )
sOut = ""; sOut = "";
if( m_bEOF ) if( m_bEOF )
{
return 0; return 0;
}
EnableReadBuffering(); EnableReadBuffering();
bool bGotData = false; bool bGotData = false;
while( 1 ) for(;;)
{ {
bool bDone = false; bool bDone = false;
@@ -361,12 +362,15 @@ int RageFileObj::GetLine( RString &sOut )
{ {
char *RealEnd = p; char *RealEnd = p;
if( bDone && p > m_pReadBuf && p[-1] == '\r' ) if( bDone && p > m_pReadBuf && p[-1] == '\r' )
{
--RealEnd; /* not including \r */ --RealEnd; /* not including \r */
}
sOut.append( m_pReadBuf, RealEnd ); sOut.append( m_pReadBuf, RealEnd );
if( bDone ) if( bDone )
{
++p; /* skip \n */ ++p; /* skip \n */
}
const int iUsed = p-m_pReadBuf; const int iUsed = p-m_pReadBuf;
if( iUsed ) if( iUsed )
{ {
+12 -6
View File
@@ -224,12 +224,13 @@ RageFileObjDeflate::~RageFileObjDeflate()
int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes ) int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes )
{ {
if( iBytes == 0 ) if( iBytes == 0 )
{
return 0; return 0;
}
m_pDeflate->next_in = (Bytef*) pBuffer; m_pDeflate->next_in = (Bytef*) pBuffer;
m_pDeflate->avail_in = iBytes; m_pDeflate->avail_in = iBytes;
while( 1 ) for(;;)
{ {
char buf[1024*4]; char buf[1024*4];
m_pDeflate->next_out = (Bytef *) buf; m_pDeflate->next_out = (Bytef *) buf;
@@ -238,8 +239,9 @@ int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes )
int err = deflate( m_pDeflate, Z_NO_FLUSH ); int err = deflate( m_pDeflate, Z_NO_FLUSH );
if( err != Z_OK ) if( err != Z_OK )
{
FAIL_M( ssprintf("deflate: err %i", err) ); FAIL_M( ssprintf("deflate: err %i", err) );
}
if( m_pDeflate->avail_out < sizeof(buf) ) if( m_pDeflate->avail_out < sizeof(buf) )
{ {
int lBytes = sizeof(buf)-m_pDeflate->avail_out; int lBytes = sizeof(buf)-m_pDeflate->avail_out;
@@ -257,9 +259,10 @@ int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes )
} }
if( m_pDeflate->avail_in == 0 && m_pDeflate->avail_out != 0 ) if( m_pDeflate->avail_in == 0 && m_pDeflate->avail_out != 0 )
{
break; break;
} }
}
return iBytes; return iBytes;
} }
@@ -270,7 +273,7 @@ int RageFileObjDeflate::FlushInternal()
{ {
m_pDeflate->avail_in = 0; m_pDeflate->avail_in = 0;
while( 1 ) for(;;)
{ {
char buf[1024*4]; char buf[1024*4];
m_pDeflate->next_out = (Bytef *) buf; m_pDeflate->next_out = (Bytef *) buf;
@@ -278,8 +281,9 @@ int RageFileObjDeflate::FlushInternal()
int err = deflate( m_pDeflate, Z_FINISH ); int err = deflate( m_pDeflate, Z_FINISH );
if( err != Z_OK && err != Z_STREAM_END ) if( err != Z_OK && err != Z_STREAM_END )
{
FAIL_M( ssprintf("deflate: err %i", err) ); FAIL_M( ssprintf("deflate: err %i", err) );
}
if( m_pDeflate->avail_out < sizeof(buf) ) if( m_pDeflate->avail_out < sizeof(buf) )
{ {
int iBytes = sizeof(buf)-m_pDeflate->avail_out; int iBytes = sizeof(buf)-m_pDeflate->avail_out;
@@ -297,9 +301,11 @@ int RageFileObjDeflate::FlushInternal()
} }
if( err == Z_STREAM_END && m_pDeflate->avail_out != 0 ) if( err == Z_STREAM_END && m_pDeflate->avail_out != 0 )
{
return m_pFile->Flush(); return m_pFile->Flush();
} }
} }
}
/* /*
* Parse a .gz file, check the header CRC16 if present, and return the data * Parse a .gz file, check the header CRC16 if present, and return the data
+5 -2
View File
@@ -117,13 +117,16 @@ static bool GrabDriver( RageFileDriver *pDriver )
{ {
g_Mutex->Lock(); g_Mutex->Lock();
while(1) for(;;)
{ {
unsigned i; unsigned i;
for( i = 0; i < g_pDrivers.size(); ++i ) for( i = 0; i < g_pDrivers.size(); ++i )
{
if( g_pDrivers[i]->m_pDriver == pDriver ) if( g_pDrivers[i]->m_pDriver == pDriver )
{
break; break;
}
}
if( i == g_pDrivers.size() ) if( i == g_pDrivers.size() )
{ {
g_Mutex->Unlock(); g_Mutex->Unlock();
+7 -3
View File
@@ -389,7 +389,7 @@ int RageSoundReader_MP3::do_mad_frame_decode( bool headers_only )
{ {
int bytes_read = 0; int bytes_read = 0;
while(1) for(;;)
{ {
int ret; int ret;
@@ -861,7 +861,7 @@ int RageSoundReader_MP3::SetPosition_hard( int iFrame )
} }
/* Decode frames until the current frame contains the desired offset. */ /* Decode frames until the current frame contains the desired offset. */
while(1) for(;;)
{ {
/* If desired < next_frame_timer, this frame contains the position. Since we've /* If desired < next_frame_timer, this frame contains the position. Since we've
* already decoded the frame, synth it, too. */ * already decoded the frame, synth it, too. */
@@ -1035,14 +1035,18 @@ int RageSoundReader_MP3::GetLengthInternal( bool fast )
} }
MADLIB_rewind(); MADLIB_rewind();
while(1) for(;;)
{ {
int ret = do_mad_frame_decode( true ); int ret = do_mad_frame_decode( true );
if( ret == -1 ) if( ret == -1 )
{
return -1; /* it set the error */ return -1; /* it set the error */
}
if( ret == 0 ) /* EOF */ if( ret == 0 ) /* EOF */
{
break; break;
} }
}
/* mad->Timer is the timestamp of the current frame; find the timestamp of /* mad->Timer is the timestamp of the current frame; find the timestamp of
* the very end. */ * the very end. */
+9 -3
View File
@@ -69,20 +69,24 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource )
m_Buffer.Get()->reserve( iBytes ); m_Buffer.Get()->reserve( iBytes );
} }
while(1) for(;;)
{ {
/* If the rate changes, we won't preload it. */ /* If the rate changes, we won't preload it. */
if( pSource->GetStreamToSourceRatio() != m_fRate ) if( pSource->GetStreamToSourceRatio() != m_fRate )
{
return false; /* Don't bother trying to preload it. */ return false; /* Don't bother trying to preload it. */
}
float buffer[1024]; float buffer[1024];
int iCnt = pSource->Read( buffer, ARRAYLEN(buffer) / m_iChannels ); int iCnt = pSource->Read( buffer, ARRAYLEN(buffer) / m_iChannels );
if( iCnt == END_OF_FILE ) if( iCnt == END_OF_FILE )
{
break; break;
}
if( iCnt < 0 ) if( iCnt < 0 )
{
return false; return false;
}
/* Add the buffer. */ /* Add the buffer. */
if( m_bBufferIs16Bit ) if( m_bBufferIs16Bit )
{ {
@@ -96,8 +100,10 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource )
} }
if( m_Buffer.Get()->size() > iMaxSamples * samplesize ) if( m_Buffer.Get()->size() > iMaxSamples * samplesize )
{
return false; /* too big */ return false; /* too big */
} }
}
m_iPosition = 0; m_iPosition = 0;
delete pSource; delete pSource;
+3 -2
View File
@@ -110,12 +110,13 @@ namespace
int GCD( int i1, int i2 ) int GCD( int i1, int i2 )
{ {
while(1) for(;;)
{ {
unsigned iRem = i2 % i1; unsigned iRem = i2 % i1;
if( iRem == 0 ) if( iRem == 0 )
{
return i1; return i1;
}
i2 = i1; i2 = i1;
i1 = iRem; i1 = iRem;
} }
+5 -1
View File
@@ -235,7 +235,7 @@ int RageSoundReader_SpeedChange::GetCursorAvail() const
int RageSoundReader_SpeedChange::Read( float *pBuf, int iFrames ) int RageSoundReader_SpeedChange::Read( float *pBuf, int iFrames )
{ {
while( 1 ) for(;;)
{ {
if( m_iDataBufferAvailFrames == 0 && m_fTrailingSpeedRatio == m_fSpeedRatio && m_fSpeedRatio == 1.0f ) if( m_iDataBufferAvailFrames == 0 && m_fTrailingSpeedRatio == m_fSpeedRatio && m_fSpeedRatio == 1.0f )
{ {
@@ -250,9 +250,13 @@ int RageSoundReader_SpeedChange::Read( float *pBuf, int iFrames )
{ {
int iRet = Step(); int iRet = Step();
if( iRet < 0 ) if( iRet < 0 )
{
return iRet; return iRet;
}
if( !GetCursorAvail() ) if( !GetCursorAvail() )
{
return END_OF_FILE; return END_OF_FILE;
}
continue; continue;
} }
+7 -2
View File
@@ -120,23 +120,28 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither
* [GRR POSSIBLE BUG: what about 32^4 ?] */ * [GRR POSSIBLE BUG: what about 32^4 ?] */
acolorhist_item *achv; acolorhist_item *achv;
int colors; int colors;
while(1) for(;;)
{ {
achv = pam_computeacolorhist( pImg, MAXCOLORS, &colors ); achv = pam_computeacolorhist( pImg, MAXCOLORS, &colors );
if( achv != NULL ) if( achv != NULL )
{
break; break;
}
pixval newmaxval = maxval / 2; pixval newmaxval = maxval / 2;
int table[256]; int table[256];
for( int c = 0; c <= maxval; ++c ) for( int c = 0; c <= maxval; ++c )
{
table[c] = ( (uint8_t) c * newmaxval + maxval/2 ) / maxval; table[c] = ( (uint8_t) c * newmaxval + maxval/2 ) / maxval;
}
for( int row = 0; row < pImg->h; ++row ) for( int row = 0; row < pImg->h; ++row )
{ {
apixel *pP = (apixel *) (pImg->pixels+row*pImg->pitch); apixel *pP = (apixel *) (pImg->pixels+row*pImg->pitch);
for( int col = 0; col < pImg->w; ++col, ++pP ) for( int col = 0; col < pImg->w; ++col, ++pP )
{
PAM_DEPTH( *pP ); PAM_DEPTH( *pP );
} }
}
maxval = newmaxval; maxval = newmaxval;
} }
newcolors = min( colors, iColors ); newcolors = min( colors, iColors );
+1 -1
View File
@@ -117,7 +117,7 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const RString &sPath, RageSur
int transparency = -1; int transparency = -1;
while(1) for(;;)
{ {
unsigned char type; unsigned char type;
if( !ReadOK(f, &type, 1) ) if( !ReadOK(f, &type, 1) )
+1 -1
View File
@@ -3,7 +3,7 @@
* *
* As a timer, * As a timer,
* RageTimer Timer; * RageTimer Timer;
* while(1) { * for(;;) {
* printf( "Will be approximately: %f", Timer.PeekDeltaTime()) ; * printf( "Will be approximately: %f", Timer.PeekDeltaTime()) ;
* float fDeltaTime = Timer.GetDeltaTime(); * float fDeltaTime = Timer.GetDeltaTime();
* } * }
+10 -2
View File
@@ -881,7 +881,7 @@ void split( const wstring &sSource, const wstring &sDelimitor, vector<wstring> &
RString str="a,b,c"; RString str="a,b,c";
int start = 0, size = -1; int start = 0, size = -1;
while( 1 ) for(;;)
{ {
do_split( str, ",", start, size ); do_split( str, ",", start, size );
if( start == str.size() ) if( start == str.size() )
@@ -2379,24 +2379,30 @@ bool FileCopy( const RString &sSrcFile, const RString &sDstFile )
bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bReadError ) bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bReadError )
{ {
while(1) for(;;)
{ {
RString data; RString data;
if( in.Read(data, 1024*32) == -1 ) if( in.Read(data, 1024*32) == -1 )
{ {
sError = ssprintf( "read error: %s", in.GetError().c_str() ); sError = ssprintf( "read error: %s", in.GetError().c_str() );
if( bReadError != NULL ) if( bReadError != NULL )
{
*bReadError = true; *bReadError = true;
}
return false; return false;
} }
if( data.empty() ) if( data.empty() )
{
break; break;
}
int i = out.Write(data); int i = out.Write(data);
if( i == -1 ) if( i == -1 )
{ {
sError = ssprintf( "write error: %s", out.GetError().c_str() ); sError = ssprintf( "write error: %s", out.GetError().c_str() );
if( bReadError != NULL ) if( bReadError != NULL )
{
*bReadError = false; *bReadError = false;
}
return false; return false;
} }
} }
@@ -2405,7 +2411,9 @@ bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bRe
{ {
sError = ssprintf( "write error: %s", out.GetError().c_str() ); sError = ssprintf( "write error: %s", out.GetError().c_str() );
if( bReadError != NULL ) if( bReadError != NULL )
{
*bReadError = false; *bReadError = false;
}
return false; return false;
} }
+11 -2
View File
@@ -640,24 +640,33 @@ void ScreenOptions::PositionRows( bool bTween )
/* If less than total (and Rows.size()) are displayed, fill in the empty /* If less than total (and Rows.size()) are displayed, fill in the empty
* space intelligently. */ * space intelligently. */
while(1) for(;;)
{ {
const int sum = (first_end - first_start) + (second_end - second_start); const int sum = (first_end - first_start) + (second_end - second_start);
if( sum >= (int) Rows.size() || sum >= total) if( sum >= (int) Rows.size() || sum >= total)
{
break; // nothing more to display, or no room break; // nothing more to display, or no room
}
/* First priority: expand the top of the second half until it meets /* First priority: expand the top of the second half until it meets
* the first half. */ * the first half. */
if( second_start > first_end ) if( second_start > first_end )
{
second_start--; second_start--;
}
// Otherwise, expand either end. // Otherwise, expand either end.
else if( first_start > 0 ) else if( first_start > 0 )
{
first_start--; first_start--;
}
else if( second_end < (int) Rows.size() ) else if( second_end < (int) Rows.size() )
{
second_end++; second_end++;
}
else else
{
FAIL_M("Do we have room to grow or don't we?"); FAIL_M("Do we have room to grow or don't we?");
} }
}
int pos = 0; int pos = 0;
for( int i=0; i<(int) Rows.size(); i++ ) // foreach row for( int i=0; i<(int) Rows.size(); i++ ) // foreach row
+5 -3
View File
@@ -592,20 +592,22 @@ static LocalizedString WAITING_FOR_HEADER( "ScreenPackages", "Waiting for header
void ScreenPackages::HTTPUpdate() void ScreenPackages::HTTPUpdate()
{ {
if( !m_bIsDownloading ) if( !m_bIsDownloading )
{
return; return;
}
int BytesGot=0; int BytesGot=0;
// Keep this as a code block // Keep this as a code block
// as there may be need to "if" it out some time. // as there may be need to "if" it out some time.
/* If you need a conditional for a large block of code, stick it in /* If you need a conditional for a large block of code, stick it in
* a function and return. */ * a function and return. */
while(1) for(;;)
{ {
char Buffer[1024]; char Buffer[1024];
int iSize = m_wSocket.ReadData( Buffer, 1024 ); int iSize = m_wSocket.ReadData( Buffer, 1024 );
if( iSize <= 0 ) if( iSize <= 0 )
{
break; break;
}
m_sBUFFER.append( Buffer, iSize ); m_sBUFFER.append( Buffer, iSize );
BytesGot += iSize; BytesGot += iSize;
} }
+12 -6
View File
@@ -295,7 +295,7 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString &
m_sCurLanguage = sLanguage; m_sCurLanguage = sLanguage;
bool bLoadedBase = false; bool bLoadedBase = false;
while(1) for(;;)
{ {
ASSERT_M( g_vThemes.size() < 20, "Circular theme fallback references detected." ); ASSERT_M( g_vThemes.size() < 20, "Circular theme fallback references detected." );
@@ -315,13 +315,15 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString &
} }
iniStrings.ReadFile( GetLanguageIniPath(sThemeName,SpecialFiles::BASE_LANGUAGE) ); iniStrings.ReadFile( GetLanguageIniPath(sThemeName,SpecialFiles::BASE_LANGUAGE) );
if( sLanguage.CompareNoCase(SpecialFiles::BASE_LANGUAGE) ) if( sLanguage.CompareNoCase(SpecialFiles::BASE_LANGUAGE) )
{
iniStrings.ReadFile( GetLanguageIniPath(sThemeName,sLanguage) ); iniStrings.ReadFile( GetLanguageIniPath(sThemeName,sLanguage) );
}
bool bIsBaseTheme = !sThemeName.CompareNoCase(SpecialFiles::BASE_THEME_NAME); bool bIsBaseTheme = !sThemeName.CompareNoCase(SpecialFiles::BASE_THEME_NAME);
iniMetrics.GetValue( "Global", "IsBaseTheme", bIsBaseTheme ); iniMetrics.GetValue( "Global", "IsBaseTheme", bIsBaseTheme );
if( bIsBaseTheme ) if( bIsBaseTheme )
{
bLoadedBase = true; bLoadedBase = true;
}
/* Read the fallback theme. If no fallback theme is specified, and we haven't /* Read the fallback theme. If no fallback theme is specified, and we haven't
* already loaded it, fall back on SpecialFiles::BASE_THEME_NAME. * already loaded it, fall back on SpecialFiles::BASE_THEME_NAME.
* That way, default theme fallbacks can be disabled with * That way, default theme fallbacks can be disabled with
@@ -330,9 +332,10 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString &
if( !iniMetrics.GetValue("Global","FallbackTheme",sFallback) ) if( !iniMetrics.GetValue("Global","FallbackTheme",sFallback) )
{ {
if( sThemeName.CompareNoCase( SpecialFiles::BASE_THEME_NAME ) && !bLoadedBase ) if( sThemeName.CompareNoCase( SpecialFiles::BASE_THEME_NAME ) && !bLoadedBase )
{
sFallback = SpecialFiles::BASE_THEME_NAME; sFallback = SpecialFiles::BASE_THEME_NAME;
} }
}
/* We actually want to load themes bottom-to-top, loading fallback themes /* We actually want to load themes bottom-to-top, loading fallback themes
* first, so derived themes overwrite metrics in fallback themes. But, we * first, so derived themes overwrite metrics in fallback themes. But, we
* need to load the derived theme first, to find out the name of the fallback * need to load the derived theme first, to find out the name of the fallback
@@ -342,7 +345,9 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString &
XmlFileUtil::MergeIniUnder( &iniStrings, &g_pLoadedThemeData->iniStrings ); XmlFileUtil::MergeIniUnder( &iniStrings, &g_pLoadedThemeData->iniStrings );
if( sFallback.empty() ) if( sFallback.empty() )
{
break; break;
}
sThemeName = sFallback; sThemeName = sFallback;
} }
@@ -960,12 +965,13 @@ RString ThemeManager::GetMetricRaw( const IniFile &ini, const RString &sMetricsG
const RString sMetricsGroup = sMetricsGroup_; const RString sMetricsGroup = sMetricsGroup_;
const RString sValueName = sValueName_; const RString sValueName = sValueName_;
while( true ) for(;;)
{ {
RString ret; RString ret;
if( ThemeManager::GetMetricRawRecursive(ini, sMetricsGroup, sValueName, ret) ) if( ThemeManager::GetMetricRawRecursive(ini, sMetricsGroup, sValueName, ret) )
{
return ret; return ret;
}
RString sCurMetricPath = GetMetricsIniPath( m_sCurThemeName ); RString sCurMetricPath = GetMetricsIniPath( m_sCurThemeName );
RString sDefaultMetricPath = GetMetricsIniPath( SpecialFiles::BASE_THEME_NAME ); RString sDefaultMetricPath = GetMetricsIniPath( SpecialFiles::BASE_THEME_NAME );
@@ -174,23 +174,30 @@ int MovieDecoder_FFMpeg::DecodeFrame( float fTargetTime )
m_fLastFrame=fTargetTime; m_fLastFrame=fTargetTime;
} }
while( 1 ) for(;;)
{ {
int ret = DecodePacket( fTargetTime ); int ret = DecodePacket( fTargetTime );
if( ret == 1 ) if( ret == 1 )
{
return 1; return 1;
}
if( ret == -1 ) if( ret == -1 )
{
return -1; return -1;
}
if( ret == 0 && m_iEOF > 0 ) if( ret == 0 && m_iEOF > 0 )
{
return 0; /* eof */ return 0; /* eof */
}
ASSERT( ret == 0 ); ASSERT( ret == 0 );
ret = ReadPacket(); ret = ReadPacket();
if( ret < 0 ) if( ret < 0 )
{
return ret; /* error */ return ret; /* error */
} }
} }
}
float MovieDecoder_FFMpeg::GetTimestamp() const float MovieDecoder_FFMpeg::GetTimestamp() const
{ {
+9 -1
View File
@@ -40,17 +40,25 @@ static const char *itoa(unsigned n)
static intptr_t xtoi( const char *hex ) static intptr_t xtoi( const char *hex )
{ {
intptr_t ret = 0; intptr_t ret = 0;
while( 1 ) for(;;)
{ {
int val = -1; int val = -1;
if( *hex >= '0' && *hex <= '9' ) if( *hex >= '0' && *hex <= '9' )
{
val = *hex - '0'; val = *hex - '0';
}
else if( *hex >= 'A' && *hex <= 'F' ) else if( *hex >= 'A' && *hex <= 'F' )
{
val = *hex - 'A' + 10; val = *hex - 'A' + 10;
}
else if( *hex >= 'a' && *hex <= 'f' ) else if( *hex >= 'a' && *hex <= 'f' )
{
val = *hex - 'a' + 10; val = *hex - 'a' + 10;
}
else else
{
break; break;
}
hex++; hex++;
ret *= 16; ret *= 16;
+5 -1
View File
@@ -31,17 +31,21 @@ static void safe_print( int fd, ... )
va_list ap; va_list ap;
va_start( ap, fd ); va_start( ap, fd );
while( true ) for(;;)
{ {
const char *p = va_arg( ap, const char * ); const char *p = va_arg( ap, const char * );
if( p == NULL ) if( p == NULL )
{
break; break;
}
size_t len = strlen( p ); size_t len = strlen( p );
while( len ) while( len )
{ {
ssize_t result = write( fd, p, strlen(p) ); ssize_t result = write( fd, p, strlen(p) );
if( result == -1 ) if( result == -1 )
{
_exit( 1 ); _exit( 1 );
}
len -= result; len -= result;
p += result; p += result;
} }
+2 -2
View File
@@ -28,7 +28,7 @@ void NORETURN sm_crash( const char *reason )
if( IsDebuggerPresent() ) if( IsDebuggerPresent() )
{ {
DebugBreak(); DebugBreak();
while(1); /* don't return */ for(;;); /* don't return */
} }
#endif #endif
@@ -39,7 +39,7 @@ void NORETURN sm_crash( const char *reason )
/* This isn't actually reached. We just do this to convince the compiler that the /* This isn't actually reached. We just do this to convince the compiler that the
* function really doesn't return. */ * function really doesn't return. */
while(1); for(;;);
#endif #endif
#if defined(_WINDOWS) #if defined(_WINDOWS)