diff --git a/stepmania/src/BeginnerHelper.cpp b/stepmania/src/BeginnerHelper.cpp index 573bd8ebb2..eca846feb6 100644 --- a/stepmania/src/BeginnerHelper.cpp +++ b/stepmania/src/BeginnerHelper.cpp @@ -63,12 +63,13 @@ static CString GetAnimPath( Animation a ) BeginnerHelper::BeginnerHelper() { - LOG->Trace("BeginnerHelper::BeginnerHelper()"); m_bFlashEnabled = false; m_bShowBackground = true; m_bInitialized = false; m_iLastRowChecked = 0; this->AddChild(&m_sBackground); + for( int pn=0; pn < NUM_PLAYERS; pn++ ) + m_bPlayerEnabled[pn] = false; } BeginnerHelper::~BeginnerHelper() @@ -109,9 +110,18 @@ void BeginnerHelper::AddPlayer( int pn, NoteData *pNotes ) { ASSERT( !m_bInitialized ); ASSERT( pNotes != NULL ); - ASSERT( pn >= 0 && pn < NUM_PLAYERS); + ASSERT( pn >= 0 && pn < NUM_PLAYERS ); + ASSERT( GAMESTATE->IsHumanPlayer(pn) ); + + if( !CanUse() ) + return; + const Character *Character = GAMESTATE->m_pCurCharacters[pn]; + ASSERT( Character != NULL ); + if( !DoesFileExist( Character->GetModelPath() ) ) + return; m_NoteData[pn].CopyAll( pNotes ); + m_bPlayerEnabled[pn] = true; } bool BeginnerHelper::CanUse() @@ -135,7 +145,17 @@ bool BeginnerHelper::Initialize( int iDancePadType ) { ASSERT( !m_bInitialized ); - if (!CanUse()) // if we can't be used, bail now. + /* If no players were successfully added, bail. */ + { + bool bAnyLoaded = false; + for( int pn=0; pn < NUM_PLAYERS; pn++ ) + if( m_bPlayerEnabled[pn] ) + bAnyLoaded = true; + if( !bAnyLoaded ) + return false; + } + + if( !CanUse() ) // if we can't be used, bail now. return false; // Load the StepCircle, Background, and flash animation @@ -171,11 +191,8 @@ bool BeginnerHelper::Initialize( int iDancePadType ) for( int pl=0; plIsHumanPlayer(pl)) - continue; - - if( GAMESTATE->m_pCurNotes[pl]->GetDifficulty() != DIFFICULTY_BEGINNER ) - continue; + if( !m_bPlayerEnabled[pl] ) + continue; // skip const Character *Character = GAMESTATE->m_pCurCharacters[pl]; ASSERT( Character != NULL ); @@ -281,22 +298,22 @@ void BeginnerHelper::Update( float fDeltaTime ) for(int pn = 0; pn < NUM_PLAYERS; pn++ ) { - if( !( GAMESTATE->IsHumanPlayer(pn) && GAMESTATE->m_pCurNotes[pn]->GetDifficulty() == DIFFICULTY_BEGINNER) ) + if( !m_bPlayerEnabled[pn] ) continue; // skip if( (m_NoteData[pn].IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.01f)) ) ) ) FlashOnce(); for(int iRow=m_iLastRowChecked; iRowGetCurrentStyleDef()->m_StepsType; /* Increment the play count. */ - for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc ) - ++GAMESTATE->m_pCurCourse->m_MemCardDatas[st][mc].iNumTimesPlayed; + if( !m_bDemonstration ) + { + for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc ) + ++GAMESTATE->m_pCurCourse->m_MemCardDatas[st][mc].iNumTimesPlayed; + } vector ci; GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci ); @@ -749,8 +752,11 @@ void ScreenGameplay::LoadNextSong() /* Increment the play count even if the player fails. (It's still popular, * even if the people playing it aren't good at it.) */ - for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc ) - ++GAMESTATE->m_pCurNotes[p]->m_MemCardDatas[mc].iNumTimesPlayed; + if( !m_bDemonstration ) + { + for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc ) + ++GAMESTATE->m_pCurNotes[p]->m_MemCardDatas[mc].iNumTimesPlayed; + } // Put course options into effect. for( unsigned i=0; im_bShowBeginnerHelper && BeginnerHelper::CanUse()) + if( PREFSMAN->m_bShowBeginnerHelper ) { - bool anybeginners = false; + for( p=0; pIsHumanPlayer(p) && GAMESTATE->m_pCurNotes[p]->GetDifficulty() == DIFFICULTY_BEGINNER ) + m_BeginnerHelper.AddPlayer( p, &m_Player[p] ); + } - for( int pb=0; pbIsHumanPlayer(pb) && GAMESTATE->m_pCurNotes[pb]->GetDifficulty() == DIFFICULTY_BEGINNER ) - { - anybeginners = true; - m_BeginnerHelper.AddPlayer( pb, &m_Player[pb] ); - } - - if(anybeginners && m_BeginnerHelper.Initialize( 2 )) // Init for doubles - { - m_Background.Unload(); // BeginnerHelper has its own BG control. - m_Background.StopAnimating(); - m_BeginnerHelper.SetX( CENTER_X ); - m_BeginnerHelper.SetY( CENTER_Y ); - } - else - { - m_Background.LoadFromSong( GAMESTATE->m_pCurSong ); - } + if( m_BeginnerHelper.Initialize( 2 ) ) // Init for doubles + { + m_Background.Unload(); // BeginnerHelper has its own BG control. + m_Background.StopAnimating(); + m_BeginnerHelper.SetX( CENTER_X ); + m_BeginnerHelper.SetY( CENTER_Y ); } else { + /* BeginnerHelper disabled/failed to load. */ m_Background.LoadFromSong( GAMESTATE->m_pCurSong ); }