From 09193d9e4b5031e08db89aabd5bf1d5125effe2d Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 23 Oct 2004 17:43:49 +0000 Subject: [PATCH] cleanup: use references when passing NoteData Have player own a NoteDataWithScoring, not derive from it --- stepmania/src/BeginnerHelper.cpp | 2 +- stepmania/src/NoteData.cpp | 40 +++---- stepmania/src/NoteData.h | 16 +-- stepmania/src/NoteDataUtil.cpp | 14 +-- stepmania/src/NoteField.cpp | 2 +- stepmania/src/NotesLoaderBMS.cpp | 4 +- stepmania/src/NotesLoaderDWI.cpp | 2 +- stepmania/src/NotesLoaderKSF.cpp | 2 +- stepmania/src/NotesWriterDWI.cpp | 2 +- stepmania/src/Player.cpp | 170 ++++++++++++++++++------------ stepmania/src/Player.h | 29 ++++- stepmania/src/RageSound.cpp | 5 +- stepmania/src/ScoreKeeperMAX2.cpp | 4 +- stepmania/src/ScreenEdit.cpp | 30 +++--- stepmania/src/ScreenGameplay.cpp | 42 ++++---- stepmania/src/ScreenHowToPlay.cpp | 8 +- stepmania/src/Song.cpp | 2 +- stepmania/src/Steps.cpp | 29 +++-- stepmania/src/Steps.h | 4 +- stepmania/src/Style.cpp | 4 +- stepmania/src/Style.h | 2 +- stepmania/src/Trail.cpp | 2 +- 22 files changed, 235 insertions(+), 180 deletions(-) diff --git a/stepmania/src/BeginnerHelper.cpp b/stepmania/src/BeginnerHelper.cpp index 2b1ea07a50..4623f2d7e3 100644 --- a/stepmania/src/BeginnerHelper.cpp +++ b/stepmania/src/BeginnerHelper.cpp @@ -105,7 +105,7 @@ void BeginnerHelper::AddPlayer( PlayerNumber pn, NoteData *pSteps ) if(!DoesFileExist(Character->GetModelPath())) return; - m_NoteData[pn].CopyAll(pSteps); + m_NoteData[pn].CopyAll(*pSteps); m_bPlayerEnabled[pn] = true; } diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index cb2844c44d..428620330f 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -65,12 +65,12 @@ void NoteData::ClearAll() /* Copy a range from pFrom to this. (Note that this does *not* overlay; * all data in the range is overwritten.) */ -void NoteData::CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin ) +void NoteData::CopyRange( const NoteData& from, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin ) { - ASSERT( pFrom->GetNumTracks() == GetNumTracks() ); + ASSERT( from.GetNumTracks() == GetNumTracks() ); NoteData From, To; - From.To4s( *pFrom ); + From.To4s( from ); To.To4s( *this ); // copy recorded TapNotes @@ -97,20 +97,20 @@ void NoteData::CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromI this->From4s( To ); } -void NoteData::Config( const NoteData &From ) +void NoteData::Config( const NoteData& from ) { - SetNumTracks( From.GetNumTracks() ); + SetNumTracks( from.GetNumTracks() ); } -void NoteData::CopyAll( const NoteData* pFrom ) +void NoteData::CopyAll( const NoteData& from ) { - Config(*pFrom); + Config(from); ClearAll(); for( int c=0; cm_TapNotes[c]; - m_HoldNotes = pFrom->m_HoldNotes; - m_AttackMap = pFrom->m_AttackMap; + m_TapNotes[c] = from.m_TapNotes[c]; + m_HoldNotes = from.m_HoldNotes; + m_AttackMap = from.m_AttackMap; } bool NoteData::IsRowEmpty( int index ) const @@ -628,27 +628,27 @@ void NoteData::ConvertHoldNotesTo2sAnd3s() } -void NoteData::To2sAnd3s( const NoteData &out ) +void NoteData::To2sAnd3s( const NoteData& from ) { - CopyAll( &out ); + CopyAll( from ); ConvertHoldNotesTo2sAnd3s(); } -void NoteData::From2sAnd3s( const NoteData &out ) +void NoteData::From2sAnd3s( const NoteData& from ) { - CopyAll( &out ); + CopyAll( from ); Convert2sAnd3sToHoldNotes(); } -void NoteData::To4s( const NoteData &out ) +void NoteData::To4s( const NoteData& from ) { - CopyAll( &out ); + CopyAll( from ); ConvertHoldNotesTo4s(); } -void NoteData::From4s( const NoteData &out ) +void NoteData::From4s( const NoteData& from ) { - CopyAll( &out ); + CopyAll( from ); Convert4sToHoldNotes(); } @@ -694,13 +694,13 @@ void NoteData::ConvertHoldNotesTo4s() } // -1 for iOriginalTracksToTakeFrom means no track -void NoteData::LoadTransformed( const NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ) +void NoteData::LoadTransformed( const NoteData& original, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ) { // reset all notes Init(); NoteData Original; - Original.To4s( *pOriginal ); + Original.To4s( original ); Config( Original ); SetNumTracks( iNewNumTracks ); diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index 195d5cc0ca..8982254b21 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -35,7 +35,7 @@ public: /* Set up to hold the data in From; same number of tracks, same * divisor. Doesn't allocate or copy anything. */ - void Config( const NoteData &From ); + void Config( const NoteData& from ); NoteData(); ~NoteData(); @@ -79,8 +79,8 @@ public: void ClearRange( int iNoteIndexBegin, int iNoteIndexEnd ); void ClearAll(); - void CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin = 0 ); - void CopyAll( const NoteData* pFrom ); + void CopyRange( const NoteData& from, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin = 0 ); + void CopyAll( const NoteData& from ); bool IsRowEmpty( int index ) const; bool IsRangeEmpty( int track, int iIndexBegin, int iIndexEnd ) const; @@ -138,18 +138,18 @@ public: int RowNeedsHands( int row ) const; // Transformations - void LoadTransformed( const NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track + void LoadTransformed( const NoteData& original, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track // Convert between HoldNote representation and '2' and '3' markers in TapNotes void Convert2sAnd3sToHoldNotes(); void ConvertHoldNotesTo2sAnd3s(); - void To2sAnd3s( const NoteData &out ); - void From2sAnd3s( const NoteData &out ); + void To2sAnd3s( const NoteData& from ); + void From2sAnd3s( const NoteData& from ); void Convert4sToHoldNotes(); void ConvertHoldNotesTo4s(); - void To4s( const NoteData &out ); - void From4s( const NoteData &out ); + void To4s( const NoteData& from ); + void From4s( const NoteData& from ); void EliminateAllButOneTap( int row ); }; diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index a0af36474d..9f31bd2931 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -141,7 +141,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData, if( 1 == sscanf( p, "%u]", &uKeysoundIndex ) ) // not fatal if this fails due to malformed data { tn.bKeysound = true; - tn.keysoundIndex = (uint16_t)uKeysoundIndex; + tn.keysoundIndex = (uint16_t)uKeysoundIndex; } // skip past the ']' @@ -1723,10 +1723,10 @@ void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, float fStartBeat, fl const int iScaledFirstRowAfterRegion = (int)((fStartBeat + (fEndBeat - fStartBeat) * fScale) * ROWS_PER_BEAT); if( fStartBeat != 0 ) - temp1.CopyRange( &nd, 0, BeatToNoteRowNotRounded(fStartBeat) ); + temp1.CopyRange( nd, 0, BeatToNoteRowNotRounded(fStartBeat) ); if( nd.GetLastRow() > iFirstRowAtEndOfRegion ) - temp1.CopyRange( &nd, iFirstRowAtEndOfRegion, nd.GetLastRow(), iScaledFirstRowAfterRegion); - temp2.CopyRange( &nd, BeatToNoteRowNotRounded(fStartBeat), iFirstRowAtEndOfRegion ); + temp1.CopyRange( nd, iFirstRowAtEndOfRegion, nd.GetLastRow(), iScaledFirstRowAfterRegion); + temp2.CopyRange( nd, BeatToNoteRowNotRounded(fStartBeat), iFirstRowAtEndOfRegion ); nd.ClearAll(); for( int r=0; r<=temp2.GetLastRow(); r++ ) @@ -1744,7 +1744,7 @@ void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, float fStartBeat, fl } } - nd.CopyAll( &temp1 ); + nd.CopyAll( temp1 ); } void NoteDataUtil::ShiftRows( NoteData &nd, float fStartBeat, float fBeatsToShift ) @@ -1762,9 +1762,9 @@ void NoteDataUtil::ShiftRows( NoteData &nd, float fStartBeat, float fBeatsToShif else // delete rows iTakeFromRow += BeatToNoteRow( -fBeatsToShift ); - temp.CopyRange( &nd, iTakeFromRow, nd.GetLastRow() ); + temp.CopyRange( nd, iTakeFromRow, nd.GetLastRow() ); nd.ClearRange( min(iTakeFromRow,iPasteAtRow), nd.GetLastRow() ); - nd.CopyRange( &temp, 0, temp.GetLastRow(), iPasteAtRow ); + nd.CopyRange( temp, 0, temp.GetLastRow(), iPasteAtRow ); } /* diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 9df891312b..01c722f434 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -88,7 +88,7 @@ void NoteField::Load( const NoteData* pNoteData, PlayerNumber pn, int iFirstPixe m_HeldHoldNotes.clear(); m_ActiveHoldNotes.clear(); - this->CopyAll( pNoteData ); + this->CopyAll( *pNoteData ); ASSERT( GetNumTracks() == GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer ); CacheAllUsedNoteSkins(); diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index c3b837eb8f..50fc6b4a7e 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -427,9 +427,9 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Steps &out, const mapSetNumTracks( iNumNewTracks ); - pNoteData2->LoadTransformed( pNoteData, iNumNewTracks, iTransformNewToOld ); + pNoteData2->LoadTransformed( *pNoteData, iNumNewTracks, iTransformNewToOld ); - out.SetNoteData(pNoteData2); + out.SetNoteData(*pNoteData2); delete pNoteData; delete pNoteData2; diff --git a/stepmania/src/NotesLoaderDWI.cpp b/stepmania/src/NotesLoaderDWI.cpp index 8206d2bfa5..29b3a9b386 100644 --- a/stepmania/src/NotesLoaderDWI.cpp +++ b/stepmania/src/NotesLoaderDWI.cpp @@ -297,7 +297,7 @@ bool DWILoader::LoadFromDWITokens( ASSERT( newNoteData.GetNumTracks() > 0 ); - out.SetNoteData(&newNoteData); + out.SetNoteData( newNoteData ); out.TidyUpData(); diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index a6e0e7883d..d76238041a 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -210,7 +210,7 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Steps &out, const Song &s // if( song.m_Timing.m_BPMSegments.size() > 1 ) // RemoveHoles( notedata, song ); - out.SetNoteData(¬edata); + out.SetNoteData( notedata ); out.TidyUpData(); diff --git a/stepmania/src/NotesWriterDWI.cpp b/stepmania/src/NotesWriterDWI.cpp index 2732ea5924..226651f526 100644 --- a/stepmania/src/NotesWriterDWI.cpp +++ b/stepmania/src/NotesWriterDWI.cpp @@ -189,7 +189,7 @@ CString NotesWriterDWI::OptimizeDWIString( CString holds, CString taps ) void NotesWriterDWI::WriteDWINotesField( RageFile &f, const Steps &out, int start ) { NoteData notedata; - out.GetNoteData( ¬edata ); + out.GetNoteData( notedata ); notedata.ConvertHoldNotesTo2sAnd3s(); const int iLastMeasure = int( notedata.GetLastBeat()/BEATS_PER_MEASURE ); diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 7730f5adb9..ef5cea846f 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -97,7 +97,17 @@ PlayerMinus::~PlayerMinus() { } -void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* pLM, CombinedLifeMeter* pCombinedLM, ScoreDisplay* pScoreDisplay, ScoreDisplay* pSecondaryScoreDisplay, Inventory* pInventory, ScoreKeeper* pPrimaryScoreKeeper, ScoreKeeper* pSecondaryScoreKeeper, NoteField* pNoteField ) +void PlayerMinus::Load( + PlayerNumber pn, + const NoteData& noteData, + LifeMeter* pLM, + CombinedLifeMeter* pCombinedLM, + ScoreDisplay* pScoreDisplay, + ScoreDisplay* pSecondaryScoreDisplay, + Inventory* pInventory, + ScoreKeeper* pPrimaryScoreKeeper, + ScoreKeeper* pSecondaryScoreKeeper, + NoteField* pNoteField ) { m_iDCState = AS2D_IDLE; //LOG->Trace( "PlayerMinus::Load()", ); @@ -121,13 +131,11 @@ void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* p const Style* pStyle = GAMESTATE->GetCurrentStyle(); - // init scoring - NoteDataWithScoring::Init(); - - // copy note data - this->CopyAll( pNoteData ); - if( GAMESTATE->m_SongOptions.m_LifeType == SongOptions::LIFE_BATTERY && g_CurStageStats.bFailed[pn] ) // Oni dead - this->ClearAll(); + // init steps + m_NoteData.Init(); + bool bOniDead = GAMESTATE->m_SongOptions.m_LifeType == SongOptions::LIFE_BATTERY && g_CurStageStats.bFailed[pn]; + if( !bOniDead ) + m_NoteData.CopyAll( noteData ); /* The editor reuses Players ... so we really need to make sure everything * is reset and not tweening. Perhaps ActorFrame should recurse to subactors; @@ -145,7 +153,7 @@ void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* p // m_pScore->Init( pn ); /* Apply transforms. */ - NoteDataUtil::TransformNoteData( *this, GAMESTATE->m_PlayerOptions[pn], GAMESTATE->GetCurrentStyle()->m_StepsType ); + NoteDataUtil::TransformNoteData( m_NoteData, GAMESTATE->m_PlayerOptions[pn], GAMESTATE->GetCurrentStyle()->m_StepsType ); switch( GAMESTATE->m_PlayMode ) { @@ -153,7 +161,7 @@ void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* p case PLAY_MODE_BATTLE: { // ugly, ugly, ugly. Works only w/ dance. - NoteDataUtil::TransformNoteData( *this, GAMESTATE->m_PlayerOptions[pn], GAMESTATE->GetCurrentStyle()->m_StepsType ); + NoteDataUtil::TransformNoteData( m_NoteData, GAMESTATE->m_PlayerOptions[pn], GAMESTATE->GetCurrentStyle()->m_StepsType ); // shuffle either p1 or p2 static int count = 0; @@ -161,11 +169,11 @@ void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* p { case 0: case 3: - NoteDataUtil::Turn( *this, STEPS_TYPE_DANCE_SINGLE, NoteDataUtil::left); + NoteDataUtil::Turn( m_NoteData, STEPS_TYPE_DANCE_SINGLE, NoteDataUtil::left); break; case 1: case 2: - NoteDataUtil::Turn( *this, STEPS_TYPE_DANCE_SINGLE, NoteDataUtil::right); + NoteDataUtil::Turn( m_NoteData, STEPS_TYPE_DANCE_SINGLE, NoteDataUtil::right); break; default: ASSERT(0); @@ -188,7 +196,7 @@ void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* p m_pNoteField->SetY( fNoteFieldMidde ); m_fNoteFieldHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD; - m_pNoteField->Load( this, pn, iStartDrawingAtPixels, iStopDrawingAtPixels, m_fNoteFieldHeight ); + m_pNoteField->Load( &m_NoteData, pn, iStartDrawingAtPixels, iStopDrawingAtPixels, m_fNoteFieldHeight ); m_ArrowBackdrop.SetPlayer( pn ); const bool bReverse = GAMESTATE->m_PlayerOptions[pn].GetReversePercentForColumn(0) == 1; @@ -319,10 +327,10 @@ void PlayerMinus::Update( float fDeltaTime ) // // update HoldNotes logic // - for( int i=0; i < GetNumHoldNotes(); i++ ) // for each HoldNote + for( int i=0; i < m_NoteData.GetNumHoldNotes(); i++ ) // for each HoldNote { - const HoldNote &hn = GetHoldNote(i); - HoldNoteScore hns = GetHoldNoteScore(hn); + const HoldNote &hn = m_NoteData.GetHoldNote(i); + HoldNoteScore hns = m_NoteData.GetHoldNoteScore(hn); m_pNoteField->m_HeldHoldNotes[hn] = false; // set hold flag so NoteField can do intelligent drawing m_pNoteField->m_ActiveHoldNotes[hn] = false; // set hold flag so NoteField can do intelligent drawing @@ -337,10 +345,10 @@ void PlayerMinus::Update( float fDeltaTime ) const GameInput GameI = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( StyleI ); // if they got a bad score or haven't stepped on the corresponding tap yet - const TapNoteScore tns = GetTapNoteScore( hn.iTrack, hn.iStartRow ); + const TapNoteScore tns = m_NoteData.GetTapNoteScore( hn.iTrack, hn.iStartRow ); const bool bSteppedOnTapNote = tns != TNS_NONE && tns != TNS_MISS; // did they step on the start of this hold? - float fLife = GetHoldNoteLife(hn); + float fLife = m_NoteData.GetHoldNoteLife(hn); // If the song beat is in the range of this hold: if( hn.iStartRow <= iSongRow && iSongRow <= hn.iEndRow ) @@ -362,7 +370,7 @@ void PlayerMinus::Update( float fDeltaTime ) HoldNoteResult *hnr = m_pNoteField->CreateHoldNoteResult( hn ); hnr->iLastHeldRow = min( iSongRow, hn.iEndRow ); - hnr = this->CreateHoldNoteResult( hn ); + hnr = m_NoteData.CreateHoldNoteResult( hn ); hnr->iLastHeldRow = min( iSongRow, hn.iEndRow ); } @@ -418,8 +426,8 @@ void PlayerMinus::Update( float fDeltaTime ) m_pNoteField->SetHoldNoteLife(hn, fLife); // update the NoteField display m_pNoteField->SetHoldNoteScore(hn, hns); // update the NoteField display - SetHoldNoteLife(hn, fLife); - SetHoldNoteScore(hn, hns); + m_NoteData.SetHoldNoteLife(hn, fLife); + m_NoteData.SetHoldNoteScore(hn, hns); } { @@ -475,15 +483,15 @@ void PlayerMinus::ApplyWaitingTransforms() float fStartBeat, fEndBeat; mod.GetAttackBeats( GAMESTATE->m_pCurSong, m_PlayerNumber, fStartBeat, fEndBeat ); - fEndBeat = min( fEndBeat, GetLastBeat() ); + fEndBeat = min( fEndBeat, m_NoteData.GetLastBeat() ); LOG->Trace( "Applying transform '%s' from %f to %f to '%s'", mod.sModifier.c_str(), fStartBeat, fEndBeat, GAMESTATE->m_pCurSong->GetTranslitMainTitle().c_str() ); if( po.m_sNoteSkin != "" ) GAMESTATE->SetNoteSkinForBeatRange( m_PlayerNumber, po.m_sNoteSkin, fStartBeat, fEndBeat ); - NoteDataUtil::TransformNoteData( *this, po, GAMESTATE->GetCurrentStyle()->m_StepsType, fStartBeat, fEndBeat ); - m_pNoteField->CopyRange( this, BeatToNoteRow(fStartBeat), BeatToNoteRow(fEndBeat), BeatToNoteRow(fStartBeat) ); + NoteDataUtil::TransformNoteData( m_NoteData, po, GAMESTATE->GetCurrentStyle()->m_StepsType, fStartBeat, fEndBeat ); + m_pNoteField->CopyRange( m_NoteData, BeatToNoteRow(fStartBeat), BeatToNoteRow(fEndBeat), BeatToNoteRow(fStartBeat) ); } GAMESTATE->m_ModsToApply[m_PlayerNumber].clear(); } @@ -573,7 +581,7 @@ void PlayerMinus::DrawHoldJudgments() if( GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fBlind > 0 ) return; - for( int c=0; cTrace( "PlayerMinus::HandlePlayerStep()" ); - ASSERT( col >= 0 && col <= GetNumTracks() ); + ASSERT( col >= 0 && col <= m_NoteData.GetNumTracks() ); float fPositionSeconds = GAMESTATE->m_fMusicSeconds; fPositionSeconds -= tm.Ago(); @@ -676,7 +684,7 @@ void PlayerMinus::Step( int col, RageTimer tm ) const float fSecondsFromPerfect = fabsf( fNoteOffset ); - TapNote tn = GetTapNote(col,iIndexOverlappingNote); + TapNote tn = m_NoteData.GetTapNote(col,iIndexOverlappingNote); switch( GAMESTATE->m_PlayerController[m_PlayerNumber] ) { @@ -706,16 +714,16 @@ void PlayerMinus::Step( int col, RageTimer tm ) { m_soundAttackLaunch.Play(); // put attack in effect - Attack attack = this->GetAttackAt( col, iIndexOverlappingNote ); + Attack attack = m_NoteData.GetAttackAt( col, iIndexOverlappingNote ); GAMESTATE->LaunchAttack( OPPOSITE_PLAYER[m_PlayerNumber], attack ); // remove all TapAttacks on this row - for( int t=0; tGetNumTracks(); t++ ) + for( int t=0; tGetTapNote(t, iIndexOverlappingNote); + TapNote tn = m_NoteData.GetTapNote(t, iIndexOverlappingNote); if( tn.type == TapNote::attack ) { - this->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField + m_NoteData.SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField m_pNoteField->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField } } @@ -753,13 +761,13 @@ void PlayerMinus::Step( int col, RageTimer tm ) // there are are no mines to the left of us. for( int t=0; t= get_to_avoid ) @@ -793,16 +801,16 @@ void PlayerMinus::Step( int col, RageTimer tm ) score = TNS_NONE; // don't score this as anything // put attack in effect - Attack attack = this->GetAttackAt( col, iIndexOverlappingNote ); + Attack attack = m_NoteData.GetAttackAt( col, iIndexOverlappingNote ); GAMESTATE->LaunchAttack( OPPOSITE_PLAYER[m_PlayerNumber], attack ); // remove all TapAttacks on this row - for( int t=0; tGetNumTracks(); t++ ) + for( int t=0; tGetTapNote(t, iIndexOverlappingNote); + TapNote tn = m_NoteData.GetTapNote(t, iIndexOverlappingNote); if( tn.type == TapNote::attack ) { - this->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField + m_NoteData.SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField m_pNoteField->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField } } @@ -844,10 +852,10 @@ void PlayerMinus::Step( int col, RageTimer tm ) score, col, fStepSeconds, fCurrentMusicSeconds, fMusicSeconds, fNoteOffset ); // LOG->Trace("Note offset: %f (fSecondsFromPerfect = %f), Score: %i", fNoteOffset, fSecondsFromPerfect, score); - SetTapNoteScore(col, iIndexOverlappingNote, score); + m_NoteData.SetTapNoteScore(col, iIndexOverlappingNote, score); if( score != TNS_NONE ) - SetTapNoteOffset(col, iIndexOverlappingNote, -fNoteOffset); + m_NoteData.SetTapNoteOffset(col, iIndexOverlappingNote, -fNoteOffset); if( GAMESTATE->m_PlayerController[m_PlayerNumber] == PC_HUMAN && score >= TNS_GREAT ) @@ -866,7 +874,7 @@ void PlayerMinus::Step( int col, RageTimer tm ) case TapNote::tap: case TapNote::hold_head: // don't the row if this note is a mine or tap attack - if( IsRowCompletelyJudged(iIndexOverlappingNote) ) + if( m_NoteData.IsRowCompletelyJudged(iIndexOverlappingNote) ) OnRowCompletelyJudged( iIndexOverlappingNote ); } @@ -889,7 +897,9 @@ void PlayerMinus::Step( int col, RageTimer tm ) m_pNoteField->Step( col, score ); } else + { m_pNoteField->Step( col, TNS_NONE ); + } } void PlayerMinus::HandleAutosync(float fNoteOffset) @@ -931,16 +941,16 @@ void PlayerMinus::OnRowCompletelyJudged( int iIndexThatWasSteppedOn ) * columns with the "was pressed recently" columns to see whether or not you hit * all the columns of the jump. -Chris */ // TapNoteScore score = MinTapNoteScore(iIndexThatWasSteppedOn); - TapNoteScore score = LastTapNoteScore(iIndexThatWasSteppedOn); + TapNoteScore score = m_NoteData.LastTapNoteScore( iIndexThatWasSteppedOn ); ASSERT(score != TNS_NONE); ASSERT(score != TNS_HIT_MINE); /* If the whole row was hit with perfects or greats, remove the row * from the NoteField, so it disappears. */ - for( int c=0; cm_CurrentPlayerOptions[m_PlayerNumber].m_fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH]==1) - RandomiseNotes( iNoteRow ); + RandomizeNotes( iNoteRow ); - // check to see if there's at the crossed row + // check to see if there's a note at the crossed row RageTimer now; if( GAMESTATE->m_PlayerController[m_PlayerNumber] != PC_HUMAN ) { - for( int t=0; tGetCurrentStyle()->StyleInputToGameInput( StyleI ); @@ -1078,7 +1090,7 @@ void PlayerMinus::CrossedMineRow( int iNoteRow ) } } -void PlayerMinus::RandomiseNotes( int iNoteRow ) +void PlayerMinus::RandomizeNotes( int iNoteRow ) { // change the row to look ahead from based upon their speed mod /* This is incorrect: if m_fScrollSpeed is 0.5, we'll never change @@ -1086,33 +1098,33 @@ void PlayerMinus::RandomiseNotes( int iNoteRow ) int iNewNoteRow = iNoteRow + ROWS_PER_BEAT*2; iNewNoteRow = int( iNewNoteRow / GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fScrollSpeed ); - int iNumOfTracks = GetNumTracks(); + int iNumOfTracks = m_NoteData.GetNumTracks(); for( int t=0; t+1 < iNumOfTracks; t++ ) { const int iSwapWith = RandomInt( 0, iNumOfTracks-1 ); /* Only swap a tap and an empty. */ - const TapNote t1 = GetTapNote(t, iNewNoteRow); + const TapNote t1 = m_NoteData.GetTapNote(t, iNewNoteRow); if( t1.type != TapNote::tap ) continue; - const TapNote t2 = GetTapNote( iSwapWith, iNewNoteRow ); + const TapNote t2 = m_NoteData.GetTapNote( iSwapWith, iNewNoteRow ); if( t2.type != TapNote::empty ) continue; /* Make sure the destination row isn't in the middle of a hold. */ bool bSkip = false; - for( int i = 0; !bSkip && i < GetNumHoldNotes(); ++i ) + for( int i = 0; !bSkip && i < m_NoteData.GetNumHoldNotes(); ++i ) { - const HoldNote &hn = GetHoldNote(i); + const HoldNote &hn = m_NoteData.GetHoldNote(i); if( hn.iTrack == iSwapWith && hn.RowIsInRange(iNewNoteRow) ) bSkip = true; } if( bSkip ) continue; - SetTapNote( t, iNewNoteRow, t2 ); - SetTapNote( iSwapWith, iNewNoteRow, t1 ); + m_NoteData.SetTapNote( t, iNewNoteRow, t2 ); + m_NoteData.SetTapNote( iSwapWith, iNewNoteRow, t1 ); const TapNote nft1 = m_pNoteField->GetTapNote( t, iNewNoteRow ); const TapNote nft2 = m_pNoteField->GetTapNote( iSwapWith, iNewNoteRow ); @@ -1123,8 +1135,8 @@ void PlayerMinus::RandomiseNotes( int iNoteRow ) void PlayerMinus::HandleTapRowScore( unsigned row ) { - TapNoteScore scoreOfLastTap = LastTapNoteScore(row); - int iNumTapsInRow = this->GetNumTracksWithTapOrHoldHead(row); + TapNoteScore scoreOfLastTap = m_NoteData.LastTapNoteScore(row); + int iNumTapsInRow = m_NoteData.GetNumTracksWithTapOrHoldHead(row); ASSERT(iNumTapsInRow > 0); bool NoCheating = true; @@ -1278,9 +1290,29 @@ void PlayerMinus::FadeToFail() } /* XXX: Why's m_NoteField in a separate class, again? Is that still needed? */ -void Player::Load( PlayerNumber player_no, const NoteData* pNoteData, LifeMeter* pLM, CombinedLifeMeter* pCombinedLM, ScoreDisplay* pScoreDisplay, ScoreDisplay* pSecondaryScoreDisplay, Inventory* pInventory, ScoreKeeper* pPrimaryScoreKeeper, ScoreKeeper* pSecondaryScoreKeeper ) +/* It was used to have an invisible computer player in PLAY_MODE_BATTLE. -Chris */ +void Player::Load( + PlayerNumber player_no, + const NoteData& noteData, + LifeMeter* pLM, + CombinedLifeMeter* pCombinedLM, + ScoreDisplay* pScoreDisplay, + ScoreDisplay* pSecondaryScoreDisplay, + Inventory* pInventory, + ScoreKeeper* pPrimaryScoreKeeper, + ScoreKeeper* pSecondaryScoreKeeper ) { - PlayerMinus::Load( player_no, pNoteData, pLM, pCombinedLM, pScoreDisplay, pSecondaryScoreDisplay, pInventory, pPrimaryScoreKeeper, pSecondaryScoreKeeper, &m_NoteField ); + PlayerMinus::Load( + player_no, + noteData, + pLM, + pCombinedLM, + pScoreDisplay, + pSecondaryScoreDisplay, + pInventory, + pPrimaryScoreKeeper, + pSecondaryScoreKeeper, + &m_NoteField ); } /* diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index f5dbbb7253..1cf1f0c254 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -29,7 +29,7 @@ class Inventory; #define SAMPLE_COUNT 16 -class PlayerMinus : public NoteDataWithScoring, public ActorFrame +class PlayerMinus : public ActorFrame { public: PlayerMinus(); @@ -38,11 +38,21 @@ public: virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); - void Load( PlayerNumber player_no, const NoteData* pNoteData, LifeMeter* pLM, CombinedLifeMeter* pCombinedLM, ScoreDisplay* pScoreDisplay, ScoreDisplay* pSecondaryScoreDisplay, Inventory* pInventory, ScoreKeeper* pPrimaryScoreKeeper, ScoreKeeper* pSecondaryScoreKeeper, NoteField* pNoteField ); + void Load( + PlayerNumber player_no, + const NoteData& noteData, + LifeMeter* pLM, + CombinedLifeMeter* pCombinedLM, + ScoreDisplay* pScoreDisplay, + ScoreDisplay* pSecondaryScoreDisplay, + Inventory* pInventory, + ScoreKeeper* pPrimaryScoreKeeper, + ScoreKeeper* pSecondaryScoreKeeper, + NoteField* pNoteField ); void CrossedRow( int iNoteRow ); void CrossedMineRow( int iNoteRow ); void Step( int col, RageTimer tm ); - void RandomiseNotes( int iNoteRow ); + void RandomizeNotes( int iNoteRow ); void FadeToFail(); int GetDancingCharacterState() const { return m_iDCState; }; void SetCharacterState(int iDCState) { m_iDCState = iDCState; }; @@ -50,6 +60,8 @@ public: static float GetMaxStepDistanceSeconds(); + NoteDataWithScoring m_NoteData; + protected: void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat ); void OnRowCompletelyJudged( int iStepIndex ); @@ -100,7 +112,16 @@ protected: class Player : public PlayerMinus { public: - void Load( PlayerNumber player_no, const NoteData* pNoteData, LifeMeter* pLM, CombinedLifeMeter* pCombinedLM, ScoreDisplay* pScoreDisplay, ScoreDisplay* pSecondaryScoreDisplay, Inventory* pInventory, ScoreKeeper* pPrimaryScoreKeeper, ScoreKeeper* pSecondaryScoreKeeper ); + void Load( + PlayerNumber player_no, + const NoteData& noteData, + LifeMeter* pLM, + CombinedLifeMeter* pCombinedLM, + ScoreDisplay* pScoreDisplay, + ScoreDisplay* pSecondaryScoreDisplay, + Inventory* pInventory, + ScoreKeeper* pPrimaryScoreKeeper, + ScoreKeeper* pSecondaryScoreKeeper ); protected: NoteField m_NoteField; diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index f9597e9460..366e037cbb 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -120,7 +120,10 @@ RageSound &RageSound::operator=( const RageSound &cpy ) databuf.reserve(internal_buffer_size); delete Sample; - Sample = cpy.Sample->Copy(); + if( cpy.Sample ) + Sample = cpy.Sample->Copy(); + else + Sample = NULL; m_sFilePath = cpy.m_sFilePath; diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index 140f7c4140..249965630c 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -30,14 +30,14 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( const vector& apSongs, const vectorGetNoteData( &ndTemp ); + pSteps->GetNoteData( ndTemp ); /* We might have been given lots of songs; don't keep them in memory uncompressed. */ pSteps->Compress(); const Style* pStyle = GAMESTATE->GetCurrentStyle(); NoteData nd; - pStyle->GetTransformedNoteDataForStyle( pn_, &ndTemp, &nd ); + pStyle->GetTransformedNoteDataForStyle( pn_, ndTemp, nd ); /* Compute RadarValues before applying any user-selected mods. Apply * Course mods and count them in the "pre" RadarValues because they're diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 782ab58735..d8f3772ddd 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -273,7 +273,7 @@ ScreenEdit::ScreenEdit( CString sName ) : Screen( sName ) m_pAttacksFromCourse = NULL; NoteData noteData; - m_pSteps->GetNoteData( ¬eData ); + m_pSteps->GetNoteData( noteData ); m_EditMode = MODE_EDITING; @@ -324,7 +324,7 @@ ScreenEdit::ScreenEdit( CString sName ) : Screen( sName ) /* XXX: Do we actually have to send real note data here, and to m_NoteFieldRecord? * (We load again on play/record.) */ - m_Player.Load( PLAYER_1, ¬eData, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); + m_Player.Load( PLAYER_1, noteData, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); GAMESTATE->m_PlayerController[PLAYER_1] = PC_HUMAN; m_Player.SetX( PLAYER_X ); /* Why was this here? Nothing ever sets Player Y values; this was causing @@ -399,7 +399,7 @@ void ScreenEdit::PlayTicks() int iTickRow = -1; for( int r=iRowLastCrossed+1; r<=iSongRow; r++ ) // for each index we crossed since the last update - if( m_Player.IsThereATapOrHoldHeadAtRow( r ) ) + if( m_Player.m_NoteData.IsThereATapOrHoldHeadAtRow( r ) ) iTickRow = r; iRowLastCrossed = iSongRow; @@ -938,7 +938,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ // save current steps Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; ASSERT( pSteps ); - pSteps->SetNoteData( &m_NoteFieldEdit ); + pSteps->SetNoteData( m_NoteFieldEdit ); // Get all Steps of this StepsType StepsType st = pSteps->m_StepsType; @@ -975,7 +975,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ pSteps = *it; GAMESTATE->m_pCurSteps[PLAYER_1] = m_pSteps = pSteps; - pSteps->GetNoteData( &m_NoteFieldEdit ); + pSteps->GetNoteData( m_NoteFieldEdit ); SCREENMAN->SystemMessage( ssprintf( "Switched to %s %s '%s'", GAMEMAN->StepsTypeToString( pSteps->m_StepsType ).c_str(), @@ -1323,7 +1323,7 @@ void ScreenEdit::TransitionFromRecordToEdit() // delete old TapNotes in the range m_NoteFieldEdit.ClearRange( iNoteIndexBegin, iNoteIndexEnd ); - m_NoteFieldEdit.CopyRange( &m_NoteFieldRecord, iNoteIndexBegin, iNoteIndexEnd, iNoteIndexBegin ); + m_NoteFieldEdit.CopyRange( m_NoteFieldRecord, iNoteIndexBegin, iNoteIndexEnd, iNoteIndexBegin ); } /* Helper for SM_DoReloadFromDisk */ @@ -1451,7 +1451,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) SCREENMAN->SystemMessage( sMessage ); m_pSteps = GAMESTATE->m_pCurSteps[PLAYER_1] = pSteps; - m_pSteps->GetNoteData( &m_NoteFieldEdit ); + m_pSteps->GetNoteData( m_NoteFieldEdit ); break; } @@ -1590,7 +1590,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, int* iAnswers ) Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; ASSERT( pSteps ); - pSteps->SetNoteData( &m_NoteFieldEdit ); + pSteps->SetNoteData( m_NoteFieldEdit ); GAMESTATE->m_pCurSong->Save(); // we shouldn't say we're saving a DWI if we're on any game besides @@ -1741,7 +1741,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) int iFirstRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker ); int iLastRow = BeatToNoteRow( m_NoteFieldEdit.m_fEndMarker ); m_Clipboard.ClearAll(); - m_Clipboard.CopyRange( &m_NoteFieldEdit, iFirstRow, iLastRow ); + m_Clipboard.CopyRange( m_NoteFieldEdit, iFirstRow, iLastRow ); } break; case paste_at_current_beat: @@ -1749,7 +1749,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) int iSrcFirstRow = 0; int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() ); int iDestFirstRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); - m_NoteFieldEdit.CopyRange( &m_Clipboard, iSrcFirstRow, iSrcLastRow, iDestFirstRow ); + m_NoteFieldEdit.CopyRange( m_Clipboard, iSrcFirstRow, iSrcLastRow, iDestFirstRow ); } break; case paste_at_begin_marker: @@ -1758,7 +1758,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) int iSrcFirstRow = 0; int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() ); int iDestFirstRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker ); - m_NoteFieldEdit.CopyRange( &m_Clipboard, iSrcFirstRow, iSrcLastRow, iDestFirstRow ); + m_NoteFieldEdit.CopyRange( m_Clipboard, iSrcFirstRow, iSrcLastRow, iDestFirstRow ); } break; case clear: @@ -1910,11 +1910,11 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) (sIter[i]->GetDifficulty() == GAMESTATE->m_pCurSteps[PLAYER_1]->GetDifficulty()) ) continue; - sIter[i]->GetNoteData( &ndTemp ); + sIter[i]->GetNoteData( ndTemp ); ndTemp.ConvertHoldNotesTo2sAnd3s(); NoteDataUtil::ScaleRegion( ndTemp, fScale, m_NoteFieldEdit.m_fBeginMarker, m_NoteFieldEdit.m_fEndMarker ); ndTemp.Convert2sAnd3sToHoldNotes(); - sIter[i]->SetNoteData( &ndTemp ); + sIter[i]->SetNoteData( ndTemp ); } m_NoteFieldEdit.m_fEndMarker = fNewClipboardEndBeat; @@ -1944,7 +1944,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) SetupCourseAttacks(); - m_Player.Load( PLAYER_1, &m_NoteFieldEdit, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); + m_Player.Load( PLAYER_1, m_NoteFieldEdit, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); GAMESTATE->m_PlayerController[PLAYER_1] = PREFSMAN->m_bAutoPlay?PC_AUTOPLAY:PC_HUMAN; m_rectRecordBack.StopTweening(); @@ -1959,7 +1959,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) * and recalc it. */ Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; ASSERT( pSteps ); - pSteps->SetNoteData( &m_NoteFieldEdit ); + pSteps->SetNoteData( m_NoteFieldEdit ); m_pSong->ReCalculateRadarValuesAndLastBeat(); m_Background.Unload(); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 3db80eeb7d..246de1a424 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -810,13 +810,13 @@ void ScreenGameplay::SetupSong( PlayerNumber p, int iSongIndex ) * once in Player::Load, then again in Player::ApplyActiveAttacks. This * is very bad for transforms like AddMines. */ - NoteData pOriginalNoteData; - GAMESTATE->m_pCurSteps[p]->GetNoteData( &pOriginalNoteData ); + NoteData originalNoteData; + GAMESTATE->m_pCurSteps[p]->GetNoteData( originalNoteData ); const Style* pStyle = GAMESTATE->GetCurrentStyle(); - NoteData pNewNoteData; - pStyle->GetTransformedNoteDataForStyle( p, &pOriginalNoteData, &pNewNoteData ); - m_Player[p].Load( p, &pNewNoteData, m_pLifeMeter[p], m_pCombinedLifeMeter, m_pPrimaryScoreDisplay[p], m_pSecondaryScoreDisplay[p], m_pInventory[p], m_pPrimaryScoreKeeper[p], m_pSecondaryScoreKeeper[p] ); + NoteData newNoteData; + pStyle->GetTransformedNoteDataForStyle( p, originalNoteData, newNoteData ); + m_Player[p].Load( p, newNoteData, m_pLifeMeter[p], m_pCombinedLifeMeter, m_pPrimaryScoreDisplay[p], m_pSecondaryScoreDisplay[p], m_pInventory[p], m_pPrimaryScoreKeeper[p], m_pSecondaryScoreKeeper[p] ); // Put course options into effect. Do this after Player::Load so @@ -939,9 +939,9 @@ void ScreenGameplay::LoadNextSong() /* The actual note data for scoring is the base class of Player. This includes * transforms, like Wide. Otherwise, the scoring will operate on the wrong data. */ - m_pPrimaryScoreKeeper[p]->OnNextSong( GAMESTATE->GetCourseSongIndex(), GAMESTATE->m_pCurSteps[p], &m_Player[p] ); + m_pPrimaryScoreKeeper[p]->OnNextSong( GAMESTATE->GetCourseSongIndex(), GAMESTATE->m_pCurSteps[p], &m_Player[p].m_NoteData ); if( m_pSecondaryScoreKeeper[p] ) - m_pSecondaryScoreKeeper[p]->OnNextSong( GAMESTATE->GetCourseSongIndex(), GAMESTATE->m_pCurSteps[p], &m_Player[p] ); + m_pSecondaryScoreKeeper[p]->OnNextSong( GAMESTATE->GetCourseSongIndex(), GAMESTATE->m_pCurSteps[p], &m_Player[p].m_NoteData ); if( m_bDemonstration ) { @@ -1027,7 +1027,7 @@ void ScreenGameplay::LoadNextSong() FOREACH_HumanPlayer( p ) { if( GAMESTATE->m_pCurSteps[p]->GetDifficulty() == DIFFICULTY_BEGINNER ) - m_BeginnerHelper.AddPlayer( p, &m_Player[p] ); + m_BeginnerHelper.AddPlayer( p, &m_Player[p].m_NoteData ); } } @@ -1068,8 +1068,8 @@ void ScreenGameplay::LoadNextSong() // (Re)Calculate the song position meter m_fSongPosMeterOffset = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fFirstBeat ); - m_fSongPosMeterEnd = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( - GAMESTATE->m_pCurSong->m_fLastBeat ); + m_fSongPosMeterEnd = ( GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( + GAMESTATE->m_pCurSong->m_fLastBeat ) - m_fSongPosMeterOffset ); // // Load cabinet lights data @@ -1081,7 +1081,7 @@ void ScreenGameplay::LoadNextSong() Steps *pSteps = GAMESTATE->m_pCurSong->GetClosestNotes( STEPS_TYPE_LIGHTS_CABINET, StringToDifficulty(PREFSMAN->m_sLightsStepsDifficulty) ); if( pSteps != NULL ) { - pSteps->GetNoteData( &m_CabinetLightsNoteData ); + pSteps->GetNoteData( m_CabinetLightsNoteData ); } else { @@ -1089,7 +1089,7 @@ void ScreenGameplay::LoadNextSong() if( pSteps ) { NoteData TapNoteData; - pSteps->GetNoteData( &TapNoteData ); + pSteps->GetNoteData( TapNoteData ); NoteDataUtil::LoadTransformedLights( TapNoteData, m_CabinetLightsNoteData, GameManager::StepsTypeToNumTracks(STEPS_TYPE_LIGHTS_CABINET) ); } } @@ -1155,7 +1155,7 @@ void ScreenGameplay::PlayTicks() int iTickRow = -1; for( int r=iRowLastCrossed+1; r<=iSongRow; r++ ) // for each index we crossed since the last update - if( m_Player[GAMESTATE->m_MasterPlayerNumber].IsThereATapOrHoldHeadAtRow( r ) ) + if( m_Player[GAMESTATE->m_MasterPlayerNumber].m_NoteData.IsThereATapOrHoldHeadAtRow( r ) ) iTickRow = r; iRowLastCrossed = iSongRow; @@ -1351,7 +1351,7 @@ void ScreenGameplay::Update( float fDeltaTime ) // kill them! SOUND->PlayOnceFromDir( THEME->GetPathS(m_sName,"oni die") ); ShowOniGameOver(pn); - m_Player[pn].Init(); // remove all notes and scoring + m_Player[pn].m_NoteData.Init(); // remove all notes and scoring m_Player[pn].FadeToFail(); // tell the NoteField to fade to white } } @@ -1432,7 +1432,7 @@ void ScreenGameplay::Update( float fDeltaTime ) { SOUND->PlayOnceFromDir( THEME->GetPathS(m_sName,"oni die") ); ShowOniGameOver( p ); - m_Player[p].Init(); // remove all notes and scoring + m_Player[p].m_NoteData.Init(); // remove all notes and scoring m_Player[p].FadeToFail(); // tell the NoteField to fade to white } } @@ -1522,9 +1522,9 @@ void ScreenGameplay::Update( float fDeltaTime ) } FOREACH_EnabledPlayer( pn ) { - for( int t=0; tm_pCurSong->m_fMusicLengthSeconds, v ); + NoteDataUtil::GetRadarValues( m_Player[p].m_NoteData, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); g_CurStageStats.radarPossible[p] += v; - m_Player[p].GetActualRadarValues( p, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); + m_Player[p].m_NoteData.GetActualRadarValues( p, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); g_CurStageStats.radarActual[p] += v; } diff --git a/stepmania/src/ScreenHowToPlay.cpp b/stepmania/src/ScreenHowToPlay.cpp index e780bcf227..ada29c1810 100644 --- a/stepmania/src/ScreenHowToPlay.cpp +++ b/stepmania/src/ScreenHowToPlay.cpp @@ -144,16 +144,16 @@ ScreenHowToPlay::ScreenHowToPlay( CString sName ) : ScreenAttract( sName ) Steps *pSteps = m_Song.GetStepsByDescription( pStyle->m_StepsType, "" ); ASSERT_M( pSteps != NULL, ssprintf("%i", pStyle->m_StepsType) ); - NoteData TempNoteData; - pSteps->GetNoteData( &TempNoteData ); - pStyle->GetTransformedNoteDataForStyle( PLAYER_1, &TempNoteData, &m_NoteData ); + NoteData tempNoteData; + pSteps->GetNoteData( tempNoteData ); + pStyle->GetTransformedNoteDataForStyle( PLAYER_1, tempNoteData, m_NoteData ); GAMESTATE->m_pCurSong = &m_Song; GAMESTATE->m_bPastHereWeGo = true; GAMESTATE->m_PlayerController[PLAYER_1] = PC_AUTOPLAY; m_pPlayer = new Player; - m_pPlayer->Load( PLAYER_1, &m_NoteData, m_pLifeMeterBar, NULL, NULL, NULL, NULL, NULL, NULL ); + m_pPlayer->Load( PLAYER_1, m_NoteData, m_pLifeMeterBar, NULL, NULL, NULL, NULL, NULL, NULL ); m_pPlayer->SetX( PLAYERX ); this->AddChild( m_pPlayer ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 4a7a62e619..90a9685862 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -791,7 +791,7 @@ void Song::ReCalculateRadarValuesAndLastBeat() // calculate radar values // NoteData tempNoteData; - pSteps->GetNoteData( &tempNoteData ); + pSteps->GetNoteData( tempNoteData ); RadarValues v; NoteDataUtil::GetRadarValues( tempNoteData, m_fMusicLengthSeconds, v ); diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 330e161a8b..f5a0c4c630 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -52,14 +52,14 @@ Steps::~Steps() delete notes_comp; } -void Steps::SetNoteData( const NoteData* pNewNoteData ) +void Steps::SetNoteData( const NoteData& noteDataNew ) { - ASSERT( pNewNoteData->GetNumTracks() == GameManager::StepsTypeToNumTracks(m_StepsType) ); + ASSERT( noteDataNew.GetNumTracks() == GameManager::StepsTypeToNumTracks(m_StepsType) ); DeAutogen(); delete notes; - notes = new NoteData(*pNewNoteData); + notes = new NoteData( noteDataNew ); delete notes_comp; notes_comp = new CompressedNoteData; @@ -67,19 +67,18 @@ void Steps::SetNoteData( const NoteData* pNewNoteData ) m_uHash = GetHashForString( notes_comp->notes ); } -void Steps::GetNoteData( NoteData* pNoteDataOut ) const +void Steps::GetNoteData( NoteData& noteDataOut ) const { ASSERT(this); - ASSERT(pNoteDataOut); Decompress(); if( notes != NULL ) - *pNoteDataOut = *notes; + noteDataOut = *notes; else { - pNoteDataOut->ClearAll(); - pNoteDataOut->SetNumTracks( GameManager::StepsTypeToNumTracks(m_StepsType) ); + noteDataOut.ClearAll(); + noteDataOut.SetNumTracks( GameManager::StepsTypeToNumTracks(m_StepsType) ); } } @@ -170,8 +169,8 @@ void Steps::Decompress() const if(parent) { // get autogen notes - NoteData pdata; - parent->GetNoteData(&pdata); + NoteData notedata; + parent->GetNoteData( notedata ); notes = new NoteData; @@ -179,9 +178,9 @@ void Steps::Decompress() const if( this->m_StepsType == STEPS_TYPE_LIGHTS_CABINET ) { - NoteDataUtil::LoadTransformedLights( pdata, *notes, iNewTracks ); + NoteDataUtil::LoadTransformedLights( notedata, *notes, iNewTracks ); } else { - NoteDataUtil::LoadTransformedSlidingWindow( pdata, *notes, iNewTracks ); + NoteDataUtil::LoadTransformedSlidingWindow( notedata, *notes, iNewTracks ); NoteDataUtil::FixImpossibleRows( *notes, m_StepsType ); } @@ -280,9 +279,9 @@ void Steps::CopyFrom( Steps* pSource, StepsType ntTo ) // pSource does not have { m_StepsType = ntTo; NoteData noteData; - pSource->GetNoteData( ¬eData ); + pSource->GetNoteData( noteData ); noteData.SetNumTracks( GameManager::StepsTypeToNumTracks(ntTo) ); - this->SetNoteData( ¬eData ); + this->SetNoteData( noteData ); this->SetDescription( "Copied from "+pSource->GetDescription() ); this->SetDifficulty( pSource->GetDifficulty() ); this->SetMeter( pSource->GetMeter() ); @@ -294,7 +293,7 @@ void Steps::CreateBlank( StepsType ntTo ) m_StepsType = ntTo; NoteData noteData; noteData.SetNumTracks( GameManager::StepsTypeToNumTracks(ntTo) ); - this->SetNoteData( ¬eData ); + this->SetNoteData( noteData ); } diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index ee64df13de..07afb05812 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -47,8 +47,8 @@ public: StepsType m_StepsType; - void GetNoteData( NoteData* pNoteDataOut ) const; - void SetNoteData( const NoteData* pNewNoteData ); + void GetNoteData( NoteData& noteDataOut ) const; + void SetNoteData( const NoteData& noteDataNew ); void SetSMNoteData( const CString ¬es_comp, const CString &attacks_comp ); void GetSMNoteData( CString ¬es_comp_out, CString &attacks_comp_out ) const; diff --git a/stepmania/src/Style.cpp b/stepmania/src/Style.cpp index df16298de7..4ac351d4bb 100644 --- a/stepmania/src/Style.cpp +++ b/stepmania/src/Style.cpp @@ -22,7 +22,7 @@ #include "NoteData.h" -void Style::GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData* pOriginal, NoteData* pNoteDataOut ) const +void Style::GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData& original, NoteData& noteDataOut ) const { int iNewToOriginalTrack[MAX_COLS_PER_PLAYER]; for( int col=0; colLoadTransformed( pOriginal, m_iColsPerPlayer, iNewToOriginalTrack ); + noteDataOut.LoadTransformed( original, m_iColsPerPlayer, iNewToOriginalTrack ); } diff --git a/stepmania/src/Style.h b/stepmania/src/Style.h index 01d61f382f..123f55b455 100644 --- a/stepmania/src/Style.h +++ b/stepmania/src/Style.h @@ -59,7 +59,7 @@ public: PlayerNumber ControllerToPlayerNumber( GameController controller ) const; - void GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData* pOriginal, NoteData* pNoteDataOut ) const; + void GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData& original, NoteData& noteDataOut ) const; bool MatchesStepsType( StepsType type ) const; diff --git a/stepmania/src/Trail.cpp b/stepmania/src/Trail.cpp index 5906d11d83..8b651ea1aa 100644 --- a/stepmania/src/Trail.cpp +++ b/stepmania/src/Trail.cpp @@ -76,7 +76,7 @@ RadarValues Trail::GetRadarValues() const if( !pSteps->IsAutogen() && e->ContainsTransformOrTurn() ) { NoteData nd; - pSteps->GetNoteData( &nd ); + pSteps->GetNoteData( nd ); RadarValues rv_orig; NoteDataUtil::GetRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv_orig ); PlayerOptions po;