From 734f9760cc15fc876c4cfb96a77c4e949a471797 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 14 Aug 2006 10:17:48 +0000 Subject: [PATCH] Remove unnecessary member. Just set iKeysoundIndex to -1 if it isn't valid. --- stepmania/src/AutoKeysounds.cpp | 6 +++--- stepmania/src/NoteDataUtil.cpp | 8 ++------ stepmania/src/NoteTypes.cpp | 18 +++++++++--------- stepmania/src/NoteTypes.h | 12 ++++-------- stepmania/src/NotesLoaderBMS.cpp | 3 --- stepmania/src/Player.cpp | 4 ++-- stepmania/src/ScreenEdit.cpp | 3 +-- 7 files changed, 21 insertions(+), 33 deletions(-) diff --git a/stepmania/src/AutoKeysounds.cpp b/stepmania/src/AutoKeysounds.cpp index 9ed07929d0..1d40613e58 100644 --- a/stepmania/src/AutoKeysounds.cpp +++ b/stepmania/src/AutoKeysounds.cpp @@ -91,11 +91,11 @@ void AutoKeysounds::FinishLoading() bool bSoundIsGlobal = true; { PlayerNumber pn = GetNextEnabledPlayer((PlayerNumber)-1); - const TapNote t = tn[pn]; + const TapNote &t = tn[pn]; pn = GetNextEnabledPlayer(pn); while( pn != PLAYER_INVALID ) { - if( tn[pn].type != TapNote::autoKeysound || tn[pn].bKeysound != t.bKeysound ) + if( tn[pn].type != TapNote::autoKeysound || tn[pn].iKeysoundIndex != t.iKeysoundIndex ) bSoundIsGlobal = false; pn = GetNextEnabledPlayer(pn); } @@ -107,7 +107,7 @@ void AutoKeysounds::FinishLoading() continue; ASSERT( tn[pn].type == TapNote::autoKeysound ); - if( tn[pn].bKeysound ) + if( tn[pn].iKeysoundIndex >= 0 ) { RString sKeysoundFilePath = sSongDir + pSong->m_vsKeysoundFile[tn[pn].iKeysoundIndex]; float fSeconds = pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(iRow) ); diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index 5f9181abac..b33b5eb0fd 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -187,10 +187,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS p++; int iKeysoundIndex = 0; if( 1 == sscanf( p, "%d]", &iKeysoundIndex ) ) // not fatal if this fails due to malformed data - { - tn.bKeysound = true; tn.iKeysoundIndex = iKeysoundIndex; - } // skip past the ']' while( p < endLine ) @@ -386,7 +383,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet ) sRet.append( ssprintf("{%s:%.2f}", tn.sAttackModifiers.c_str(), tn.fAttackDurationSeconds) ); } - if( tn.bKeysound ) + if( tn.iKeysoundIndex >= 0 ) sRet.append( ssprintf("[%d]",tn.iKeysoundIndex) ); } @@ -1962,8 +1959,7 @@ void NoteDataUtil::AddTapAttacks( NoteData &nd, Song* pSong ) TapNote::original, szAttacks[RandomInt(ARRAYSIZE(szAttacks))], 15.0f, - false, - 0 ); + -1 ); nd.SetTapNote( iTrack, BeatToNoteRow(fBeat), tn ); } } diff --git a/stepmania/src/NoteTypes.cpp b/stepmania/src/NoteTypes.cpp index 0b52bfd423..3e24ed3cf6 100644 --- a/stepmania/src/NoteTypes.cpp +++ b/stepmania/src/NoteTypes.cpp @@ -6,15 +6,15 @@ #include "XmlFile.h" #include "LocalizedString.h" -TapNote TAP_EMPTY ( TapNote::empty, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ORIGINAL_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ORIGINAL_HOLD_HEAD ( TapNote::hold_head, TapNote::hold_head_hold, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ORIGINAL_ROLL_HEAD ( TapNote::hold_head, TapNote::hold_head_roll, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ORIGINAL_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ORIGINAL_ATTACK ( TapNote::attack, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ORIGINAL_AUTO_KEYSOUND ( TapNote::autoKeysound,TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 ); -TapNote TAP_ADDITION_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::addition, "", 0, false, 0 ); -TapNote TAP_ADDITION_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::addition, "", 0, false, 0 ); +TapNote TAP_EMPTY ( TapNote::empty, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_HOLD_HEAD ( TapNote::hold_head, TapNote::hold_head_hold, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_ROLL_HEAD ( TapNote::hold_head, TapNote::hold_head_roll, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_ATTACK ( TapNote::attack, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_AUTO_KEYSOUND ( TapNote::autoKeysound,TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); +TapNote TAP_ADDITION_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::addition, "", 0, -1 ); +TapNote TAP_ADDITION_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::addition, "", 0, -1 ); static const char *NoteTypeNames[] = { "4th", diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index afcea98605..1244531fee 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -100,10 +100,8 @@ struct TapNote RString sAttackModifiers; float fAttackDurationSeconds; - bool bKeysound; // true if this note plays a keysound when hit - int iKeysoundIndex; // index into Song's vector of keysound files. - // Only valid if bKeysound. + // Only valid if nonnegative. /* hold_head only: */ int iDuration; @@ -119,15 +117,14 @@ struct TapNote XNode* CreateNode() const; void LoadFromNode( const XNode* pNode ); - - TapNote() {} + TapNote() : type(empty), subType(SubType_invalid), source(original), fAttackDurationSeconds(0.f), + iKeysoundIndex(-1), iDuration(0), pn(PLAYER_INVALID) { } TapNote( Type type_, SubType subType_, Source source_, RString sAttackModifiers_, float fAttackDurationSeconds_, - bool bKeysound_, int iKeysoundIndex_ ) { type = type_; @@ -135,7 +132,6 @@ struct TapNote source = source_; sAttackModifiers = sAttackModifiers_; fAttackDurationSeconds = fAttackDurationSeconds_; - bKeysound = bKeysound_; iKeysoundIndex = iKeysoundIndex_; iDuration = 0; pn = PLAYER_INVALID; @@ -148,13 +144,13 @@ struct TapNote COMPARE(source); COMPARE(sAttackModifiers); COMPARE(fAttackDurationSeconds); - COMPARE(bKeysound); COMPARE(iKeysoundIndex); COMPARE(iDuration); COMPARE(pn); #undef COMPARE return true; } + bool operator!=( const TapNote &other ) const { return !operator==( other ); } }; extern TapNote TAP_EMPTY; // '0' diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index eb48581012..64e5142e05 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -311,10 +311,7 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa TapNote tn = TAP_ORIGINAL_TAP; map::const_iterator it = m_mapWavIdToKeysoundIndex.find(sNoteId); if( it != m_mapWavIdToKeysoundIndex.end() ) - { - tn.bKeysound = true; tn.iKeysoundIndex = it->second; - } vTapNotes.push_back( tn ); } else diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 3717906666..223828b4fe 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -1267,7 +1267,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele if( iIndexOverlappingNote != -1 ) { const TapNote &tn = m_NoteData.GetTapNote( col, iIndexOverlappingNote ); - if( tn.bKeysound && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) + if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) m_vKeysounds[tn.iKeysoundIndex].Play(); } } @@ -1404,7 +1404,7 @@ void Player::UpdateJudgedRows() if( tn.pn != PLAYER_INVALID && tn.pn != pn ) continue; - if( tn.bKeysound && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) + if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) m_vKeysounds[tn.iKeysoundIndex].Play(); else m_soundMine.Play(); diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 0d64c5ed59..e59b683f67 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -2438,8 +2438,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) TapNote::original, sMods, g_fLastInsertAttackDurationSeconds, - false, - 0 ); + -1 ); tn.pn = m_InputPlayerNumber; SaveUndo(); m_NoteDataEdit.SetTapNote( g_iLastInsertTapAttackTrack, row, tn );