From 646d4ba6d975f8a3a5859f602a72f06bbcbce78b Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 5 Oct 2002 20:03:14 +0000 Subject: [PATCH] smarter autogen for doubles --- stepmania/src/GameManager.cpp | 32 ++++++++++-------- stepmania/src/NoteData.cpp | 61 +++++++++++++++++------------------ stepmania/src/NoteData.h | 3 +- stepmania/src/Song.cpp | 13 ++++++-- stepmania/src/song.h | 1 + 5 files changed, 59 insertions(+), 51 deletions(-) diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index 9a1e6ec3c7..d99f8973c6 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -529,27 +529,31 @@ StyleDef g_StyleDefs[NUM_STYLES] = GAME_DANCE, // m_Game false, // m_bUsedForGameplay true, // m_bUsedForEdit - "couple (edit-only)", // m_szName + "couple (edit)", // m_szName { NOTES_TYPE_DANCE_COUPLE, NOTES_TYPE_DANCE_COUPLE }, // m_NotesTypes StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType { 160, 480 }, // m_iCenterX 8, // m_iColsPerPlayer { // m_ColumnInfo[NUM_PLAYERS][MAX_COLS_PER_PLAYER]; { // PLAYER_1 - { TRACK_1, GAME_CONTROLLER_1, DANCE_BUTTON_LEFT, +DANCE_COL_SPACING*4.0f }, - { TRACK_2, GAME_CONTROLLER_1, DANCE_BUTTON_DOWN, +DANCE_COL_SPACING*3.0f }, - { TRACK_3, GAME_CONTROLLER_1, DANCE_BUTTON_UP, +DANCE_COL_SPACING*2.0f }, - { TRACK_4, GAME_CONTROLLER_1, DANCE_BUTTON_RIGHT, +DANCE_COL_SPACING*1.0f }, - { TRACK_5, GAME_CONTROLLER_2, DANCE_BUTTON_LEFT, -DANCE_COL_SPACING*1.0f }, - { TRACK_6, GAME_CONTROLLER_2, DANCE_BUTTON_DOWN, -DANCE_COL_SPACING*2.0f }, - { TRACK_7, GAME_CONTROLLER_2, DANCE_BUTTON_UP, -DANCE_COL_SPACING*3.0f }, - { TRACK_8, GAME_CONTROLLER_2, DANCE_BUTTON_RIGHT, -DANCE_COL_SPACING*4.0f }, + { TRACK_1, GAME_CONTROLLER_1, DANCE_BUTTON_LEFT, -DANCE_COL_SPACING*4.0f }, + { TRACK_2, GAME_CONTROLLER_1, DANCE_BUTTON_DOWN, -DANCE_COL_SPACING*3.0f }, + { TRACK_3, GAME_CONTROLLER_1, DANCE_BUTTON_UP, -DANCE_COL_SPACING*2.0f }, + { TRACK_4, GAME_CONTROLLER_1, DANCE_BUTTON_RIGHT, -DANCE_COL_SPACING*1.0f }, + { TRACK_5, GAME_CONTROLLER_2, DANCE_BUTTON_LEFT, +DANCE_COL_SPACING*1.0f }, + { TRACK_6, GAME_CONTROLLER_2, DANCE_BUTTON_DOWN, +DANCE_COL_SPACING*2.0f }, + { TRACK_7, GAME_CONTROLLER_2, DANCE_BUTTON_UP, +DANCE_COL_SPACING*3.0f }, + { TRACK_8, GAME_CONTROLLER_2, DANCE_BUTTON_RIGHT, +DANCE_COL_SPACING*4.0f }, }, { // PLAYER_2 - { TRACK_1, GAME_CONTROLLER_1, DANCE_BUTTON_LEFT, -DANCE_COL_SPACING*1.5f }, - { TRACK_2, GAME_CONTROLLER_1, DANCE_BUTTON_DOWN, -DANCE_COL_SPACING*0.5f }, - { TRACK_3, GAME_CONTROLLER_1, DANCE_BUTTON_UP, +DANCE_COL_SPACING*0.5f }, - { TRACK_4, GAME_CONTROLLER_1, DANCE_BUTTON_RIGHT, +DANCE_COL_SPACING*1.5f }, + { TRACK_1, GAME_CONTROLLER_1, DANCE_BUTTON_LEFT, -DANCE_COL_SPACING*4.0f }, + { TRACK_2, GAME_CONTROLLER_1, DANCE_BUTTON_DOWN, -DANCE_COL_SPACING*3.0f }, + { TRACK_3, GAME_CONTROLLER_1, DANCE_BUTTON_UP, -DANCE_COL_SPACING*2.0f }, + { TRACK_4, GAME_CONTROLLER_1, DANCE_BUTTON_RIGHT, -DANCE_COL_SPACING*1.0f }, + { TRACK_5, GAME_CONTROLLER_2, DANCE_BUTTON_LEFT, +DANCE_COL_SPACING*1.0f }, + { TRACK_6, GAME_CONTROLLER_2, DANCE_BUTTON_DOWN, +DANCE_COL_SPACING*2.0f }, + { TRACK_7, GAME_CONTROLLER_2, DANCE_BUTTON_UP, +DANCE_COL_SPACING*3.0f }, + { TRACK_8, GAME_CONTROLLER_2, DANCE_BUTTON_RIGHT, +DANCE_COL_SPACING*4.0f }, }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; @@ -714,7 +718,7 @@ StyleDef g_StyleDefs[NUM_STYLES] = GAME_PUMP, // m_Game false, // m_bUsedForGameplay true, // m_bUsedForEdit - "couple (edit-only)", // m_szName + "couple (edit)", // m_szName { NOTES_TYPE_PUMP_COUPLE,NOTES_TYPE_PUMP_COUPLE}, // m_NotesTypes StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType { 160, 480 }, // m_iCenterX diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 776dd446bb..4cb83d098a 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -865,50 +865,46 @@ void NoteData::LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTra pOriginal->ConvertHoldNotesTo4s(); m_iNumTracks = iNewNumTracks; + int iCurTrackOffset = 0; + int iTrackOffsetMin = 0; + int iTrackOffsetMax = abs( iNewNumTracks - pOriginal->m_iNumTracks ); + int bOffsetIncreasing = true; + int iLastRow = pOriginal->GetLastRow(); for( int r=0; r<=iLastRow; r++ ) { - int iMeasure = (int)(NoteRowToBeat(r) / BEATS_PER_MEASURE); - + // copy notes in this measure for( int t=0; t<=pOriginal->m_iNumTracks; t++ ) { int iOldTrack = t; - int iNewTrack = (iOldTrack + iMeasure/4) % iNewNumTracks; // change sliding window every 4 measures - + int iNewTrack = (iOldTrack + iCurTrackOffset) % iNewNumTracks; if( pOriginal->m_TapNotes[iOldTrack][r] != '0' ) this->m_TapNotes[iNewTrack][r] = pOriginal->m_TapNotes[iOldTrack][r]; } - } - pOriginal->Convert4sToHoldNotes(); - Convert4sToHoldNotes(); -} - -void NoteData::LoadTransformedMirrorOnCross( NoteData* pOriginal, int iNewNumTracks ) -{ - ASSERT( iNewNumTracks == pOriginal->m_iNumTracks*2 ); - - m_iNumTracks = iNewNumTracks; - - pOriginal->ConvertHoldNotesTo4s(); - - bool bMirror = false; - int iMirrorTrack = pOriginal->m_iNumTracks/2-1; - - int iLastRow = pOriginal->GetLastRow(); - for( int r=0; r<=iLastRow; r++ ) - { - for( int t=0; t<=pOriginal->m_iNumTracks; t++ ) + if( r % (ROWS_PER_MEASURE*2) == 0 ) // adjust sliding window every two measures { - int iOldTrack = t; - int iNewTrack = bMirror ? m_iNumTracks - iOldTrack : iOldTrack; - - if( pOriginal->m_TapNotes[iOldTrack][r] != '0' ) + // See if there is a hold crossing the beginning of this measure + pOriginal->Convert4sToHoldNotes(); + bool bHoldCrossesThisMeasure = false; + for( int i=0; im_iNumHoldNotes; i++ ) { - this->m_TapNotes[iNewTrack][r] = pOriginal->m_TapNotes[iOldTrack][r]; - - if( iOldTrack == iMirrorTrack ) - bMirror ^= true; + const HoldNote& hn = pOriginal->m_HoldNotes[i]; + if( hn.m_fStartBeat < NoteRowToBeat(r) && hn.m_fEndBeat > NoteRowToBeat(r) ) + { + bHoldCrossesThisMeasure = true; + break; + } + } + pOriginal->ConvertHoldNotesTo4s(); + + // adjust offset + if( !bHoldCrossesThisMeasure ) + { + iCurTrackOffset += bOffsetIncreasing ? 1 : -1; + if( iCurTrackOffset == iTrackOffsetMin || iCurTrackOffset == iTrackOffsetMax ) + bOffsetIncreasing ^= true; + CLAMP( iCurTrackOffset, iTrackOffsetMin, iTrackOffsetMax ); } } } @@ -917,6 +913,7 @@ void NoteData::LoadTransformedMirrorOnCross( NoteData* pOriginal, int iNewNumTra Convert4sToHoldNotes(); } + NoteType NoteData::GetSmallestNoteTypeForMeasure( int iMeasureIndex ) { const int iMeasureStartIndex = iMeasureIndex * ROWS_PER_MEASURE; diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index ce9840bfaa..85ebfdf158 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -89,8 +89,7 @@ public: // Transformations void LoadTransformed( NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track - void LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTracks ); // useful for autogenerating DDR->Pump, Pump->DDR - void LoadTransformedMirrorOnCross( NoteData* pOriginal, int iNewNumTracks ); // useful for autogenerating double patterns + void LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTracks ); // used by autogen void CropToLeftSide(); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 0d695c19be..6093035466 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -33,7 +33,7 @@ #include "NotesLoaderKSF.h" #include "NotesWriterDWI.h" -const int FILE_CACHE_VERSION = 92; // increment this when Song or Notes changes to invalidate cache +const int FILE_CACHE_VERSION = 97; // increment this when Song or Notes changes to invalidate cache int CompareBPMSegments(const void *arg1, const void *arg2) @@ -548,10 +548,15 @@ void Song::TidyUpData() /* Get Notes that match a given style and player. */ void Song::GetNotesThatMatch( const StyleDef *s, int p, CArray& arrayAddTo ) const +{ + GetNotesThatMatch( s->m_NotesTypes[p], arrayAddTo ); +} + +void Song::GetNotesThatMatch( NotesType nt, CArray& arrayAddTo ) const { for( int i=0; im_NotesType == s->m_NotesTypes[p] ) + if( m_apNotes[i]->m_NotesType == nt ) arrayAddTo.Add( m_apNotes[i] ); } } @@ -731,7 +736,9 @@ void Song::AddAutoGenNotes() { int iNumTracks = GAMEMAN->NotesTypeToNumTracks(nt); int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing); - if( SongHasNotesType(nt) && iTrackDifference apNotes; + this->GetNotesThatMatch( nt, apNotes ); + if( iTrackDifference 0 && apNotes[0]->m_sDescription.Find("autogen")==-1 ) { ntBestMatch = nt; iBestTrackDifference = iTrackDifference; diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 72fc4aef68..f70328be20 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -189,6 +189,7 @@ public: bool SongHasNotesType( NotesType nt ) const; bool SongHasNotesTypeAndDifficulty( NotesType nt, Difficulty dc ) const; void GetNotesThatMatch( const StyleDef *s, int p, CArray& arrayAddTo ) const; + void GetNotesThatMatch( NotesType nt, CArray& arrayAddTo ) const; int GetNumTimesPlayed() const; bool IsNew() const; bool IsEasy( NotesType nt ) const;