From 9916275a8a30f3792be59a8e7a045e97b02ea70e Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 19:59:10 -0500 Subject: [PATCH 1/6] fix signed-compare warnings The m_iSelection array could probably be made unsigned... IF we were confident we never try to assign it a negative number, of which fact I'm not convinced. --- src/EditMenu.cpp | 2 +- src/GameManager.cpp | 2 +- src/RageSoundMixBuffer.cpp | 2 +- src/SongManager.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EditMenu.cpp b/src/EditMenu.cpp index a9a2f6ec6f..25a799a838 100644 --- a/src/EditMenu.cpp +++ b/src/EditMenu.cpp @@ -398,7 +398,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) StepsType orgSel = StepsType_Invalid; if( !m_StepsTypes.empty() ) // Not first run { - ASSERT( m_StepsTypes.size() > m_iSelection[ROW_STEPS_TYPE] ); + ASSERT( (int) m_StepsTypes.size() > m_iSelection[ROW_STEPS_TYPE] ); StepsType orgSel = m_StepsTypes[m_iSelection[ROW_STEPS_TYPE]]; } diff --git a/src/GameManager.cpp b/src/GameManager.cpp index 9328a5b468..db430656c9 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -2946,7 +2946,7 @@ void GameManager::GetStepsTypesForGame( const Game *pGame, vector& aS // Some Styles use the same StepsType (e.g. single and versus) so check // that we aren't doubling up. bool found = false; - for( int j=0; j < aStepsTypeAddTo.size(); j++ ) + for( unsigned j=0; j < aStepsTypeAddTo.size(); j++ ) if( (int) st == (int) aStepsTypeAddTo[j] ) { found = true; break; } if(found) continue; diff --git a/src/RageSoundMixBuffer.cpp b/src/RageSoundMixBuffer.cpp index 7b5226bb28..01352cdc04 100644 --- a/src/RageSoundMixBuffer.cpp +++ b/src/RageSoundMixBuffer.cpp @@ -92,7 +92,7 @@ void RageSoundMixBuffer::read( float *pBuf ) void RageSoundMixBuffer::read_deinterlace( float **pBufs, int channels ) { - for( int i = 0; i < m_iBufUsed / channels; ++i ) + for( unsigned i = 0; i < m_iBufUsed / channels; ++i ) for( int ch = 0; ch < channels; ++ch ) pBufs[ch][i] = m_pMixbuf[channels * i + ch]; m_iBufUsed = 0; diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 20401e5a9a..6a0eebfe9a 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -1735,7 +1735,7 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi } } - if( vsFiles.size() > MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded ) + if( (int) vsFiles.size() > MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded ) { LOG->Warn("Profile %s has too many edits; some have been skipped.", ProfileSlotToString( slot ).c_str() ); return; @@ -1749,13 +1749,13 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi GetDirListing( sDir+"*", vsGroups, true, false ); // XXX: Same as above, edits may be skipped in error in some cases - for( int i=0; i vsSongs; GetDirListing(sDir+sGroupDir+"*", vsSongs, true, false ); - for( int j=0; j vsEdits; RString sSongDir = sGroupDir+vsSongs[j]+"/"; @@ -1777,7 +1777,7 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi loaderSM.LoadEditFromFile( fn, slot, true, given ); } - if( vsEdits.size() > MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded ) + if( (int) vsEdits.size() > MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded ) { LOG->Warn("Profile %s has too many edits; some have been skipped.", ProfileSlotToString( slot ).c_str() ); return; From 911a0d6471617a30db95cb0666e09cd33d06045b Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 20:24:06 -0500 Subject: [PATCH 2/6] remove unnecessary enum-to-int cast --- src/GameManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GameManager.cpp b/src/GameManager.cpp index db430656c9..a6c9656c4f 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -2947,7 +2947,7 @@ void GameManager::GetStepsTypesForGame( const Game *pGame, vector& aS // that we aren't doubling up. bool found = false; for( unsigned j=0; j < aStepsTypeAddTo.size(); j++ ) - if( (int) st == (int) aStepsTypeAddTo[j] ) { found = true; break; } + if( st == aStepsTypeAddTo[j] ) { found = true; break; } if(found) continue; aStepsTypeAddTo.push_back( st ); From 57a142b76fecc15aa0bdb08a85241910c9055462 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 19:33:50 -0500 Subject: [PATCH 3/6] fix logic/crash in CoinModeNoHome option This option was returning -1 for an index and triggering an assert, and the logic in the other direction was typoed. --- src/ScreenOptionsMasterPrefs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 211b227ed7..d4fb9bf5e6 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -390,12 +390,17 @@ static void CoinModeNoHome( int &sel, bool ToSel, const ConfOption *pConfOption if( ToSel ) { MovePref( sel, ToSel, pConfOption ); - sel--; + // If the mode was Pay, the index is 0; otherwise, set the index + // to 1 to avoid out-of-range crashing. + if (sel == 1) + sel = 0; + else + sel = 1; } else { int tmp = sel + 1; - MovePref( sel, ToSel, pConfOption ); + MovePref( tmp, ToSel, pConfOption ); } } From 3322fa9144ff38bba7f2e2e213a77fb314410950 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 19:45:33 -0500 Subject: [PATCH 4/6] ensure that GetCreditsMessage returns a value The unhandled case: in Free Play mode and players can't join. Can this even happen? --- src/ScreenSystemLayer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ScreenSystemLayer.cpp b/src/ScreenSystemLayer.cpp index 8c600b9a1a..a705cb68df 100644 --- a/src/ScreenSystemLayer.cpp +++ b/src/ScreenSystemLayer.cpp @@ -119,8 +119,11 @@ namespace default: // CoinMode_Free if( GAMESTATE->PlayersCanJoin() ) return CREDITS_FREE_PLAY.GetValue(); + // TODO: What should be displayed if players + // can't join in free mode? } } + return RString(); } }; From 6ac4fcdbd3af67cc87f9ed36c7cdfde4ab101c95 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 20:06:32 -0500 Subject: [PATCH 5/6] remove accidentally shadowing declaration With this in place, the orgSel was always Invalid. --- src/EditMenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EditMenu.cpp b/src/EditMenu.cpp index 25a799a838..2c9e205c49 100644 --- a/src/EditMenu.cpp +++ b/src/EditMenu.cpp @@ -399,7 +399,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) if( !m_StepsTypes.empty() ) // Not first run { ASSERT( (int) m_StepsTypes.size() > m_iSelection[ROW_STEPS_TYPE] ); - StepsType orgSel = m_StepsTypes[m_iSelection[ROW_STEPS_TYPE]]; + orgSel = m_StepsTypes[m_iSelection[ROW_STEPS_TYPE]]; } // The StepsType selection may no longer be valid. Zero it for now. From 312d2b12265aeadadde12bd655bf5c78ded62c08 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 20:19:50 -0500 Subject: [PATCH 6/6] fix type-punning warning This should be a no-op (though I wouldn't be offended if someone checks me on that). I think the code's clearer without casting back and forth anyway. --- src/RageSurfaceUtils_Zoom.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/RageSurfaceUtils_Zoom.cpp b/src/RageSurfaceUtils_Zoom.cpp index c77cec2d29..de9691b243 100644 --- a/src/RageSurfaceUtils_Zoom.cpp +++ b/src/RageSurfaceUtils_Zoom.cpp @@ -95,7 +95,7 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst ) const int width = dst->w; for( int y = 0; y < height; y++ ) { - uint32_t *dp = (uint32_t *) (dst->pixels + dst->pitch*y); + uint8_t *dp = (uint8_t *) (dst->pixels + dst->pitch*y); /* current source pointer and next source pointer (first and second * rows sampled for this row): */ const uint8_t *csp = sp + esy0[y] * src->pitch; @@ -109,7 +109,6 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst ) const uint8_t *c10 = ncsp + esx0[x]*4; const uint8_t *c11 = ncsp + esx1[x]*4; - uint8_t color[4]; for( int c = 0; c < 4; ++c ) { uint32_t x0 = uint32_t(c00[c]) * ex0[x]; @@ -120,12 +119,11 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst ) x1 >>= 24; const uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24; - color[c] = uint8_t(res); + dp[c] = uint8_t(res); } - *dp = *(uint32_t *) color; // Advance destination pointer. - ++dp; + dp += 4; } } }