Don't change m_pCurCharacters, since then we have to put it back,

and that's tricky to do right.
CanUse(): return false if there aren't any characters.
Simplify.
This commit is contained in:
Glenn Maynard
2003-09-03 03:29:25 +00:00
parent 775db4a782
commit 77d4263752
+22 -12
View File
@@ -79,9 +79,16 @@ void BeginnerHelper::AddPlayer( int pn, NoteData *pNotes )
bool BeginnerHelper::CanUse() bool BeginnerHelper::CanUse()
{ {
return ((GAMESTATE->m_CurGame == GAME_DANCE) && if( !DoesFileExist("Characters" SLASH "DancePad-DDR.txt") )
(DoesFileExist("Characters" SLASH "DancePad-DDR.txt")) && return false;
(DoesFileExist("Characters" SLASH "DancePads-DDR.txt")) ); if( !DoesFileExist("Characters" SLASH "DancePads-DDR.txt") )
return false;
if( GAMESTATE->m_CurGame != GAME_DANCE )
return false;
if( GAMESTATE->m_pCharacters.size() == 0 )
return false;
return true;
} }
bool BeginnerHelper::Initialize( int iDancePadType ) bool BeginnerHelper::Initialize( int iDancePadType )
@@ -132,17 +139,21 @@ bool BeginnerHelper::Initialize( int iDancePadType )
if( !GAMESTATE->IsHumanPlayer(pl)) if( !GAMESTATE->IsHumanPlayer(pl))
continue; continue;
if( GAMESTATE->m_pCurNotes[pl]->GetDifficulty() != DIFFICULTY_BEGINNER )
continue;
// if there is no character set, try loading a random one. // if there is no character set, try loading a random one.
if( GAMESTATE->m_pCurCharacters[pl] == NULL ) // XXX: If the character is turned on by us, it should be reverted
{ Character *Character = GAMESTATE->m_pCurCharacters[pl];
GAMESTATE->m_pCurCharacters[pl] = GAMESTATE->GetRandomCharacter(); if( Character == NULL )
} Character = GAMESTATE->GetRandomCharacter();
/* If there aren't any characters, CanUse() should have returned false. */
ASSERT( Character != NULL );
if( GAMESTATE->m_pCurNotes[pl]->GetDifficulty() == DIFFICULTY_BEGINNER && GAMESTATE->m_pCurCharacters[pl] != NULL )
{
// Load textures // Load textures
m_mDancer[pl].SetHorizAlign( align_left ); m_mDancer[pl].SetHorizAlign( align_left );
m_mDancer[pl].LoadMilkshapeAscii( GAMESTATE->m_pCurCharacters[pl]->GetModelPath() ); m_mDancer[pl].LoadMilkshapeAscii( Character->GetModelPath() );
// Load needed animations // Load needed animations
m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-LEFT","Characters" SLASH "BeginnerHelper_step-left.bones.txt" ); m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-LEFT","Characters" SLASH "BeginnerHelper_step-left.bones.txt" );
@@ -151,7 +162,7 @@ bool BeginnerHelper::Initialize( int iDancePadType )
m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-RIGHT","Characters" SLASH "BeginnerHelper_step-right.bones.txt" ); m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-RIGHT","Characters" SLASH "BeginnerHelper_step-right.bones.txt" );
m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-JUMPLR","Characters" SLASH "BeginnerHelper_step-jumplr.bones.txt" ); m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-JUMPLR","Characters" SLASH "BeginnerHelper_step-jumplr.bones.txt" );
/*m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-JUMPUD","Characters\\BeginnerHelper_step-jumpud.bones.txt" );*/ /*m_mDancer[pl].LoadMilkshapeAsciiBones( "Step-JUMPUD","Characters\\BeginnerHelper_step-jumpud.bones.txt" );*/
m_mDancer[pl].LoadMilkshapeAsciiBones( "rest",GAMESTATE->m_pCurCharacters[0]->GetRestAnimationPath() ); m_mDancer[pl].LoadMilkshapeAsciiBones( "rest",Character->GetRestAnimationPath() );
m_mDancer[pl].SetDefaultAnimation( "rest" ); m_mDancer[pl].SetDefaultAnimation( "rest" );
m_mDancer[pl].PlayAnimation( "rest" ); m_mDancer[pl].PlayAnimation( "rest" );
m_mDancer[pl].SetRotationX( PLAYER_ANGLE ); m_mDancer[pl].SetRotationX( PLAYER_ANGLE );
@@ -160,7 +171,6 @@ bool BeginnerHelper::Initialize( int iDancePadType )
m_mDancer[pl].SetZoom( 20 ); m_mDancer[pl].SetZoom( 20 );
m_mDancer[pl].m_bRevertToDefaultAnimation = true; // Stay bouncing after a step has finished animating. m_mDancer[pl].m_bRevertToDefaultAnimation = true; // Stay bouncing after a step has finished animating.
} }
}
return (m_bInitialized = true); return (m_bInitialized = true);
} }