add c'tor overload to make Player without a NoteField

This commit is contained in:
Chris Danford
2005-08-23 21:07:36 +00:00
parent 0c57983d0e
commit 73461405b4
2 changed files with 26 additions and 17 deletions
+22 -15
View File
@@ -90,7 +90,7 @@ float AdjustedWindowHold( HoldWindow hw, bool bIsPlayingBeginner )
#define ADJUSTED_WINDOW_HOLD( hw ) AdjustedWindowHold( hw, IsPlayingBeginner() ) #define ADJUSTED_WINDOW_HOLD( hw ) AdjustedWindowHold( hw, IsPlayingBeginner() )
Player::Player() Player::Player( bool bShowNoteField )
{ {
m_bLoaded = false; m_bLoaded = false;
@@ -117,14 +117,16 @@ Player::Player()
PlayerAI::InitFromDisk(); PlayerAI::InitFromDisk();
m_pNoteField = new NoteField; m_pNoteField = NULL;
if( bShowNoteField )
m_pNoteField = new NoteField;
this->SubscribeToMessage( Message_AutosyncChanged ); this->SubscribeToMessage( Message_AutosyncChanged );
} }
Player::~Player() Player::~Player()
{ {
delete m_pNoteField; SAFE_DELETE( m_pNoteField );
} }
/* Init() does the expensive stuff: load sounds and note skins. Load() just loads a NoteData. */ /* Init() does the expensive stuff: load sounds and note skins. Load() just loads a NoteData. */
@@ -214,7 +216,8 @@ void Player::Init(
ActorUtil::OnCommand( m_Judgment, sType ); ActorUtil::OnCommand( m_Judgment, sType );
m_fNoteFieldHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD; m_fNoteFieldHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD;
m_pNoteField->Init( m_pPlayerState, m_fNoteFieldHeight ); if( m_pNoteField )
m_pNoteField->Init( m_pPlayerState, m_fNoteFieldHeight );
} }
void Player::Load( const NoteData& noteData ) void Player::Load( const NoteData& noteData )
@@ -229,7 +232,7 @@ void Player::Load( const NoteData& noteData )
// TODO: Remove use of PlayerNumber. // TODO: Remove use of PlayerNumber.
PlayerNumber pn = m_pPlayerState->m_PlayerNumber; PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
GAMESTATE->ResetNoteSkinsForPlayer( pn ); GAMESTATE->ResetNoteSkinsForPlayer( m_pPlayerState );
// init steps // init steps
m_NoteData.Init(); m_NoteData.Init();
@@ -291,8 +294,10 @@ void Player::Load( const NoteData& noteData )
float fNoteFieldMiddle = (GRAY_ARROWS_Y_STANDARD+GRAY_ARROWS_Y_REVERSE)/2; float fNoteFieldMiddle = (GRAY_ARROWS_Y_STANDARD+GRAY_ARROWS_Y_REVERSE)/2;
if( m_pNoteField ) if( m_pNoteField )
{
m_pNoteField->SetY( fNoteFieldMiddle ); m_pNoteField->SetY( fNoteFieldMiddle );
m_pNoteField->Load( &m_NoteData, iStartDrawingAtPixels, iStopDrawingAtPixels ); m_pNoteField->Load( &m_NoteData, iStartDrawingAtPixels, iStopDrawingAtPixels );
}
const bool bReverse = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetReversePercentForColumn(0) == 1; const bool bReverse = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetReversePercentForColumn(0) == 1;
bool bPlayerUsingBothSides = GAMESTATE->GetCurrentStyle()->m_StyleType==ONE_PLAYER_TWO_SIDES; bool bPlayerUsingBothSides = GAMESTATE->GetCurrentStyle()->m_StyleType==ONE_PLAYER_TWO_SIDES;
@@ -642,7 +647,8 @@ void Player::ApplyWaitingTransforms()
m_pPlayerState->m_ModsToApply.clear(); m_pPlayerState->m_ModsToApply.clear();
// Cache used NoteSkins now, not on the next update. // Cache used NoteSkins now, not on the next update.
m_pNoteField->RefreshBeatToNoteSkin(); if( m_pNoteField )
m_pNoteField->RefreshBeatToNoteSkin();
} }
void Player::DrawPrimitives() void Player::DrawPrimitives()
@@ -1007,7 +1013,7 @@ void Player::HandleStep( int col, const RageTimer &tm, bool bHeld )
// TODO: Remove use of PlayerNumber // TODO: Remove use of PlayerNumber
PlayerNumber pn = m_pPlayerState->m_PlayerNumber; PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
GAMESTATE->LaunchAttack( OPPOSITE_PLAYER[pn], attack ); GAMESTATE->LaunchAttack( (MultiPlayer)OPPOSITE_PLAYER[pn], attack );
// remove all TapAttacks on this row // remove all TapAttacks on this row
for( int t=0; t<m_NoteData.GetNumTracks(); t++ ) for( int t=0; t<m_NoteData.GetNumTracks(); t++ )
@@ -1693,13 +1699,14 @@ bool Player::IsPlayingBeginner() const
Steps *pSteps = m_pPlayerStageStats->vpPossibleSteps[0]; Steps *pSteps = m_pPlayerStageStats->vpPossibleSteps[0];
return pSteps->GetDifficulty() == DIFFICULTY_BEGINNER; return pSteps->GetDifficulty() == DIFFICULTY_BEGINNER;
} }
else
{ if( m_pPlayerState == NULL )
if( m_pPlayerState->m_PlayerNumber == PLAYER_INVALID ) return false;
return false;
Steps *pSteps = GAMESTATE->m_pCurSteps[ m_pPlayerState->m_PlayerNumber ]; if( m_pPlayerState->m_PlayerNumber == PLAYER_INVALID )
return pSteps && pSteps->GetDifficulty() == DIFFICULTY_BEGINNER; return false;
} Steps *pSteps = GAMESTATE->m_pCurSteps[ m_pPlayerState->m_PlayerNumber ];
return pSteps && pSteps->GetDifficulty() == DIFFICULTY_BEGINNER;
} }
void Player::HandleMessage( const CString& sMessage ) void Player::HandleMessage( const CString& sMessage )
+4 -2
View File
@@ -19,14 +19,14 @@ class ScoreKeeper;
class Inventory; class Inventory;
class RageTimer; class RageTimer;
class NoteField; class NoteField;
struct PlayerStageStats; class PlayerStageStats;
#define SAMPLE_COUNT 32 #define SAMPLE_COUNT 32
class Player: public ActorFrame class Player: public ActorFrame
{ {
public: public:
Player(); Player( bool bShowNoteField = true );
~Player(); ~Player();
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
@@ -58,6 +58,8 @@ public:
NoteData m_NoteData; NoteData m_NoteData;
bool HasNoteField() { return m_pNoteField != NULL; }
protected: protected:
void HandleStep( int col, const RageTimer &tm, bool bHeld ); void HandleStep( int col, const RageTimer &tm, bool bHeld );
void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat ); void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat );