Fix various compiler and valgrind warnings, including:
authorDataBeaver <tdb@tdb.fi>
Sat, 8 Jan 2011 11:36:42 +0000 (11:36 +0000)
committerDataBeaver <tdb@tdb.fi>
Sat, 8 Jan 2011 11:36:42 +0000 (11:36 +0000)
- compare CString::find result against CString::npos, not -1
- use CString::size_type to hold string indices, not int
- fix other signed vs unsigned comparisons as well
- parentheses in expressions with mixed and/or operators
- braces around ifs containing other ifs and elses
- make sure variables are initialized before using
- #pragma warning is MSVC-specific
- fix an invalid printf format string
- string literals are const

git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg/branches/dev@865 83fadc84-e282-4d84-a09a-c4228d6ae7e5

33 files changed:
src/BGAnimationLayer.cpp
src/BitmapText.cpp
src/CodeDetector.cpp
src/Course.cpp
src/DifficultyIcon.cpp
src/GameManager.cpp
src/GameState.cpp
src/GradeDisplay.cpp
src/GraphDisplay.cpp
src/LinkedOptionsMenu.cpp
src/ModelTypes.cpp
src/NetworkSyncManager.cpp
src/NoteDataUtil.cpp
src/NotesLoaderBMS.cpp
src/NotesLoaderDWI.cpp
src/NotesLoaderKSF.cpp
src/RageBitmapTexture.cpp
src/RageFileDriverCrypt_ITG2.cpp
src/RageInputDevice.h
src/RageSound.cpp
src/RageUtil.cpp
src/ScreenEndlessBreak.cpp
src/ScreenGameplay.cpp
src/ScreenJukebox.cpp
src/ScreenNetSelectMusic.cpp
src/ScreenSelectMode.cpp
src/ScreenSelectMusic.cpp
src/Song.cpp
src/Sprite.cpp
src/UnlockManager.cpp
src/UserPackManager.cpp
src/arch/Lights/LightsDriver_Dynamic.cpp
src/archutils/Unix/X11Helper.cpp

index 5556bc1..5deb905 100755 (executable)
@@ -156,7 +156,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( const CString& sPath )
        Effect effect = EFFECT_CENTER;
 
        for( int i=0; i<NUM_EFFECTS; i++ )
-               if( lcPath.find(EFFECT_STRING[i]) != -1 )
+               if( lcPath.find(EFFECT_STRING[i]) != CString::npos )
                        effect = (Effect)i;
 
        switch( effect )
@@ -338,23 +338,23 @@ void BGAnimationLayer::LoadFromAniLayerFile( const CString& sPath )
        CString sHint = sPath;
        sHint.MakeLower();
 
-       if( sHint.find("cyclecolor") != -1 )
+       if( sHint.find("cyclecolor") != CString::npos )
                for( unsigned i=0; i<m_SubActors.size(); i++ )
                        m_SubActors[i]->SetEffectRainbow( 5 );
 
-       if( sHint.find("cyclealpha") != -1 )
+       if( sHint.find("cyclealpha") != CString::npos )
                for( unsigned i=0; i<m_SubActors.size(); i++ )
                        m_SubActors[i]->SetEffectDiffuseShift( 2, RageColor(1,1,1,1), RageColor(1,1,1,0) );
 
-       if( sHint.find("startonrandomframe") != -1 )
+       if( sHint.find("startonrandomframe") != CString::npos )
                for( unsigned i=0; i<m_SubActors.size(); i++ )
                        m_SubActors[i]->SetState( rand()%m_SubActors[i]->GetNumStates() );
 
-       if( sHint.find("dontanimate") != -1 )
+       if( sHint.find("dontanimate") != CString::npos )
                for( unsigned i=0; i<m_SubActors.size(); i++ )
                        m_SubActors[i]->StopAnimating();
 
-       if( sHint.find("add") != -1 )
+       if( sHint.find("add") != CString::npos )
                for( unsigned i=0; i<m_SubActors.size(); i++ )
                        m_SubActors[i]->SetBlendMode( BLEND_ADD );
 }
index 96bc995..b972689 100755 (executable)
@@ -850,7 +850,7 @@ void ColorBitmapText::SetMaxLines( int iNumLines, int iDirection )
 
                //When we're cutting out text, we need to maintain the last
                //color, so our text at the top doesn't become colorless.
-               RageColor LastColor;
+               RageColor LastColor(0, 0, 0, 0);
 
                for ( unsigned i = 0; i < m_vColors.size(); i++ )
                {
index f8ee365..c957cc8 100755 (executable)
@@ -103,8 +103,8 @@ bool CodeItem::Load( CString sButtonsNames )
        const Game* pGame = GAMESTATE->GetCurrentGame();
        CStringArray asButtonNames;
 
-       bool bHasAPlus = sButtonsNames.find( '+' ) != -1;
-       bool bHasADash = sButtonsNames.find( '-' ) != -1;
+       bool bHasAPlus = sButtonsNames.find( '+' ) != CString::npos;
+       bool bHasADash = sButtonsNames.find( '-' ) != CString::npos;
 
        if( bHasAPlus )
        {
index d48565e..930e2ac 100755 (executable)
@@ -159,7 +159,7 @@ void Course::LoadFromCRSFile( CString sPath, bool bIsCustom )
                {
                        CString str = sParams[1];
                        str.MakeLower();
-                       if( str.find("yes") != -1 )
+                       if( str.find("yes") != CString::npos )
                                m_bRepeat = true;
                }
 
index 5942052..a93c4c6 100755 (executable)
@@ -24,7 +24,7 @@ bool DifficultyIcon::Load( CString sPath )
        Sprite::Load( sPath );
        int iStates = GetNumStates();
        bool bWarn = iStates != NUM_DIFFICULTIES  &&  iStates != NUM_DIFFICULTIES*2;
-       if( sPath.find("_blank") != -1 )
+       if( sPath.find("_blank") != CString::npos )
                bWarn = false;
        if( bWarn )
        {
index 0d64922..98c6c48 100755 (executable)
@@ -69,7 +69,7 @@ const int PNM5_COL_SPACING = 32;
 const int PNM9_COL_SPACING = 32;
 
 struct {
-       char *name;
+       const char *name;
        int NumTracks;
 } const StepsTypes[NUM_STEPS_TYPES] = {
        { "dance-single",       4 },
index bf6f34c..4b2d12a 100755 (executable)
@@ -103,6 +103,9 @@ GameState::GameState() :
        m_iCoins = 0;
        m_timeGameStarted.SetZero();
 
+       m_bDemonstrationOrJukebox = false;
+       m_bTemporaryEventMode = false;
+
        ReloadCharacters();
 
        m_iNumTimesThroughAttract = -1; // initial screen will bump this up to 0
@@ -1686,7 +1689,7 @@ void GameState::StoreRankingName( PlayerNumber pn, CString name )
                                }
 
                                line.MakeUpper();
-                               if( !line.empty() && name.find(line) != -1 )    // name contains a bad word
+                               if( !line.empty() && name.find(line) != CString::npos ) // name contains a bad word
                                {
                                        LOG->Trace( "entered '%s' matches blacklisted item '%s'", name.c_str(), line.c_str() );
                                        name = "";
index abf98de..bfbc959 100755 (executable)
@@ -31,7 +31,7 @@ bool GradeDisplay::Load( RageTextureID ID )
        Sprite::StopAnimating();
 
        bool bWarn = Sprite::GetNumStates() != 8 && Sprite::GetNumStates() != 16;
-       if( ID.filename.find("_blank") != -1 )
+       if( ID.filename.find("_blank") != CString::npos )
                bWarn = false;
        if( bWarn )
        {
@@ -81,7 +81,7 @@ void GradeDisplay::DrawPrimitives()
 
 int GradeDisplay::GetFrameIndex( PlayerNumber pn, Grade g )
 {
-       if( this->m_pTexture->GetID().filename.find("_blank") != -1 )
+       if( this->m_pTexture->GetID().filename.find("_blank") != CString::npos )
                return 0;
 
        // either 8, or 16 states
index 67ffee2..16fc53e 100755 (executable)
@@ -202,6 +202,12 @@ void GraphDisplay::UpdateVerts()
                iRangeFGC[0] = iRangeFEC[1];
                iRangeFGC[1] = m_iPulseStopPoint;
        }
+       else
+       {
+               iRangeFFC[0] = iRangeFFC[1] = 0;
+               iRangeFEC[0] = iRangeFEC[1] = 0;
+               iRangeFGC[0] = iRangeFGC[1] = 0;
+       }
 #undef COMPARE_POINT
 
        for( int i = 0; i < NumSlices; ++i )
index 2b8aa31..7e4b370 100644 (file)
@@ -9,9 +9,11 @@
 #include "ScreenManager.h"
 #include "CodeDetector.h"
 
+#ifdef MSVC
 /* It's going to be a pain to fix these. Disable for now. */
 #pragma warning( disable : 4018 )      // signed/unsigned mismatch
 #pragma warning( disable : 4244 )      // conversion, possible loss of data
+#endif
 
 void LinkedOptionsMenu::Load( LinkedOptionsMenu *prev, LinkedOptionsMenu *next )
 {
@@ -111,12 +113,12 @@ void LinkedOptionsMenu::SetChoices( const CStringArray &asChoices )
        }
 
        // show first page of choices
-       for( unsigned i = 0; i < asChoices.size() && i < ROWS_PER_PAGE; i++ )
+       for( unsigned i = 0; i < asChoices.size() && i < (unsigned)ROWS_PER_PAGE; i++ )
        {
                m_Rows[i]->PlayCommand("TweenOn");
        }
        m_iCurPage = 0;
-       if ( asChoices.size() > ROWS_PER_PAGE )
+       if ( asChoices.size() > (unsigned)ROWS_PER_PAGE )
        {
                m_sprIndicatorDown.PlayCommand("TweenOn");
                m_bIndTweenedOn[1] = true;
@@ -141,7 +143,7 @@ void LinkedOptionsMenu::SetChoices( const CStringArray &asChoices )
 CString LinkedOptionsMenu::GetCurrentSelection()
 {
        ASSERT( m_iCurrentSelection >= 0 );
-       ASSERT( m_iCurrentSelection < m_Rows.size() );
+       ASSERT( (unsigned)m_iCurrentSelection < m_Rows.size() );
        return m_Rows[m_iCurrentSelection]->GetText();
 }
 
@@ -151,7 +153,7 @@ LinkedInputResponseType LinkedOptionsMenu::MoveRow(int iDirection)
        ASSERT( iDirection != 0 );
        iDirection = iDirection / abs(iDirection);
        int iNewSelection = m_iCurrentSelection + iDirection;
-       if (iNewSelection >= m_Rows.size() && iNewSelection > 0) // user chose beyond last option
+       if (iNewSelection > 0 && (unsigned)iNewSelection >= m_Rows.size()) // user chose beyond last option
        {
                if ( GetNextMenu() != this && MENU_WRAPPING )
                {
@@ -182,7 +184,7 @@ LinkedInputResponseType LinkedOptionsMenu::MoveRow(int iDirection)
 void LinkedOptionsMenu::SetChoiceIndex( int iNewSelection )
 {
        ASSERT( iNewSelection >= 0 );
-       ASSERT( iNewSelection < m_Rows.size() );
+       ASSERT( (unsigned)iNewSelection < m_Rows.size() );
        int iSavedSelection = m_iCurrentSelection;
        m_iCurrentSelection = iNewSelection;
        if (iNewSelection / ROWS_PER_PAGE != m_iCurPage) // new page
@@ -197,12 +199,12 @@ void LinkedOptionsMenu::SetChoiceIndex( int iNewSelection )
 void LinkedOptionsMenu::SetPage(int iPage)
 {
        int iSavedPage = m_iCurPage;
-       for( unsigned i = m_iCurPage*ROWS_PER_PAGE; i < (m_iCurPage+1)*ROWS_PER_PAGE && i < m_Rows.size(); i++ )
+       for( unsigned i = m_iCurPage*ROWS_PER_PAGE; i < (unsigned)(m_iCurPage+1)*ROWS_PER_PAGE && i < m_Rows.size(); i++ )
        {
                m_Rows[i]->PlayCommand("TweenOff");
        }
        m_iCurPage = iPage;
-       for( unsigned i = m_iCurPage*ROWS_PER_PAGE; i < (m_iCurPage+1)*ROWS_PER_PAGE && i < m_Rows.size(); i++ )
+       for( unsigned i = m_iCurPage*ROWS_PER_PAGE; i < (unsigned)(m_iCurPage+1)*ROWS_PER_PAGE && i < m_Rows.size(); i++ )
        {
                m_Rows[i]->PlayCommand("TweenOn");
        }
@@ -210,7 +212,7 @@ void LinkedOptionsMenu::SetPage(int iPage)
        {
                m_sprIndicatorUp.PlayCommand("TweenOn");
                m_bIndTweenedOn[0] = true;
-               if ( m_iCurPage+1 == m_Rows.size()/ROWS_PER_PAGE + ( (m_Rows.size()%ROWS_PER_PAGE > 0) ? 1 : 0 ) ) // on last page
+               if ( (unsigned)m_iCurPage+1 == m_Rows.size()/ROWS_PER_PAGE + ( (m_Rows.size()%ROWS_PER_PAGE > 0) ? 1 : 0 ) ) // on last page
                {
                        m_sprIndicatorDown.PlayCommand("TweenOff");
                        m_bIndTweenedOn[1] = false;
index 93d3762..f6ed8ec 100755 (executable)
@@ -29,8 +29,8 @@ void AnimatedTexture::Load( CString sTexOrIniPath )
 {
        ASSERT( vFrames.empty() );      // don't load more than once
 
-       m_bSphereMapped = sTexOrIniPath.find("sphere") != -1;
-       if( sTexOrIniPath.find("add") != -1 )
+       m_bSphereMapped = sTexOrIniPath.find("sphere") != CString::npos;
+       if( sTexOrIniPath.find("add") != CString::npos )
                m_BlendMode = BLEND_ADD;
        else
                m_BlendMode = BLEND_NORMAL;
index fe46d60..821bc09 100755 (executable)
@@ -820,7 +820,7 @@ void PacketFunctions::Write4(uint32_t data)
 
 void PacketFunctions::WriteNT(const CString& data)
 {
-       int index=0;
+       CString::size_type index=0;
        while ((Position<NETMAXBUFFERSIZE)&&(index<data.length()))
                Data[Position++] = (unsigned char)(data.c_str()[index++]);
        Data[Position++] = 0;
index da45971..259c6b0 100755 (executable)
@@ -58,11 +58,11 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData
        out.SetNumTracks( iNumTracks );
 
        // strip comments out of sSMNoteData
-       while( sSMNoteData.find("//") != -1 )
+       while( sSMNoteData.find("//") != CString::npos )
        {
-               int iIndexCommentStart = sSMNoteData.find("//");
-               int iIndexCommentEnd = sSMNoteData.find("\n", iIndexCommentStart);
-               if( iIndexCommentEnd == -1 )    // comment doesn't have an end?
+               CString::size_type iIndexCommentStart = sSMNoteData.find("//");
+               CString::size_type iIndexCommentEnd = sSMNoteData.find("\n", iIndexCommentStart);
+               if( iIndexCommentEnd == CString::npos ) // comment doesn't have an end?
                        sSMNoteData.erase( iIndexCommentStart, 2 );
                else
                        sSMNoteData.erase( iIndexCommentStart, iIndexCommentEnd-iIndexCommentStart );
index 7ff11a2..b7762f5 100755 (executable)
@@ -276,7 +276,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, const NameToData_t &mapNa
                        sData = sData.substr( iOpenBracket+1, iCloseBracket-iOpenBracket-1 );
 
                // if there's a 6 in the description, it's probably part of "6panel" or "6-panel"
-               if( sData.find("6") != -1 )
+               if( sData.find("6") != CString::npos )
                        out.m_StepsType = STEPS_TYPE_DANCE_SOLO;
        }
 
@@ -303,7 +303,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, const NameToData_t &mapNa
                const CString &sNoteData = it->second;
 
                vector<TapNote> vTapNotes;
-               for( int i=0; i+1<sNoteData.length(); i+=2 )
+               for( CString::size_type i=0; i+1<sNoteData.length(); i+=2 )
                {
                        CString sNoteId = sNoteData.substr(i,2);
                        if( sNoteId != "00" )
index 7f2d830..8f56fd7 100755 (executable)
@@ -202,7 +202,7 @@ bool DWILoader::LoadFromDWITokens(
                double fCurrentBeat = 0;
                double fCurrentIncrementer = 1.0/8 * BEATS_PER_MEASURE;
 
-               for( int i=0; i<sStepData.length(); )
+               for( CString::size_type i=0; i<sStepData.length(); )
                {
                        char c = sStepData[i++];
                        switch( c )
@@ -529,8 +529,9 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
                        }
                }
                else
+               {
                        // do nothing.  We don't care about this value name
-                       ;
+               }
        }
 
        return true;
index 3ec181f..17b31ef 100755 (executable)
@@ -101,17 +101,17 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Steps &out, const Song &s
                sFName.MakeLower();
 
                out.SetDescription(sFName);
-               if( sFName.find("crazy")!=-1 )
+               if( sFName.find("crazy")!=CString::npos )
                {
                        out.SetDifficulty(DIFFICULTY_HARD);
                        if(!out.GetMeter()) out.SetMeter(8);
                }
-               else if( sFName.find("hard")!=-1 )
+               else if( sFName.find("hard")!=CString::npos )
                {
                        out.SetDifficulty(DIFFICULTY_MEDIUM);
                        if(!out.GetMeter()) out.SetMeter(5);
                }
-               else if( sFName.find("easy")!=-1 )
+               else if( sFName.find("easy")!=CString::npos )
                {
                        out.SetDifficulty(DIFFICULTY_EASY);
                        if(!out.GetMeter()) out.SetMeter(2);
@@ -125,13 +125,13 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Steps &out, const Song &s
                out.m_StepsType = STEPS_TYPE_PUMP_SINGLE;
 
                /* Check for "halfdouble" before "double". */
-               if( sFName.find("halfdouble") != -1 || sFName.find("h_double") != -1 )
+               if( sFName.find("halfdouble") != CString::npos || sFName.find("h_double") != CString::npos )
                        out.m_StepsType = STEPS_TYPE_PUMP_HALFDOUBLE;
-               else if( sFName.find("double") != -1 )
+               else if( sFName.find("double") != CString::npos )
                        out.m_StepsType = STEPS_TYPE_PUMP_DOUBLE;
-               else if( sFName.find("_1") != -1 )
+               else if( sFName.find("_1") != CString::npos )
                        out.m_StepsType = STEPS_TYPE_PUMP_SINGLE;
-               else if( sFName.find("_2") != -1 )
+               else if( sFName.find("_2") != CString::npos )
                        out.m_StepsType = STEPS_TYPE_PUMP_COUPLE;
        }
 
index d7265d2..411bf0c 100755 (executable)
@@ -96,21 +96,21 @@ void RageBitmapTexture::Create()
        CString HintString = GetID().filename + actualID.AdditionalTextureHints;
        HintString.MakeLower();
 
-       if( HintString.find("32bpp") != -1 )                    actualID.iColorDepth = 32;
-       else if( HintString.find("16bpp") != -1 )               actualID.iColorDepth = 16;
-       if( HintString.find("dither") != -1 )                   actualID.bDither = true;
-       if( HintString.find("stretch") != -1 )                  actualID.bStretch = true;
-       if( HintString.find("mipmaps") != -1 )                  actualID.bMipMaps = true;
-       if( HintString.find("nomipmaps") != -1 )                actualID.bMipMaps = false;      // check for "nomipmaps" after "mipmaps"
+       if( HintString.find("32bpp") != CString::npos )                 actualID.iColorDepth = 32;
+       else if( HintString.find("16bpp") != CString::npos )            actualID.iColorDepth = 16;
+       if( HintString.find("dither") != CString::npos )                actualID.bDither = true;
+       if( HintString.find("stretch") != CString::npos )               actualID.bStretch = true;
+       if( HintString.find("mipmaps") != CString::npos )               actualID.bMipMaps = true;
+       if( HintString.find("nomipmaps") != CString::npos )             actualID.bMipMaps = false;      // check for "nomipmaps" after "mipmaps"
 
        /* If the image is marked grayscale, then use all bits not used for alpha
         * for the intensity.  This way, if an image has no alpha, you get an 8-bit
         * grayscale; if it only has boolean transparency, you get a 7-bit grayscale. */
-       if( HintString.find("grayscale") != -1 )                actualID.iGrayscaleBits = 8-actualID.iAlphaBits;
+       if( HintString.find("grayscale") != CString::npos )             actualID.iGrayscaleBits = 8-actualID.iAlphaBits;
 
        /* This indicates that the only component in the texture is alpha; assume all
         * color is white. */
-       if( HintString.find("alphamap") != -1 )                 actualID.iGrayscaleBits = 0;
+       if( HintString.find("alphamap") != CString::npos )              actualID.iGrayscaleBits = 0;
 
        /* No iGrayscaleBits for images that are already paletted.  We don't support
         * that; and that hint is intended for use on images that are already grayscale,
index 1381df3..de88807 100644 (file)
@@ -210,7 +210,9 @@ int RageFileObjCrypt_ITG2::ReadInternal( void *buffer, size_t bytes )
 
        // seek to the file location and read it into the buffer
        this->SeekInternal( m_iHeaderSize + startpos );
-       this->ReadDirect( crbuf, bufsize );
+       unsigned bytes_read = this->ReadDirect( crbuf, bufsize );
+       if(bytes_read<bufsize)
+               memset(crbuf+bytes_read, 0, bufsize-bytes_read);
 
        // TODO (for Mark at least :P): understand this.
        for (unsigned i = 0; i < bufsize/16; i++)
index 47e8cf0..fcbc7bc 100755 (executable)
@@ -371,7 +371,7 @@ public:
        DeviceInput(): device(DEVICE_NONE), button(-1), level(0), bDown(false), ts(RageZeroTimer) { }
        DeviceInput( InputDevice d, int b, float l=0 ): device(d), button(b), level(l), bDown(l > 0.5f), ts(RageZeroTimer) { }
        DeviceInput( InputDevice d, int b, float l, const RageTimer &t ):
-               device(d), button(b), level(l), ts(t) { }
+               device(d), button(b), level(l), bDown(l > 0.5f), ts(t) { }
 
        bool operator==( const DeviceInput &other ) const
        { 
index 8e84428..972258f 100755 (executable)
@@ -897,7 +897,7 @@ RageSoundParams::StopMode_t RageSound::GetStopMode() const
        if( m_Param.StopMode != RageSoundParams::M_AUTO )
                return m_Param.StopMode;
 
-       if( m_sFilePath.find("loop") != -1 )
+       if( m_sFilePath.find("loop") != CString::npos )
                return RageSoundParams::M_LOOP;
        else
                return RageSoundParams::M_STOP;
index 738a076..546027c 100755 (executable)
@@ -1231,7 +1231,7 @@ bool utf8_to_wchar_ec( const CString &s, unsigned &start, wchar_t &ch )
                        start += i;
                        return false;
                }
-               ch = (ch << 6) | byte & 0x3F;
+               ch = (ch << 6) | (byte & 0x3F);
        }
 
        bool bValid = true;
@@ -1517,7 +1517,7 @@ void Replace_Unicode_Markers( CString &Text )
 
                int numdigits = 0;
                while(p < Text.size() &&
-                       (hex && isxdigit(Text[p])) || (!hex && isdigit(Text[p])))
+                       ((hex && isxdigit(Text[p])) || (!hex && isdigit(Text[p]))))
                {
                   p++;
                   numdigits++;
index dde7535..bc98a9c 100755 (executable)
@@ -63,6 +63,7 @@ void ScreenEndlessBreak::Update(float fDeltaTime)
 {
        m_textTimeRemaining.SetText( SecondsToMMSSMsMs(m_fCountdownSecs) );
        if( !m_bExiting )
+       {
                if(m_fCountdownSecs <= 0)
                {               
                        m_bExiting = true;
@@ -73,6 +74,7 @@ void ScreenEndlessBreak::Update(float fDeltaTime)
                        //m_fCountdownSecs--;
                        m_fCountdownSecs = (m_fCountdownSecs - fDeltaTime);
                Screen::Update( fDeltaTime );
+       }
 }
 
 void ScreenEndlessBreak::DrawPrimitives()
index 72be40e..28a6d10 100755 (executable)
@@ -1103,7 +1103,7 @@ void ScreenGameplay::LoadLights()
                CString sGroup = GAMESTATE->m_pCurSong->m_sGroupName;\r
                sGroup.MakeLower();\r
 \r
-               if( sGroup.find("dance dance revolution") != -1 || sGroup.find("ddr") != -1 )\r
+               if( sGroup.find("dance dance revolution") != CString::npos || sGroup.find("ddr") != CString::npos )\r
                {\r
                        m_bEasterEgg = true;\r
                        pSteps = GAMESTATE->m_pCurSong->GetClosestNotes( STEPS_TYPE_DANCE_SINGLE, DIFFICULTY_MEDIUM );\r
@@ -2217,8 +2217,8 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
 \r
                        /* Mark failure.  This hasn't been done yet if m_bTwoPlayerRecovery is set. */\r
                        if( GAMESTATE->GetPlayerFailType(p) != SongOptions::FAIL_OFF &&\r
-                               (m_pLifeMeter[p] && m_pLifeMeter[p]->IsFailing()) || \r
-                               (m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing(p)) )\r
+                               ((m_pLifeMeter[p] && m_pLifeMeter[p]->IsFailing()) || \r
+                               (m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing(p))) )\r
                                STATSMAN->m_CurStageStats.m_player[p].bFailed = true;\r
 \r
                        if( !STATSMAN->m_CurStageStats.m_player[p].bFailed )\r
index 3043e66..f6f34b6 100755 (executable)
@@ -128,8 +128,8 @@ void ScreenJukebox::SetSong()
                                        {
                                                CString s = a->sModifiers;
                                                s.MakeLower();
-                                               if( s.find("dark") != -1 ||
-                                                       s.find("stealth") != -1 )
+                                               if( s.find("dark") != CString::npos ||
+                                                       s.find("stealth") != CString::npos )
                                                {
                                                        bModsAreOkToShow = false;
                                                        break;
index 3ab3cee..fe91cd4 100755 (executable)
@@ -317,10 +317,12 @@ void ScreenNetSelectMusic::MenuLeft( PlayerNumber pn, const InputEventType type
        bool bLeftAndRightPressed = bLeftPressed && bRightPressed;
 
        if ( type == IET_FIRST_PRESS )
+       {
                if ( bLeftAndRightPressed )
                        m_MusicWheel.ChangeSort( SORT_MODE_MENU );              
                else
                        m_MusicWheel.Move( -1 );
+       }
 }
 
 void ScreenNetSelectMusic::MenuRight( PlayerNumber pn, const InputEventType type )
@@ -330,10 +332,12 @@ void ScreenNetSelectMusic::MenuRight( PlayerNumber pn, const InputEventType type
        bool bLeftAndRightPressed = bLeftPressed && bRightPressed;
 
        if ( type == IET_FIRST_PRESS )
+       {
                if ( bLeftAndRightPressed )
                        m_MusicWheel.ChangeSort( SORT_MODE_MENU );              
                else
                        m_MusicWheel.Move( +1 );
+       }
 }
 
 void ScreenNetSelectMusic::MenuUp( PlayerNumber pn, const InputEventType type )
index 38f3874..e88a785 100755 (executable)
@@ -212,9 +212,9 @@ void ScreenSelectMode::UpdateSelectableChoices()
                                                INCLUDE_DOUBLE_IN_JP == 0 && 
                                                (
                                                        GAMESTATE->GetNumSidesJoined() == SidesJoinedToPlay || 
-                                                       (modename.substr(0, 6) == "DOUBLE" || modename.substr(0, 13) == "ARCADE-DOUBLE" ||
+                                                       ((modename.substr(0, 6) == "DOUBLE" || modename.substr(0, 13) == "ARCADE-DOUBLE" ||
                                                        modename.substr(0, 10) == "HALFDOUBLE" || modename.substr(0, 17) == "ARCADE-HALFDOUBLE") &&
-                                                       GAMESTATE->GetNumSidesJoined() != 2
+                                                       GAMESTATE->GetNumSidesJoined() != 2)
                                                )
                                        )
                                ) 
index 13b8586..146a4d2 100755 (executable)
@@ -1362,7 +1362,7 @@ void UpdateLoadProgress( unsigned long iCurrent, unsigned long iTotal )
        unsigned long iPercent = iCurrent / (iTotal/100);\r
 \r
        // XXX: kind of voodoo\r
-       CString sMessage = ssprintf( "\n\n%s\n%i%%\n%s",\r
+       CString sMessage = ssprintf( "\n\n%s\n%lu%%\n%s",\r
                CUSTOM_SONG_WAIT_TEXT.GetValue().c_str(), \r
                iPercent,\r
                CUSTOM_SONG_CANCEL_TEXT.GetValue().c_str() );\r
@@ -1962,10 +1962,12 @@ void ScreenSelectMusic::AfterMusicChange()
                        /* Please note: displaying banners if CustomSongPreviews\r
                         * is for testing only and is not intended behaviour. */\r
                        if ( PREFSMAN->m_bShowBanners )\r
+                       {\r
                                if( pSong->IsCustomSong() && !PREFSMAN->m_bCustomSongPreviews )\r
                                        g_sBannerPath = THEME->GetPathG("Banner","custom");\r
                                else\r
                                        g_sBannerPath = pSong->GetBannerPath();\r
+                       }\r
 \r
                        if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )\r
                        {\r
index e21240b..ff09619 100755 (executable)
@@ -1364,7 +1364,7 @@ CString GetSongAssetPath( CString sPath, const CString &sSongPath )
 
        /* If there's no path in the file, the file is in the same directory
         * as the song.  (This is the preferred configuration.) */
-       if( sPath.find('/') == -1 )
+       if( sPath.find('/') == CString::npos )
                return sSongPath+sPath;
 
        /* The song contains a path; treat it as relative to the top SM directory. */
index 289a0ab..3169ad4 100755 (executable)
@@ -694,7 +694,7 @@ void Sprite::SetState( int iNewState )
        if( iNewState < 0  ||  iNewState >= (int)m_States.size() )
        {
                // Don't warn about number of states in "_blank".
-               if( !m_pTexture || m_pTexture->GetID().filename.find("_blank") == -1 )
+               if( !m_pTexture || m_pTexture->GetID().filename.find("_blank") == CString::npos )
                {
                        CString sError;
                        if( m_pTexture )
index d7c40d5..4a99c07 100755 (executable)
@@ -277,7 +277,7 @@ bool UnlockEntry::IsValid() const
 
 bool UnlockEntry::IsLocked() const
 {
-       float fScores[NUM_UNLOCK_TYPES];
+       float fScores[NUM_UNLOCK_TYPES] = {};
        UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
 
        for( int i = 0; i < NUM_UNLOCK_TYPES; ++i )
index ad335da..d9134e7 100644 (file)
@@ -60,7 +60,7 @@ bool UserPackManager::Remove( const CString &sPack )
 
 /* Any packs containing these folders will be rejected from addition
  * due to possible conflicts, problems, or stability issues, */
-static const int NUM_BLACKLISTED_FOLDERS = 4;
+static const unsigned NUM_BLACKLISTED_FOLDERS = 4;
 static const char *BLACKLISTED_FOLDERS[] = { "Data", "Program", "Themes/default", "Themes/home" };
 
 bool UserPackManager::IsPackMountable( const CString &sPack, CString &sError )
index 0c9b94e..411fb02 100644 (file)
@@ -28,7 +28,7 @@ bool LightsDriver_Dynamic::LoadInternal()
        if( LIGHTS_API_VERSION_MAJOR != info->mi_api_ver_major ||
                LIGHTS_API_VERSION_MINOR != info->mi_api_ver_minor )
        {
-               LOG->Warn( "LightsDriver \"%s\" uses API version %d%.%d, binary uses %d%.%d. Disabled.",
+               LOG->Warn( "LightsDriver \"%s\" uses API version %d.%d, binary uses %d.%d. Disabled.",
                        info->mi_name, info->mi_api_ver_major, info->mi_api_ver_minor,
                        LIGHTS_API_VERSION_MAJOR, LIGHTS_API_VERSION_MINOR );
                return false;
index 24062e7..d35bdb5 100755 (executable)
@@ -71,7 +71,7 @@ bool X11Helper::CloseMask( long mask )
 
 static bool pApplyMasks()
 {
-       if( X11Helper::Dpy == NULL | !g_bHaveWin )
+       if( X11Helper::Dpy == NULL || !g_bHaveWin )
                return true;
 
        LOG->Trace("X11Helper: Reapplying event masks.");