From d2a54cca317d382ba7b2766f08e84683bfd9fa48 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 12 Sep 2004 05:56:24 +0000 Subject: [PATCH] make TapNote a struct. Over time, more properties will move from the enums and into bit flags. --- stepmania/src/BeginnerHelper.cpp | 6 +- stepmania/src/CatalogXml.cpp | 1 + stepmania/src/ModeChoice.cpp | 1 + stepmania/src/NoteData.cpp | 137 ++++++++++--------- stepmania/src/NoteData.h | 9 +- stepmania/src/NoteDataUtil.cpp | 134 +++++++++--------- stepmania/src/NoteDataWithScoring.cpp | 19 +-- stepmania/src/NoteField.cpp | 12 +- stepmania/src/NoteTypes.cpp | 9 ++ stepmania/src/NoteTypes.h | 105 +++++++------- stepmania/src/NotesLoaderBMS.cpp | 12 +- stepmania/src/NotesLoaderBMS.h | 3 +- stepmania/src/NotesLoaderDWI.cpp | 8 +- stepmania/src/NotesLoaderKSF.cpp | 6 +- stepmania/src/NotesWriterDWI.cpp | 19 +-- stepmania/src/Player.cpp | 92 ++++++------- stepmania/src/ProfileManager.cpp | 1 + stepmania/src/ScreenEdit.cpp | 8 +- stepmania/src/ScreenEvaluation.cpp | 2 +- stepmania/src/ScreenGameplay.cpp | 4 +- stepmania/src/ScreenHowToPlay.cpp | 2 +- stepmania/src/ScreenNameEntryTraditional.cpp | 1 + stepmania/src/ScreenSelectMusic.cpp | 1 + stepmania/src/SongManager.cpp | 1 + stepmania/src/StyleUtil.cpp | 1 + stepmania/src/StyleUtil.h | 4 +- 26 files changed, 306 insertions(+), 292 deletions(-) diff --git a/stepmania/src/BeginnerHelper.cpp b/stepmania/src/BeginnerHelper.cpp index e48f85b065..fdf0a62dca 100644 --- a/stepmania/src/BeginnerHelper.cpp +++ b/stepmania/src/BeginnerHelper.cpp @@ -335,9 +335,9 @@ void BeginnerHelper::Update( float fDeltaTime ) // Find all steps on this row, in order to show the correct animations int iStep = 0; const int iNumTracks = m_NoteData[pn].GetNumTracks(); - for(int k=0; kStep(pn, iStep); diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index cba6b5594a..e0425843af 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -17,6 +17,7 @@ #include "StyleUtil.h" #include "ThemeManager.h" #include "PrefsManager.h" +#include "Style.h" #define SHOW_PLAY_MODE(pm) THEME->GetMetricB("CatalogXml",ssprintf("ShowPlayMode%s",PlayModeToString(pm).c_str())) #define SHOW_STYLE(ps) THEME->GetMetricB("CatalogXml",ssprintf("ShowStyle%s",Capitalize((ps)->m_szName).c_str())) diff --git a/stepmania/src/ModeChoice.cpp b/stepmania/src/ModeChoice.cpp index 1307e7510c..b6b4023a58 100644 --- a/stepmania/src/ModeChoice.cpp +++ b/stepmania/src/ModeChoice.cpp @@ -15,6 +15,7 @@ #include "MemoryCardManager.h" #include "song.h" #include "Game.h" +#include "Style.h" void ModeChoice::Init() { diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 20d5dc5fb2..efc65235d9 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -90,15 +90,15 @@ void NoteData::CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromI { for( int c=0; c& addTo ) const { for( int t=0; t mapAttackToNothing; + // Add all used AttackNote index values to a map. + set setUsedIndices; int num_rows = GetNumRows(); for( int t=0; t::iterator iter = m_AttackMap.find( tn.attackIndex ); + ASSERT( iter != m_AttackMap.end() ); + return iter->second; } @@ -446,7 +446,7 @@ int NoteData::GetNumTapNotes( float fStartBeat, float fEndBeat ) const for( int i=iStartIndex; i<=iEndIndex; i++ ) { TapNote tn = GetTapNoteX(t, i); - if( tn != TAP_EMPTY && tn != TAP_MINE ) + if( tn.type != TapNote::empty && tn.type != TapNote::mine ) iNumNotes++; } } @@ -486,7 +486,7 @@ int NoteData::GetNumMines( float fStartBeat, float fEndBeat ) const for( int t=0; t= MinTaps ) @@ -622,20 +627,21 @@ void NoteData::Convert2sAnd3sToHoldNotes() { for( int i=0; i<=rows; i++ ) // foreach TapNote element { - if( GetTapNote(col, i) != TAP_HOLD_HEAD ) // this is a HoldNote begin marker + if( GetTapNote(col,i).type != TapNote::hold_head ) // this is a HoldNote begin marker continue; - SetTapNote(col, i, TAP_EMPTY); + SetTapNote(col, i, TAP_EMPTY); // clear the hold head marker for( int j=i+1; j<=rows; j++ ) // search for end of HoldNote { - // end hold on the next note we see - if( GetTapNote(col, j) == TAP_EMPTY ) + // End hold on the next note we see. This should be a hold_tail if the + // data is in a consistent state, but doesn't have to be. + if( GetTapNote(col, j).type == TapNote::empty ) continue; SetTapNote(col, j, TAP_EMPTY); AddHoldNote( HoldNote(col, i, j) ); - break; + break; // done searching for the end of this hold } } } @@ -654,8 +660,8 @@ void NoteData::ConvertHoldNotesTo2sAnd3s() /* If they're the same, then they got clamped together, so just ignore it. */ if( hn.iStartRow != hn.iEndRow ) { - SetTapNote( hn.iTrack, hn.iStartRow, TAP_HOLD_HEAD ); - SetTapNote( hn.iTrack, hn.iEndRow, TAP_HOLD_TAIL ); + SetTapNote( hn.iTrack, hn.iStartRow, TAP_ORIGINAL_HOLD_HEAD ); + SetTapNote( hn.iTrack, hn.iEndRow, TAP_ORIGINAL_HOLD_TAIL ); } } m_HoldNotes.clear(); @@ -699,19 +705,19 @@ void NoteData::Convert4sToHoldNotes() { for( int i=0; i<=rows; i++ ) // foreach TapNote element { - if( GetTapNote(col, i) != TAP_HOLD ) // this is a HoldNote body - continue; - - HoldNote hn( col, i, 0 ); - // search for end of HoldNote - do { + if( GetTapNote(col, i).type == TapNote::hold ) // this is a HoldNote body + { + HoldNote hn( col, i, 0 ); + // search for end of HoldNote + do { + SetTapNote(col, i, TAP_EMPTY); + i++; + } while( GetTapNote(col, i).type == TapNote::hold ); SetTapNote(col, i, TAP_EMPTY); - i++; - } while( GetTapNote(col, i) == TAP_HOLD); - SetTapNote(col, i, TAP_EMPTY); - hn.iEndRow = i; - AddHoldNote( hn ); + hn.iEndRow = i; + AddHoldNote( hn ); + } } } } @@ -722,9 +728,8 @@ void NoteData::ConvertHoldNotesTo4s() for( int i=0; i m_HoldNotes; - map m_AttackMap; + map m_AttackMap; /* Pad m_TapNotes so it includes the row "rows". */ void PadTapNotes(int rows); @@ -36,14 +36,15 @@ public: void SetNumTracks( int iNewNumTracks ); // TODO: Think of better accessors - const map& GetAttackMap() const { return m_AttackMap; } - map& GetAttackMap() { return m_AttackMap; } + const map& GetAttackMap() const { return m_AttackMap; } + map& GetAttackMap() { return m_AttackMap; } /* Return the note at the given track and row. Row may be out of * range; pretend the song goes on with TAP_EMPTYs indefinitely. */ inline TapNote GetTapNote(unsigned track, int row) const { - if(row < 0 || row >= (int) m_TapNotes[track].size()) return TapNote(TAP_EMPTY); + if(row < 0 || row >= (int) m_TapNotes[track].size()) + return TAP_EMPTY; return m_TapNotes[track][row]; } void ReserveRows( int row ); diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index 41fad4e7f8..289e954ae2 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -95,21 +95,22 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData, for( int c=0; c= 'a' && sMeasureLine[c] <= 'z' ) + if( ch >= 'a' && ch <= 'z' ) { - t = sMeasureLine[c]; + t.Set( TapNote::attack, TapNote::original, ch - 'a' ); } else { @@ -118,7 +119,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData, * due to invalid data. We should probably check for this when * we load SM data for the first time ... */ // ASSERT(0); - t = TAP_EMPTY; + t = TAP_EMPTY; } break; } @@ -154,7 +155,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData, if( asBits[0].empty() ) continue; - TapNote tn = asBits[0][0]; + int attack_index = asBits[0][0] - 'a'; Attack attack; attack.level = ATTACK_LEVEL_1; @@ -162,7 +163,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData, attack.sModifier.Replace( '.', ',' ); // we couldn't use comma here because the map item separator is a comma attack.fSecsRemaining = strtof( asBits[2], NULL ); - out.GetAttackMap()[tn] = attack; + out.GetAttackMap()[attack_index] = attack; } } } @@ -206,23 +207,17 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in_, CString ¬es_out, { TapNote tn = in.GetTapNote(t, r); char c; - switch( tn ) + switch( tn.type ) { - case TAP_EMPTY: c = '0'; break; - case TAP_TAP: c = '1'; break; - case TAP_HOLD_HEAD: c = '2'; break; - case TAP_HOLD_TAIL: c = '3'; break; - case TAP_MINE: c = 'M'; break; + case TapNote::empty: c = '0'; break; + case TapNote::tap: c = '1'; break; + case TapNote::hold_head: c = '2'; break; + case TapNote::hold_tail: c = '3'; break; + case TapNote::mine: c = 'M'; break; + case TapNote::attack: c = 'a' + (char)tn.attackIndex ; break; default: - if( IsTapAttack(tn) ) - { - c = tn; - } - else - { - ASSERT(0); - c = '0'; - } + ASSERT(0); + c = '0'; break; } sRet.append(1, c); @@ -239,15 +234,16 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in_, CString ¬es_out, // CStringArray asLines; - for( map::const_iterator iter = in_.GetAttackMap().begin(); + for( map::const_iterator iter = in_.GetAttackMap().begin(); iter != in_.GetAttackMap().end(); iter++ ) { - TapNote tn = iter->first; + int attackIndex = iter->first; + char ch = 'a' + (char)attackIndex; Attack attack = iter->second; attack.sModifier.Replace( ',', '.' ); // comma is the map item separator - asLines.push_back( ssprintf("%c=%s=%f,\n", tn, attack.sModifier.c_str(), attack.fSecsRemaining) ); + asLines.push_back( ssprintf("%c=%s=%f,\n", ch, attack.sModifier.c_str(), attack.fSecsRemaining) ); } attacks_out = join( ",", asLines ); @@ -298,8 +294,8 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o if( r ) for( int t=0; t<=Original.GetNumTracks(); t++ ) { - if( Original.GetTapNote(t, r) == TAP_HOLD && - Original.GetTapNote(t, r-1) == TAP_HOLD) + if( Original.GetTapNote(t,r).type == TapNote::hold && + Original.GetTapNote(t,r-1).type == TapNote::hold ) { bHoldCrossesThisMeasure = true; break; @@ -355,7 +351,7 @@ void NoteDataUtil::LoadOverlapped( const NoteData &input, NoteData &out, int iNe int &iTrackTo = DestRow[i]; const TapNote iStepFrom = in.GetTapNote( iTrackFrom, row ); - if( iStepFrom == TAP_EMPTY ) + if( iStepFrom.type == TapNote::empty ) continue; if( LastSourceTrack[iTrackTo] != iTrackFrom && @@ -404,12 +400,12 @@ void NoteDataUtil::LoadTransformedLights( const NoteData &in, NoteData &out, int * don't write huge streams of tap notes. */ bool bHoldNoteOnThisRow = false; for( int t=0; t0 && t=0; i-- ) if( fmodf(in.GetHoldNote(i).GetStartBeat(),1) != 0 ) // doesn't start on a beat @@ -906,11 +902,11 @@ void NoteDataUtil::Wide( NoteData &in, float fStartBeat, float fEndBeat ) iTrackToAdd--; CLAMP( iTrackToAdd, 0, in.GetNumTracks()-1 ); - if( in.GetTapNote(iTrackToAdd, i) != TAP_EMPTY ) + if( in.GetTapNote(iTrackToAdd, i).type != TapNote::empty ) { iTrackToAdd = (iTrackToAdd+1) % in.GetNumTracks(); } - in.SetTapNote(iTrackToAdd, i, TAP_ADDITION); + in.SetTapNote(iTrackToAdd, i, TAP_ADDITION_TAP); } in.Convert4sToHoldNotes(); @@ -1029,7 +1025,7 @@ void NoteDataUtil::InsertIntelligentTaps( } done_looking_for_track_to_add: - in.SetTapNote(iTrackOfNoteToAdd, iRowToAdd, TAP_ADDITION); + in.SetTapNote(iTrackOfNoteToAdd, iRowToAdd, TAP_ADDITION_TAP); } in.Convert4sToHoldNotes(); @@ -1057,8 +1053,8 @@ void NoteDataUtil::AddMines( NoteData &in, float fStartBeat, float fEndBeat ) if( iRowCount>=iPlaceEveryRows ) { for( int t=0; t iSimultaneousHolds ) break; - if( in.GetTapNote(t,r) == TAP_TAP ) + if( in.GetTapNote(t,r).type == TapNote::tap ) { // Find the ending row for this hold int iTapsLeft = iSimultaneousHolds; @@ -1191,7 +1187,7 @@ void NoteDataUtil::ConvertTapsToHolds( NoteData &in, int iSimultaneousHolds, flo // If there are two taps in a row on the same track, // don't convert the earlier one to a hold. - if( in.GetTapNote(t,r2) != TAP_EMPTY ) + if( in.GetTapNote(t,r2).type != TapNote::empty ) goto dont_add_hold; set tracksDown; @@ -1238,7 +1234,7 @@ void NoteDataUtil::Stomp( NoteData &in, StepsType st, float fStartBeat, float fE for( int t=0; tGetTapNote(t, i) != TAP_EMPTY && GetTapNoteScore(t, i) >= tns ) + if( this->GetTapNote(t, i).type != TapNote::empty && GetTapNoteScore(t, i) >= tns ) iNumSuccessfulTapNotes++; } } @@ -59,11 +59,10 @@ int NoteDataWithScoring::GetNumNWithScore( TapNoteScore tns, int MinTaps, const TapNoteScore minTapNoteScore = TNS_MARVELOUS; for( int t=0; tGetTapNote(t, i) == TAP_MINE && GetTapNoteScore(t, i) != TNS_HIT_MINE ) + if( this->GetTapNote(t,i).type == TapNote::mine && GetTapNoteScore(t, i) != TNS_HIT_MINE ) iNumSuccessfulMinesNotes++; } } @@ -143,7 +142,9 @@ int NoteDataWithScoring::GetSuccessfulHands( float fStartBeat, float fEndBeat ) for( int t=0; t=iFirstIndexToDraw; --i ) // for each row { TapNote tn = GetTapNote(c, i); - if( tn == TAP_EMPTY ) // no note here + if( tn.type == TapNote::empty ) // no note here continue; // skip - if( tn == TAP_HOLD_HEAD ) // this is a HoldNote begin marker. Grade it, but don't draw + if( tn.type == TapNote::hold_head ) // this is a HoldNote begin marker. Grade it, but don't draw continue; // skip // TRICKY: If boomerang is on, then all notes in the range @@ -601,7 +601,7 @@ void NoteField::DrawPrimitives() bool bHoldNoteBeginsOnThisBeat = false; for( int c2=0; c2 -2000, ssprintf("%i %i %i, %f %f", i, iLastIndexToDraw, iFirstIndexToDraw, GAMESTATE->m_fSongBeat, GAMESTATE->m_fMusicSeconds) ); SearchForBeat( CurDisplay, NextDisplay, NoteRowToBeat(i) ); diff --git a/stepmania/src/NoteTypes.cpp b/stepmania/src/NoteTypes.cpp index c951842678..dbf5e04f2f 100644 --- a/stepmania/src/NoteTypes.cpp +++ b/stepmania/src/NoteTypes.cpp @@ -1,6 +1,15 @@ #include "global.h" #include "NoteTypes.h" +TapNote TAP_EMPTY = { TapNote::empty, TapNote::original, 0 }; +TapNote TAP_ORIGINAL_TAP = { TapNote::tap, TapNote::original, 0 }; +TapNote TAP_ORIGINAL_HOLD_HEAD = { TapNote::hold_head, TapNote::original, 0 }; // '2' +TapNote TAP_ORIGINAL_HOLD_TAIL = { TapNote::hold_tail, TapNote::original, 0 }; // '3' +TapNote TAP_ORIGINAL_HOLD = { TapNote::hold, TapNote::original, 0 }; // '4' +TapNote TAP_ORIGINAL_MINE = { TapNote::mine, TapNote::original, 0 }; +TapNote TAP_ADDITION_TAP = { TapNote::tap, TapNote::addition, 0 }; +TapNote TAP_ADDITION_MINE = { TapNote::mine, TapNote::addition, 0 }; + float NoteTypeToBeat( NoteType nt ) { switch( nt ) diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index b4f44a1c7d..587c4988a7 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -1,68 +1,57 @@ #ifndef NOTE_TYPES_H #define NOTE_TYPES_H -#include "PlayerOptions.h" +struct TapNote +{ + enum Type { + empty, + tap, + hold_head, // graded like a TAP_TAP + hold_tail, /* In 2sand3s mode, holds are deleted and TAP_HOLD_END is added: */ + hold, /* In 4s mode, holds and TAP_HOLD_HEAD are deleted and TAP_HOLD is added: */ + mine, // don't step! + attack, + }; + unsigned type : 3; // no unsigned enum support in VC++ + enum Source { + original, // part of the original NoteData + addition, // additional note added by a transform + removed, // Removed taps, e.g. in Little - play keysounds here as if + // judged Perfect, but don't bother rendering or judging this + // step. Also used for when we implement auto-scratch in BM, + // and for if/when we do a "reduce" modifier that cancels out + // all but N keys on a line [useful for BM->DDR autogen, too]. + // Removed hold body (...why?) - acts as follows: + // 1 - if we're using a sustained-sound gametype [Keyboardmania], and + // we've already hit the start of the sound (?? we put Holds Off on?) + // then this is triggered automatically to keep the sound going + // 2 - if we're NOT [anything else], we ignore this. + // Equivalent to all 4s aside from the first one. + }; + unsigned source : 2; // only valid if type!=empty + unsigned attackIndex : 3; // attack index + // bit field sizes should add to 8 bits. -// '1' = tap note -// '2' = hold note begin -// '3' = hold note end ('1' can also end a HoldNote) ('3' without a matching '2' is ignored -// ... for future expansion + void Set( Type type_, Source source_, unsigned attackIndex_ ) + { + type = type_; + source = source_; + attackIndex = attackIndex_; + } +}; +const unsigned MAX_NUM_ATTACKS = 2*2*2; // 3 bits to hold the attack index currently -typedef unsigned char TapNote; - -static const TapNote TAP_EMPTY = '0'; -static const TapNote TAP_TAP = '1'; /* impatient? */ -static const TapNote TAP_HOLD_HEAD = '2'; // graded like a TAP_TAP - -/* In 2sand3s mode, holds are deleted and TAP_HOLD_END is added: */ -static const TapNote TAP_HOLD_TAIL = '3'; - -/* In 4s mode, holds and TAP_HOLD_HEAD are deleted and TAP_HOLD is added: */ -static const TapNote TAP_HOLD = '4'; - -// additional note added by a transform -static const TapNote TAP_ADDITION = '5'; - -// mine note - don't step! -static const TapNote TAP_MINE = '6'; - -// TAP_ADD_HOLD is to TAP_HOLD what TAP_ADDITION is to TAP_TAP. -// There is no equivalent for TAP_MINE. -static const TapNote TAP_ADD_HOLD = '7'; // is this supposed to be TAP_ADD_HOLD_HEAD? -Chris - - -// BM-specific -// Removed taps, e.g. in Little - play keysounds here as if -// judged Perfect, but don't bother rendering or judging this -// step. Also used for when we implement auto-scratch in BM, -// and for if/when we do a "reduce" modifier that cancels out -// all but N keys on a line [useful for BM->DDR autogen, too]. -static const TapNote TAP_REMOVED = '8'; - -// KM-specific -// Removed hold body (...why?) - acts as follows: -// 1 - if we're using a sustained-sound gametype [Keyboardmania], and -// we've already hit the start of the sound (?? we put Holds Off on?) -// then this is triggered automatically to keep the sound going -// 2 - if we're NOT [anything else], we ignore this. -// Equivalent to all 4s aside from the first one. -static const TapNote TAP_REMOVED_HOLD_BODY = ':'; - -// KM-specific -// A hold removed by Little, I guess. -static const TapNote TAP_REMOVED_HOLD_HEAD = '.'; - -// KM-specific -// Kills an auto-sound from a hold. -static const TapNote TAP_REMOVED_HOLD_TAIL = '\''; - -// step for an item -static const TapNote TAP_ATTACK_BEGIN = 'a'; -static const TapNote TAP_ATTACK_END = 'z'; - -inline bool IsTapAttack( TapNote tn ) { return tn>=TAP_ATTACK_BEGIN && tn<=TAP_ATTACK_END; } +extern TapNote TAP_EMPTY; // '0' +extern TapNote TAP_ORIGINAL_TAP; // '1' +extern TapNote TAP_ORIGINAL_HOLD_HEAD; // '2' +extern TapNote TAP_ORIGINAL_HOLD_TAIL; // '3' +extern TapNote TAP_ORIGINAL_HOLD; // '4' +extern TapNote TAP_ORIGINAL_MINE; // 'M' +extern TapNote TAP_ADDITION_TAP; +extern TapNote TAP_ADDITION_MINE; +// TODO: Don't have a hard-coded track limit. enum { TRACK_1 = 0, diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index 6b48a450b0..600a844f51 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -128,16 +128,16 @@ StepsType BMSLoader::CheckTracksMagic() } } -void BMSLoader::mapBMSTrackToDanceNote( int iBMSTrack, int &iDanceColOut, char &cNoteCharOut ) +void BMSLoader::mapBMSTrackToDanceNote( int iBMSTrack, int &iDanceColOut, TapNote &tapNoteOut ) { if( iBMSTrack > 40 ) { - cNoteCharOut = '2'; + tapNoteOut = TAP_ORIGINAL_HOLD_HEAD; iBMSTrack -= 40; } else { - cNoteCharOut = '1'; + tapNoteOut = TAP_ORIGINAL_TAP; } switch( iBMSTrack ) @@ -293,12 +293,12 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Steps &out ) const int iNoteIndex = (int) ( (iMeasureNo + fPercentThroughMeasure) * BEATS_PER_MEASURE * ROWS_PER_BEAT ); int iColumnNumber; - char cNoteChar; + TapNote tapNoteOut; - mapBMSTrackToDanceNote( iTrackNum, iColumnNumber, cNoteChar ); + mapBMSTrackToDanceNote( iTrackNum, iColumnNumber, tapNoteOut ); if( iColumnNumber != -1 ) - pNoteData->SetTapNote(iColumnNumber, iNoteIndex, cNoteChar); + pNoteData->SetTapNote(iColumnNumber, iNoteIndex, tapNoteOut); } } } diff --git a/stepmania/src/NotesLoaderBMS.h b/stepmania/src/NotesLoaderBMS.h index ee60567cc7..8f01144377 100644 --- a/stepmania/src/NotesLoaderBMS.h +++ b/stepmania/src/NotesLoaderBMS.h @@ -3,6 +3,7 @@ #include "NotesLoader.h" #include "GameConstantsAndTypes.h" +#include "NoteTypes.h" class Song; class Steps; @@ -10,7 +11,7 @@ class Steps; class BMSLoader: public NotesLoader { bool LoadFromBMSFile( const CString &sPath, Steps &out1 ); - void mapBMSTrackToDanceNote( int iBMSTrack, int &iDanceColOut, char &cNoteCharOut ); + void mapBMSTrackToDanceNote( int iBMSTrack, int &iDanceColOut, TapNote &tapNoteOut ); void PushTrackNumForMagic( int iTrackNum ); StepsType CheckTracksMagic(); void ResetTracksMagic(); diff --git a/stepmania/src/NotesLoaderDWI.cpp b/stepmania/src/NotesLoaderDWI.cpp index 5a4ddac5cb..8206d2bfa5 100644 --- a/stepmania/src/NotesLoaderDWI.cpp +++ b/stepmania/src/NotesLoaderDWI.cpp @@ -266,9 +266,9 @@ bool DWILoader::LoadFromDWITokens( DWIcharToNoteCol( c, (GameController)pad, iCol1, iCol2 ); if( iCol1 != -1 ) - newNoteData.SetTapNote(iCol1, iIndex, TAP_TAP); + newNoteData.SetTapNote(iCol1, iIndex, TAP_ORIGINAL_TAP); if( iCol2 != -1 ) - newNoteData.SetTapNote(iCol2, iIndex, TAP_TAP); + newNoteData.SetTapNote(iCol2, iIndex, TAP_ORIGINAL_TAP); if( sStepData[i] == '!' ) { @@ -278,9 +278,9 @@ bool DWILoader::LoadFromDWITokens( DWIcharToNoteCol( holdChar, (GameController)pad, iCol1, iCol2 ); if( iCol1 != -1 ) - newNoteData.SetTapNote(iCol1, iIndex, TAP_HOLD_HEAD); + newNoteData.SetTapNote(iCol1, iIndex, TAP_ORIGINAL_HOLD_HEAD); if( iCol2 != -1 ) - newNoteData.SetTapNote(iCol2, iIndex, TAP_HOLD_HEAD); + newNoteData.SetTapNote(iCol2, iIndex, TAP_ORIGINAL_HOLD_HEAD); } } diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index 35a7221bf8..3e01d3bc66 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -192,9 +192,9 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Steps &out, const Song &s TapNote tap; switch(sRowString[t]) { - case '0': tap = TAP_EMPTY; break; - case '1': tap = TAP_TAP; break; - default: ASSERT(0); tap = TAP_EMPTY; break; + case '0': tap = TAP_EMPTY; break; + case '1': tap = TAP_ORIGINAL_TAP; break; + default: ASSERT(0); tap = TAP_EMPTY; break; } notedata.SetTapNote(t, row, tap); diff --git a/stepmania/src/NotesWriterDWI.cpp b/stepmania/src/NotesWriterDWI.cpp index 53c1df023b..2732ea5924 100644 --- a/stepmania/src/NotesWriterDWI.cpp +++ b/stepmania/src/NotesWriterDWI.cpp @@ -15,14 +15,14 @@ CString NotesWriterDWI::NotesToDWIString( const TapNote cNoteCols[6] ) CString taps, holds, ret; for( int col = 0; col < 6; ++col ) { - switch( cNoteCols[col] ) + switch( cNoteCols[col].type ) { - case TAP_EMPTY: - case TAP_MINE: + case TapNote::empty: + case TapNote::mine: continue; } - if( cNoteCols[col] == TAP_HOLD_HEAD ) + if( cNoteCols[col].type == TapNote::hold_head ) holds += dirs[col]; else taps += dirs[col]; @@ -83,10 +83,13 @@ CString NotesWriterDWI::NotesToDWIString( const TapNote cNoteCols[6] ) CString NotesWriterDWI::NotesToDWIString( TapNote cNoteCol1, TapNote cNoteCol2, TapNote cNoteCol3, TapNote cNoteCol4, TapNote cNoteCol5, TapNote cNoteCol6 ) { - const TapNote cNoteCols[6] = { - cNoteCol1, cNoteCol2, cNoteCol3, cNoteCol4, cNoteCol5, cNoteCol6 - }; - + TapNote cNoteCols[6]; + cNoteCols[0] = cNoteCol1; + cNoteCols[1] = cNoteCol2; + cNoteCols[2] = cNoteCol3; + cNoteCols[3] = cNoteCol4; + cNoteCols[4] = cNoteCol5; + cNoteCols[5] = cNoteCol6; return NotesToDWIString( cNoteCols ); } diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 4c39d10364..89aaf96937 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -597,7 +597,7 @@ int PlayerMinus::GetClosestNoteDirectional( int col, float fBeat, float fMaxBeat int iCurrentIndex = iIndexStartLookingAt + (iDirection * delta); if( iCurrentIndex < 0) continue; - if( GetTapNote(col, iCurrentIndex) == TAP_EMPTY) continue; /* no note here */ + if( GetTapNote(col, iCurrentIndex).type == TapNote::empty) continue; /* no note here */ if( GetTapNoteScore(col, iCurrentIndex) != TNS_NONE ) continue; /* this note has a score already */ return iCurrentIndex; @@ -678,11 +678,11 @@ void PlayerMinus::Step( int col, RageTimer tm ) switch( GAMESTATE->m_PlayerController[m_PlayerNumber] ) { - case PC_HUMAN: { + case PC_HUMAN: - switch( tn ) + switch( tn.type ) { - case TAP_MINE: + case TapNote::mine: // stepped too close to mine? if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Mine) ) { @@ -698,42 +698,38 @@ void PlayerMinus::Step( int col, RageTimer tm ) } break; - default: // not a mine - if( IsTapAttack(tn) ) + case TapNote::attack: + score = TNS_NONE; // don't score this as anything + if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Attack) ) { - score = TNS_NONE; // don't score this as anything - if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Attack) ) - { - m_soundAttackLaunch.Play(); - // put attack in effect - Attack attack = this->GetAttackAt( col, iIndexOverlappingNote ); - GAMESTATE->LaunchAttack( OPPOSITE_PLAYER[m_PlayerNumber], attack ); + m_soundAttackLaunch.Play(); + // put attack in effect + Attack attack = this->GetAttackAt( col, iIndexOverlappingNote ); + GAMESTATE->LaunchAttack( OPPOSITE_PLAYER[m_PlayerNumber], attack ); - // remove all TapAttacks on this row - for( int t=0; tGetNumTracks(); t++ ) + // remove all TapAttacks on this row + for( int t=0; tGetNumTracks(); t++ ) + { + TapNote tn = this->GetTapNote(t, iIndexOverlappingNote); + if( tn.type == TapNote::attack ) { - TapNote tn = this->GetTapNote(t, iIndexOverlappingNote); - if( IsTapAttack(tn) ) - { - this->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField - m_pNoteField->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField - } + this->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField + m_pNoteField->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField } } } - else // !IsTapAttack - { - if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Marvelous) ) score = TNS_MARVELOUS; - else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Perfect) ) score = TNS_PERFECT; - else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Great) ) score = TNS_GREAT; - else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Good) ) score = TNS_GOOD; - else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Boo) ) score = TNS_BOO; - else score = TNS_NONE; - } + break; + default: + if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Marvelous) ) score = TNS_MARVELOUS; + else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Perfect) ) score = TNS_PERFECT; + else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Great) ) score = TNS_GREAT; + else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Good) ) score = TNS_GOOD; + else if( fSecondsFromPerfect <= ADJUSTED_WINDOW(Boo) ) score = TNS_BOO; + else score = TNS_NONE; break; } break; - } + case PC_CPU: case PC_AUTOPLAY: switch( GAMESTATE->m_PlayerController[m_PlayerNumber] ) @@ -748,14 +744,14 @@ void PlayerMinus::Step( int col, RageTimer tm ) // TRICKY: We're asking the AI to judge mines. consider TNS_GOOD and below // as "mine was hit" and everything else as "mine was avoided" - if( tn == TAP_MINE ) + if( tn.type == TapNote::mine ) { // The CPU hits a lot of mines. Only consider hitting the // first mine for a row. We know we're the first mine if // there are are no mines to the left of us. for( int t=0; t TNS_GOOD ) + if( tn.type == TapNote::attack && score > TNS_GOOD ) { m_soundAttackLaunch.Play(); score = TNS_NONE; // don't score this as anything @@ -802,7 +798,7 @@ void PlayerMinus::Step( int col, RageTimer tm ) for( int t=0; tGetNumTracks(); t++ ) { TapNote tn = this->GetTapNote(t, iIndexOverlappingNote); - if( IsTapAttack(tn) ) + if( tn.type == TapNote::attack ) { this->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField m_pNoteField->SetTapNote(col, iIndexOverlappingNote, TAP_EMPTY); // remove from NoteField @@ -863,11 +859,10 @@ void PlayerMinus::Step( int col, RageTimer tm ) if( m_pSecondaryScoreKeeper ) m_pSecondaryScoreKeeper->HandleTapScore( score ); - switch( tn ) + switch( tn.type ) { - case TAP_TAP: - case TAP_HOLD_HEAD: - case TAP_ADDITION: + case TapNote::tap: + case TapNote::hold_head: // don't the row if this note is a mine or tap attack if( IsRowCompletelyJudged(iIndexOverlappingNote) ) OnRowCompletelyJudged( iIndexOverlappingNote ); @@ -945,8 +940,8 @@ void PlayerMinus::OnRowCompletelyJudged( int iIndexThatWasSteppedOn ) { TapNote tn = GetTapNote(c, iIndexThatWasSteppedOn); - if( tn == TAP_EMPTY ) continue; /* no note in this col */ - if( tn == TAP_MINE ) continue; /* don't flash on mines b/c they're supposed to be missed */ + if( tn.type == TapNote::empty ) continue; /* no note in this col */ + if( tn.type == TapNote::mine ) continue; /* don't flash on mines b/c they're supposed to be missed */ // If the score is great or better, remove the note from the screen to // indicate success. (Or always if blind is on.) @@ -1011,10 +1006,12 @@ void PlayerMinus::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds ) bool MissedNoteOnThisRow = false; for( int t=0; tm_PlayerController[m_PlayerNumber] != PC_HUMAN ) { for( int t=0; tGetCurrentStyle()->StyleInputToGameInput( StyleI ); @@ -1091,7 +1088,8 @@ void PlayerMinus::RandomiseNotes( int iNoteRow ) const TapNote t1 = GetTapNote(t, NewNoteRow); const TapNote t2 = GetTapNote(iRandomTrackToSwapWith, NewNoteRow); - if( (t1 == TAP_TAP || t1 == TAP_EMPTY) && (t2 == TAP_TAP || t2 == TAP_EMPTY) ) + if( (t1.type == TapNote::tap || t1.type == TapNote::empty) && + (t2.type == TapNote::tap || t2.type == TapNote::empty) ) { SetTapNote(t, NewNoteRow, t2); SetTapNote(iRandomTrackToSwapWith, NewNoteRow, t1); diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index f60ee8f39f..96b656e81b 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -20,6 +20,7 @@ #include "MemoryCardManager.h" #include "XmlFile.h" #include "StepsUtil.h" +#include "Style.h" ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 3e6c5d9bbd..87f6b8fd88 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -726,7 +726,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } - if( m_NoteFieldEdit.GetTapNote(iCol, iSongIndex) != TAP_EMPTY ) + if( m_NoteFieldEdit.GetTapNote(iCol, iSongIndex).type != TapNote::empty ) { m_NoteFieldEdit.SetTapNote( iCol, iSongIndex, TAP_EMPTY ); return; @@ -735,7 +735,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ // Hold LShift to lay mine, hold RShift to lay an attack if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) ) { - m_NoteFieldEdit.SetTapNote(iCol, iSongIndex, TAP_MINE ); + m_NoteFieldEdit.SetTapNote(iCol, iSongIndex, TAP_ORIGINAL_MINE ); } else if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)) ) { @@ -744,7 +744,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } else { - m_NoteFieldEdit.SetTapNote(iCol, iSongIndex, TAP_TAP ); + m_NoteFieldEdit.SetTapNote(iCol, iSongIndex, TAP_ORIGINAL_TAP ); } } break; @@ -1214,7 +1214,7 @@ void ScreenEdit::InputRecord( const DeviceInput& DeviceI, const InputEventType t if( iRow < 0 ) break; - m_NoteFieldRecord.SetTapNote(iCol, iRow, TAP_TAP); + m_NoteFieldRecord.SetTapNote(iCol, iRow, TAP_ORIGINAL_TAP); m_NoteFieldRecord.Step( iCol, TNS_MARVELOUS ); } break; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index e673f9b660..25f34474bf 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -26,7 +26,7 @@ #include "RageDisplay.h" #include "StepMania.h" #include "CryptManager.h" -#include +#include "Style.h" const int NUM_SCORE_DIGITS = 9; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 03468beb42..cf39dfba72 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1510,7 +1510,7 @@ void ScreenGameplay::Update( float fDeltaTime ) { // Somehow, step data was getting majorly corrupted, therefor causing light // signals to be sent at incorrect times where notes were not even present. - bool bBlink = (m_CabinetLightsNoteData.GetTapNote( cl, r ) != TAP_EMPTY); + bool bBlink = (m_CabinetLightsNoteData.GetTapNote( cl, r ).type != TapNote::empty ); bBlinkCabinetLight[cl] |= bBlink; } FOREACH_EnabledPlayer( pn ) @@ -1518,7 +1518,7 @@ void ScreenGameplay::Update( float fDeltaTime ) for( int t=0; t