Don't count demo play in NumTimesPlayed.

Fix BeginnerHelper model load crash; simplify.
This commit is contained in:
Glenn Maynard
2003-12-02 19:11:51 +00:00
parent 5eeb7eeb37
commit 3e8cf666ba
3 changed files with 58 additions and 42 deletions
+35 -18
View File
@@ -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; pl<NUM_PLAYERS; pl++ ) // Load players
{
if( !GAMESTATE->IsHumanPlayer(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; iRow<iCurRow; iRow++)
{
if((m_NoteData[pn].IsThereATapAtRow( iRow )))
{
int iStep = 0;
const int iNumTracks = m_NoteData[pn].GetNumTracks();
for( int k=0; k<iNumTracks; k++ )
if( m_NoteData[pn].GetTapNote(k, iRow ) == TAP_TAP )
iStep |= 1 << k;
Step( pn, iStep );
}
if( !m_NoteData[pn].IsThereATapAtRow( iRow ) )
continue;
int iStep = 0;
const int iNumTracks = m_NoteData[pn].GetNumTracks();
for( int k=0; k<iNumTracks; k++ )
if( m_NoteData[pn].GetTapNote(k, iRow ) == TAP_TAP )
iStep |= 1 << k;
Step( pn, iStep );
}
}
m_iLastRowChecked = iCurRow;
+1
View File
@@ -33,6 +33,7 @@ protected:
void Step( int pn, int CSTEP );
NoteData m_NoteData[NUM_PLAYERS];
bool m_bPlayerEnabled[NUM_PLAYERS];
Model m_mDancer[NUM_PLAYERS];
Model m_mDancePad;
Sprite m_sFlash;
+22 -24
View File
@@ -161,8 +161,11 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
{
const StepsType st = GAMESTATE->GetCurrentStyleDef()->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<Course::Info> 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; i<m_asModifiersQueue[p][iPlaySongIndex].size(); ++i )
@@ -895,31 +901,23 @@ void ScreenGameplay::LoadNextSong()
// Check to see if any players are in beginner mode.
// 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( GAMESTATE->IsHumanPlayer(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 );
}