Remove unnecessary member. Just set iKeysoundIndex to -1 if it isn't valid.

This commit is contained in:
Steve Checkoway
2006-08-14 10:17:48 +00:00
parent 2f9bda2eea
commit 734f9760cc
7 changed files with 21 additions and 33 deletions
+3 -3
View File
@@ -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) );
+2 -6
View File
@@ -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 );
}
}
+9 -9
View File
@@ -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",
+4 -8
View File
@@ -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'
-3
View File
@@ -311,10 +311,7 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa
TapNote tn = TAP_ORIGINAL_TAP;
map<RString,int>::const_iterator it = m_mapWavIdToKeysoundIndex.find(sNoteId);
if( it != m_mapWavIdToKeysoundIndex.end() )
{
tn.bKeysound = true;
tn.iKeysoundIndex = it->second;
}
vTapNotes.push_back( tn );
}
else
+2 -2
View File
@@ -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();
+1 -2
View File
@@ -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 );