Don't count demo play in NumTimesPlayed.
Fix BeginnerHelper model load crash; simplify.
This commit is contained in:
@@ -63,12 +63,13 @@ static CString GetAnimPath( Animation a )
|
|||||||
|
|
||||||
BeginnerHelper::BeginnerHelper()
|
BeginnerHelper::BeginnerHelper()
|
||||||
{
|
{
|
||||||
LOG->Trace("BeginnerHelper::BeginnerHelper()");
|
|
||||||
m_bFlashEnabled = false;
|
m_bFlashEnabled = false;
|
||||||
m_bShowBackground = true;
|
m_bShowBackground = true;
|
||||||
m_bInitialized = false;
|
m_bInitialized = false;
|
||||||
m_iLastRowChecked = 0;
|
m_iLastRowChecked = 0;
|
||||||
this->AddChild(&m_sBackground);
|
this->AddChild(&m_sBackground);
|
||||||
|
for( int pn=0; pn < NUM_PLAYERS; pn++ )
|
||||||
|
m_bPlayerEnabled[pn] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginnerHelper::~BeginnerHelper()
|
BeginnerHelper::~BeginnerHelper()
|
||||||
@@ -109,9 +110,18 @@ void BeginnerHelper::AddPlayer( int pn, NoteData *pNotes )
|
|||||||
{
|
{
|
||||||
ASSERT( !m_bInitialized );
|
ASSERT( !m_bInitialized );
|
||||||
ASSERT( pNotes != NULL );
|
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_NoteData[pn].CopyAll( pNotes );
|
||||||
|
m_bPlayerEnabled[pn] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BeginnerHelper::CanUse()
|
bool BeginnerHelper::CanUse()
|
||||||
@@ -135,7 +145,17 @@ bool BeginnerHelper::Initialize( int iDancePadType )
|
|||||||
{
|
{
|
||||||
ASSERT( !m_bInitialized );
|
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;
|
return false;
|
||||||
|
|
||||||
// Load the StepCircle, Background, and flash animation
|
// Load the StepCircle, Background, and flash animation
|
||||||
@@ -171,11 +191,8 @@ bool BeginnerHelper::Initialize( int iDancePadType )
|
|||||||
|
|
||||||
for( int pl=0; pl<NUM_PLAYERS; pl++ ) // Load players
|
for( int pl=0; pl<NUM_PLAYERS; pl++ ) // Load players
|
||||||
{
|
{
|
||||||
if( !GAMESTATE->IsHumanPlayer(pl))
|
if( !m_bPlayerEnabled[pl] )
|
||||||
continue;
|
continue; // skip
|
||||||
|
|
||||||
if( GAMESTATE->m_pCurNotes[pl]->GetDifficulty() != DIFFICULTY_BEGINNER )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const Character *Character = GAMESTATE->m_pCurCharacters[pl];
|
const Character *Character = GAMESTATE->m_pCurCharacters[pl];
|
||||||
ASSERT( Character != NULL );
|
ASSERT( Character != NULL );
|
||||||
@@ -281,22 +298,22 @@ void BeginnerHelper::Update( float fDeltaTime )
|
|||||||
|
|
||||||
for(int pn = 0; pn < NUM_PLAYERS; pn++ )
|
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
|
continue; // skip
|
||||||
|
|
||||||
if( (m_NoteData[pn].IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.01f)) ) ) )
|
if( (m_NoteData[pn].IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.01f)) ) ) )
|
||||||
FlashOnce();
|
FlashOnce();
|
||||||
for(int iRow=m_iLastRowChecked; iRow<iCurRow; iRow++)
|
for(int iRow=m_iLastRowChecked; iRow<iCurRow; iRow++)
|
||||||
{
|
{
|
||||||
if((m_NoteData[pn].IsThereATapAtRow( iRow )))
|
if( !m_NoteData[pn].IsThereATapAtRow( iRow ) )
|
||||||
{
|
continue;
|
||||||
int iStep = 0;
|
|
||||||
const int iNumTracks = m_NoteData[pn].GetNumTracks();
|
int iStep = 0;
|
||||||
for( int k=0; k<iNumTracks; k++ )
|
const int iNumTracks = m_NoteData[pn].GetNumTracks();
|
||||||
if( m_NoteData[pn].GetTapNote(k, iRow ) == TAP_TAP )
|
for( int k=0; k<iNumTracks; k++ )
|
||||||
iStep |= 1 << k;
|
if( m_NoteData[pn].GetTapNote(k, iRow ) == TAP_TAP )
|
||||||
Step( pn, iStep );
|
iStep |= 1 << k;
|
||||||
}
|
Step( pn, iStep );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_iLastRowChecked = iCurRow;
|
m_iLastRowChecked = iCurRow;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ protected:
|
|||||||
void Step( int pn, int CSTEP );
|
void Step( int pn, int CSTEP );
|
||||||
|
|
||||||
NoteData m_NoteData[NUM_PLAYERS];
|
NoteData m_NoteData[NUM_PLAYERS];
|
||||||
|
bool m_bPlayerEnabled[NUM_PLAYERS];
|
||||||
Model m_mDancer[NUM_PLAYERS];
|
Model m_mDancer[NUM_PLAYERS];
|
||||||
Model m_mDancePad;
|
Model m_mDancePad;
|
||||||
Sprite m_sFlash;
|
Sprite m_sFlash;
|
||||||
|
|||||||
@@ -161,8 +161,11 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
|
|||||||
{
|
{
|
||||||
const StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
|
const StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
|
||||||
/* Increment the play count. */
|
/* Increment the play count. */
|
||||||
for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc )
|
if( !m_bDemonstration )
|
||||||
++GAMESTATE->m_pCurCourse->m_MemCardDatas[st][mc].iNumTimesPlayed;
|
{
|
||||||
|
for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc )
|
||||||
|
++GAMESTATE->m_pCurCourse->m_MemCardDatas[st][mc].iNumTimesPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
vector<Course::Info> ci;
|
vector<Course::Info> ci;
|
||||||
GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, 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,
|
/* Increment the play count even if the player fails. (It's still popular,
|
||||||
* even if the people playing it aren't good at it.) */
|
* even if the people playing it aren't good at it.) */
|
||||||
for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc )
|
if( !m_bDemonstration )
|
||||||
++GAMESTATE->m_pCurNotes[p]->m_MemCardDatas[mc].iNumTimesPlayed;
|
{
|
||||||
|
for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc )
|
||||||
|
++GAMESTATE->m_pCurNotes[p]->m_MemCardDatas[mc].iNumTimesPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
// Put course options into effect.
|
// Put course options into effect.
|
||||||
for( unsigned i=0; i<m_asModifiersQueue[p][iPlaySongIndex].size(); ++i )
|
for( unsigned i=0; i<m_asModifiersQueue[p][iPlaySongIndex].size(); ++i )
|
||||||
@@ -895,31 +901,23 @@ void ScreenGameplay::LoadNextSong()
|
|||||||
|
|
||||||
// Check to see if any players are in beginner mode.
|
// Check to see if any players are in beginner mode.
|
||||||
// Note: steps can be different if turn modifiers are used.
|
// Note: steps can be different if turn modifiers are used.
|
||||||
if( PREFSMAN->m_bShowBeginnerHelper && BeginnerHelper::CanUse())
|
if( PREFSMAN->m_bShowBeginnerHelper )
|
||||||
{
|
{
|
||||||
bool anybeginners = false;
|
for( p=0; p<NUM_PLAYERS; p++ )
|
||||||
|
if( GAMESTATE->IsHumanPlayer(p) && GAMESTATE->m_pCurNotes[p]->GetDifficulty() == DIFFICULTY_BEGINNER )
|
||||||
|
m_BeginnerHelper.AddPlayer( p, &m_Player[p] );
|
||||||
|
}
|
||||||
|
|
||||||
for( int pb=0; pb<NUM_PLAYERS; pb++ )
|
if( m_BeginnerHelper.Initialize( 2 ) ) // Init for doubles
|
||||||
if( GAMESTATE->IsHumanPlayer(pb) && GAMESTATE->m_pCurNotes[pb]->GetDifficulty() == DIFFICULTY_BEGINNER )
|
{
|
||||||
{
|
m_Background.Unload(); // BeginnerHelper has its own BG control.
|
||||||
anybeginners = true;
|
m_Background.StopAnimating();
|
||||||
m_BeginnerHelper.AddPlayer( pb, &m_Player[pb] );
|
m_BeginnerHelper.SetX( CENTER_X );
|
||||||
}
|
m_BeginnerHelper.SetY( CENTER_Y );
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* BeginnerHelper disabled/failed to load. */
|
||||||
m_Background.LoadFromSong( GAMESTATE->m_pCurSong );
|
m_Background.LoadFromSong( GAMESTATE->m_pCurSong );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user