From 9d16a66f773307de4be7ee73a5f64fe389c8d789 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 3 Apr 2005 21:43:29 +0000 Subject: [PATCH] fix radar values don't get recalculated after changing steps in editor fix radar values shown for edits if copied from official steps --- stepmania/src/ScreenEdit.cpp | 2 ++ stepmania/src/Song.cpp | 25 +++++++++++-------------- stepmania/src/Steps.cpp | 21 +++++++++++++++++++-- stepmania/src/Steps.h | 5 +++-- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 135fa2ef8c..ad967c1d66 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -1812,10 +1812,12 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns m_CurrentAction = c; // copy edit into current Steps + Song* pSong = GAMESTATE->m_pCurSong; Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; ASSERT( pSteps ); pSteps->SetNoteData( m_NoteDataEdit ); + pSteps->CalculateRadarValues( pSong->m_fMusicLengthSeconds ); if( HOME_EDIT_MODE ) { diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 23440b9329..0084a410a6 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -786,7 +786,13 @@ void Song::ReCalculateRadarValuesAndLastBeat() { Steps* pSteps = m_vpSteps[i]; - /* If it's autogen, radar vals and first/last beat will come from the parent. */ + pSteps->CalculateRadarValues( m_fMusicLengthSeconds ); + + // + // calculate lastBeat + // + + /* If it's autogen, then first/last beat will come from the parent. */ if( pSteps->IsAutogen() ) continue; @@ -795,28 +801,19 @@ void Song::ReCalculateRadarValuesAndLastBeat() if( pSteps->IsAnEdit() ) continue; + // Don't set first/last beat based on lights. They often start very + // early and end very late. + if( pSteps->m_StepsType == STEPS_TYPE_LIGHTS_CABINET ) + continue; - // - // calculate radar values - // NoteData tempNoteData; pSteps->GetNoteData( tempNoteData ); - RadarValues v; - NoteDataUtil::GetRadarValues( tempNoteData, m_fMusicLengthSeconds, v ); - pSteps->SetRadarValues( v ); - - /* Many songs have stray, empty song patterns. Ignore them, so * they don't force the first beat of the whole song to 0. */ if( tempNoteData.GetLastRow() == 0 ) continue; - // Don't set first/last beat based on lights. They often start very - // early and end very late. - if( pSteps->m_StepsType == STEPS_TYPE_LIGHTS_CABINET ) - continue; - fFirstBeat = min( fFirstBeat, tempNoteData.GetFirstBeat() ); fLastBeat = max( fLastBeat, tempNoteData.GetLastBeat() ); } diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 55f2e1b559..c9e4eef35a 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -151,6 +151,23 @@ void Steps::TidyUpData() SetMeter( int(PredictMeter()) ); } +void Steps::CalculateRadarValues( float fMusicLengthSeconds ) +{ + m_RadarValues = RadarValues(); + + // If we're autogen, don't calculate values. GetRadarValues will take from our parent. + if( parent != NULL ) + return; + + // If we're an edit, leave the RadarValues invalid. + if( IsAnEdit() ) + return; + + NoteData tempNoteData; + this->GetNoteData( tempNoteData ); + NoteDataUtil::GetRadarValues( tempNoteData, fMusicLengthSeconds, m_RadarValues ); +} + void Steps::Decompress() const { if( m_bNoteDataIsFilled ) @@ -266,7 +283,7 @@ void Steps::AutogenFrom( const Steps *parent_, StepsType ntTo ) m_StepsType = ntTo; } -void Steps::CopyFrom( Steps* pSource, StepsType ntTo ) // pSource does not have to be of the same StepsType! +void Steps::CopyFrom( Steps* pSource, StepsType ntTo, float fMusicLengthSeconds ) // pSource does not have to be of the same StepsType { m_StepsType = ntTo; NoteData noteData; @@ -276,7 +293,7 @@ void Steps::CopyFrom( Steps* pSource, StepsType ntTo ) // pSource does not have this->SetDescription( pSource->GetDescription() ); this->SetDifficulty( pSource->GetDifficulty() ); this->SetMeter( pSource->GetMeter() ); - this->SetRadarValues( pSource->GetRadarValues() ); + this->CalculateRadarValues( fMusicLengthSeconds ); } void Steps::CreateBlank( StepsType ntTo ) diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index 77e0db3ebd..0c87c6c962 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -22,7 +22,7 @@ public: // initializers void AutogenFrom( const Steps *parent, StepsType ntTo ); - void CopyFrom( Steps* pSource, StepsType ntTo ); + void CopyFrom( Steps* pSource, StepsType ntTo, float fMusicLengthSeconds ); void CreateBlank( StepsType ntTo ); void Compress() const; @@ -61,7 +61,8 @@ public: void GetSMNoteData( CString ¬es_comp_out ) const; void TidyUpData(); - + void CalculateRadarValues( float fMusicLengthSeconds ); + // Lua void PushSelf( lua_State *L );