clean up NoteData

This commit is contained in:
Chris Danford
2003-02-01 05:16:38 +00:00
parent 6c272b6ba5
commit f4e8c4fb24
10 changed files with 67 additions and 53 deletions
+24 -13
View File
@@ -37,6 +37,17 @@ NoteData::~NoteData()
{
}
int NoteData::GetNumTracks()
{
return m_iNumTracks;
}
void NoteData::SetNumTracks( int iNewNumTracks )
{
m_iNumTracks = iNewNumTracks;
}
/* Clear [iNoteIndexBegin,iNoteIndexEnd]; that is, including iNoteIndexEnd. */
void NoteData::ClearRange( int iNoteIndexBegin, int iNoteIndexEnd )
{
@@ -566,9 +577,9 @@ NoteType NoteDataUtil::GetSmallestNoteTypeForMeasure( const NoteData &n, int iMe
void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData )
{
/* Clear notes, but keep the same number of tracks. */
int iNumTracks = out.m_iNumTracks;
int iNumTracks = out.GetNumTracks();
out.Init();
out.m_iNumTracks = iNumTracks;
out.SetNumTracks( iNumTracks );
// strip comments out of sSMNoteData
while( sSMNoteData.Find("//") != -1 )
@@ -611,7 +622,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData
// if( m_iNumTracks != sMeasureLine.GetLength() )
// RageException::Throw( "Actual number of note columns (%d) is different from the NotesType (%d).", m_iNumTracks, sMeasureLine.GetLength() );
for( int c=0; c<min(sMeasureLine.GetLength(),out.m_iNumTracks); c++ )
for( int c=0; c<min(sMeasureLine.GetLength(),out.GetNumTracks()); c++ )
{
TapNote t;
switch(sMeasureLine[c])
@@ -655,7 +666,7 @@ CString NoteDataUtil::GetSMNoteDataString(NoteData &in)
for( int r=iMeasureStartRow; r<=iMeasureLastRow; r+=iRowSpacing )
{
for( int t=0; t<in.m_iNumTracks; t++ ) {
for( int t=0; t<in.GetNumTracks(); t++ ) {
char c;
switch(in.GetTapNote(t, r)) {
case TAP_EMPTY: c = '0'; break;
@@ -783,8 +794,8 @@ void NoteDataUtil::Turn( NoteData &in, PlayerOptions::TurnType tt )
case PlayerOptions::TURN_NONE:
return; // nothing to do
case PlayerOptions::TURN_MIRROR:
for( t=0; t<in.m_iNumTracks; t++ )
iTakeFromTrack[t] = in.m_iNumTracks-t-1;
for( t=0; t<in.GetNumTracks(); t++ )
iTakeFromTrack[t] = in.GetNumTracks()-t-1;
break;
case PlayerOptions::TURN_LEFT:
case PlayerOptions::TURN_RIGHT: // HACK: TurnRight does the same thing as TurnLeft. I'll fix this later...
@@ -859,10 +870,10 @@ void NoteDataUtil::Turn( NoteData &in, PlayerOptions::TurnType tt )
case PlayerOptions::TURN_SUPER_SHUFFLE: // use this code to shuffle the HoldNotes
{
vector<int> aiTracksLeftToMap;
for( t=0; t<in.m_iNumTracks; t++ )
for( t=0; t<in.GetNumTracks(); t++ )
aiTracksLeftToMap.push_back( t );
for( t=0; t<in.m_iNumTracks; t++ )
for( t=0; t<in.GetNumTracks(); t++ )
{
int iRandTrackIndex = rand()%aiTracksLeftToMap.size();
int iRandTrack = aiTracksLeftToMap[iRandTrackIndex];
@@ -885,7 +896,7 @@ void NoteDataUtil::Turn( NoteData &in, PlayerOptions::TurnType tt )
// transform notes
int max_row = in.GetLastRow();
for( t=0; t<in.m_iNumTracks; t++ )
for( t=0; t<in.GetNumTracks(); t++ )
for( int r=0; r<=max_row; r++ )
tempNoteData.SetTapNote(t, r, in.GetTapNote(iTakeFromTrack[t], r));
@@ -919,11 +930,11 @@ void NoteDataUtil::Turn( NoteData &in, PlayerOptions::TurnType tt )
// shuffle this row
vector<int> aiTracksThatCouldHaveTapNotes;
for( t=0; t<in.m_iNumTracks; t++ )
for( t=0; t<in.GetNumTracks(); t++ )
if( in.GetTapNote(t, r) != TAP_HOLD ) // any point that isn't part of a hold
aiTracksThatCouldHaveTapNotes.push_back( t );
for( t=0; t<in.m_iNumTracks; t++ )
for( t=0; t<in.GetNumTracks(); t++ )
{
if( in.GetTapNote(t, r) != TAP_HOLD && in.GetTapNote(t, r) != TAP_EMPTY ) // there is a tap note here (and not a HoldNote)
{
@@ -950,7 +961,7 @@ void NoteDataUtil::MakeLittle(NoteData &in)
if( i%ROWS_PER_BEAT != 0 )
{
// filter out all non-quarter notes
for( int c=0; c<in.m_iNumTracks; c++ )
for( int c=0; c<in.GetNumTracks(); c++ )
{
in.SetTapNote(c, i, TAP_EMPTY);
}
@@ -1001,7 +1012,7 @@ void NoteDataUtil::SnapToNearestNoteType( NoteData &in, NoteType nt1, NoteType n
float fNewBeat = bNewBeat1IsCloser ? fNewBeat1 : fNewBeat2;
int iNewIndex = BeatToNoteRow( fNewBeat );
for( int c=0; c<in.m_iNumTracks; c++ )
for( int c=0; c<in.GetNumTracks(); c++ )
{
TapNote note = in.GetTapNote(c, iOldIndex);
in.SetTapNote(c, iOldIndex, TAP_EMPTY);
+5 -2
View File
@@ -27,6 +27,8 @@ class NoteData
{
/* Keep this aligned, so that they all have the same size. */
vector<TapNote> m_TapNotes[MAX_NOTE_TRACKS];
int m_iNumTracks;
vector<HoldNote> m_HoldNotes;
/* Pad m_TapNotes so it includes the row "rows". */
@@ -37,12 +39,13 @@ public:
* divisor. Doesn't allocate or copy anything. */
void Config( const NoteData &From );
int m_iNumTracks;
NoteData();
~NoteData();
void Init();
int GetNumTracks();
void SetNumTracks( int iNewNumTracks );
/* 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, unsigned row) const
+3 -3
View File
@@ -39,7 +39,7 @@ int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float
for( unsigned i=iStartIndex; i<min(iEndIndex, m_TapNoteScores[0].size()); i++ )
{
for( int t=0; t<m_iNumTracks; t++ )
for( int t=0; t<GetNumTracks(); t++ )
{
if( this->GetTapNote(t, i) != TAP_EMPTY && GetTapNoteScore(t, i) == tns )
iNumSuccessfulTapNotes++;
@@ -60,7 +60,7 @@ int NoteDataWithScoring::GetNumDoublesWithScore( TapNoteScore tns, const float f
{
int iNumNotesThisIndex = 0;
TapNoteScore minTapNoteScore = TNS_MARVELOUS;
for( int t=0; t<m_iNumTracks; t++ )
for( int t=0; t<GetNumTracks(); t++ )
{
if( GetTapNote(t, i) != TAP_EMPTY )
{
@@ -90,7 +90,7 @@ int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const floa
bool NoteDataWithScoring::IsRowComplete( int index )
{
for( int t=0; t<m_iNumTracks; t++ )
for( int t=0; t<GetNumTracks(); t++ )
if( GetTapNote(t, index) != TAP_EMPTY && GetTapNoteScore(t, index) < TNS_GREAT )
return false;
return true;
+7 -7
View File
@@ -61,10 +61,10 @@ void NoteField::Load( NoteData* pNoteData, PlayerNumber pn, int iFirstPixelToDra
this->CopyAll( pNoteData );
// init note displays
for( int c=0; c<m_iNumTracks; c++ )
for( int c=0; c<GetNumTracks(); c++ )
m_NoteDisplay[c].Load( c, pn );
ASSERT( m_iNumTracks == GAMESTATE->GetCurrentStyleDef()->m_iColsPerPlayer );
ASSERT( GetNumTracks() == GAMESTATE->GetCurrentStyleDef()->m_iColsPerPlayer );
}
void NoteField::Update( float fDeltaTime )
@@ -84,7 +84,7 @@ void NoteField::DrawMeasureBar( int iMeasureIndex )
const float fYPos = ArrowGetYPos( m_PlayerNumber, fYOffset );
m_rectMeasureBar.SetXY( 0, fYPos );
m_rectMeasureBar.SetZoomX( (float)(m_iNumTracks+1) * ARROW_SIZE );
m_rectMeasureBar.SetZoomX( (float)(GetNumTracks()+1) * ARROW_SIZE );
m_rectMeasureBar.SetZoomY( 20 );
m_rectMeasureBar.SetDiffuse( RageColor(0,0,0,0.5f) );
m_rectMeasureBar.Draw();
@@ -102,7 +102,7 @@ void NoteField::DrawMarkerBar( const float fBeat )
const float fYPos = ArrowGetYPos( m_PlayerNumber, fYOffset );
m_rectMarkerBar.SetXY( 0, fYPos );
m_rectMarkerBar.SetZoomX( (float)(m_iNumTracks+1) * ARROW_SIZE );
m_rectMarkerBar.SetZoomX( (float)(GetNumTracks()+1) * ARROW_SIZE );
m_rectMarkerBar.SetZoomY( 20 );
m_rectMarkerBar.SetDiffuse( RageColor(0,0,0,0.5f) );
m_rectMarkerBar.Draw();
@@ -249,7 +249,7 @@ void NoteField::DrawPrimitives()
// draw in big batches.
//
for( int c=0; c<m_iNumTracks; c++ ) // for each arrow column
for( int c=0; c<GetNumTracks(); c++ ) // for each arrow column
{
/////////////////////////////////
// Draw all HoldNotes in this column (so that they appear under the tap notes)
@@ -295,7 +295,7 @@ void NoteField::DrawPrimitives()
// See if there is a hold step that begins on this index.
bool bHoldNoteBeginsOnThisBeat = false;
for( int c2=0; c2<m_iNumTracks; c2++ )
for( int c2=0; c2<GetNumTracks(); c2++ )
{
if( GetTapNote(c2, i) == TAP_HOLD_HEAD )
{
@@ -313,7 +313,7 @@ void NoteField::DrawPrimitives()
void NoteField::RemoveTapNoteRow( int iIndex )
{
for( int c=0; c<m_iNumTracks; c++ )
for( int c=0; c<GetNumTracks(); c++ )
SetTapNote(c, iIndex, TAP_EMPTY);
}
+8 -8
View File
@@ -64,7 +64,7 @@ Notes::~Notes()
void Notes::SetNoteData( NoteData* pNewNoteData )
{
ASSERT( pNewNoteData->m_iNumTracks == GameManager::NotesTypeToNumTracks(m_NotesType) );
ASSERT( pNewNoteData->GetNumTracks() == GameManager::NotesTypeToNumTracks(m_NotesType) );
DeAutogen();
@@ -80,7 +80,7 @@ void Notes::GetNoteData( NoteData* pNoteDataOut ) const
ASSERT(this);
ASSERT(pNoteDataOut);
Decompress();
pNoteDataOut->m_iNumTracks = notes->m_iNumTracks;
pNoteDataOut->SetNumTracks( notes->GetNumTracks() );
*pNoteDataOut = *notes;
}
@@ -218,11 +218,11 @@ void Notes::Decompress() const
parent->GetNoteData(&pdata);
notes = new NoteData;
notes->m_iNumTracks = GameManager::NotesTypeToNumTracks(m_NotesType);
if(pdata.m_iNumTracks == notes->m_iNumTracks)
notes->SetNumTracks( GameManager::NotesTypeToNumTracks(m_NotesType) );
if(pdata.GetNumTracks() == notes->GetNumTracks())
notes->CopyRange( &pdata, 0, pdata.GetLastRow(), 0 );
else
notes->LoadTransformedSlidingWindow( &pdata, notes->m_iNumTracks );
notes->LoadTransformedSlidingWindow( &pdata, notes->GetNumTracks() );
return;
}
@@ -230,7 +230,7 @@ void Notes::Decompress() const
if(!notes_comp) return; /* no data is no data */
notes = new NoteData;
notes->m_iNumTracks = GameManager::NotesTypeToNumTracks(m_NotesType);
notes->SetNumTracks( GameManager::NotesTypeToNumTracks(m_NotesType) );
NoteDataUtil::LoadFromSMNoteDataString(*notes, *notes_comp);
}
@@ -298,7 +298,7 @@ void Notes::CopyFrom( Notes* pSource, NotesType ntTo ) // pSource does not have
m_NotesType = ntTo;
NoteData noteData;
pSource->GetNoteData( &noteData );
noteData.m_iNumTracks = GameManager::NotesTypeToNumTracks(ntTo);
noteData.SetNumTracks( GameManager::NotesTypeToNumTracks(ntTo) );
this->SetNoteData( &noteData );
this->SetDescription( "Copied from "+pSource->GetDescription() );
this->SetDifficulty( pSource->GetDifficulty() );
@@ -313,7 +313,7 @@ void Notes::CreateBlank( NotesType ntTo )
{
m_NotesType = ntTo;
NoteData noteData;
noteData.m_iNumTracks = GameManager::NotesTypeToNumTracks(ntTo);
noteData.SetNumTracks( GameManager::NotesTypeToNumTracks(ntTo) );
this->SetNoteData( &noteData );
}
+2 -2
View File
@@ -65,7 +65,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out )
out.m_NotesType = NOTES_TYPE_INVALID;
NoteData* pNoteData = new NoteData;
pNoteData->m_iNumTracks = MAX_NOTE_TRACKS;
pNoteData->SetNumTracks( MAX_NOTE_TRACKS );
ifstream file(sPath);
if( file.bad() )
@@ -230,7 +230,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out )
}
NoteData* pNoteData2 = new NoteData;
pNoteData2->m_iNumTracks = iNumNewTracks;
pNoteData2->SetNumTracks( iNumNewTracks );
pNoteData2->LoadTransformed( pNoteData, iNumNewTracks, iTransformNewToOld );
out.SetNoteData(pNoteData2);
+2 -2
View File
@@ -130,7 +130,7 @@ bool DWILoader::LoadFromDWITokens(
NoteData* pNoteData = new NoteData;
ASSERT( pNoteData );
pNoteData->m_iNumTracks = mapDanceNoteToNoteDataColumn.size();
pNoteData->SetNumTracks( mapDanceNoteToNoteDataColumn.size() );
for( int pad=0; pad<2; pad++ ) // foreach pad
{
@@ -236,7 +236,7 @@ bool DWILoader::LoadFromDWITokens(
// this will expand the HoldNote begin markers we wrote into actual HoldNotes
pNoteData->Convert2sAnd3sToHoldNotes();
ASSERT( pNoteData->m_iNumTracks > 0 );
ASSERT( pNoteData->GetNumTracks() > 0 );
out.SetNoteData(pNoteData);
+4 -4
View File
@@ -75,14 +75,14 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Notes &out )
if(!out.GetMeter()) out.SetMeter(5);
}
notedata.m_iNumTracks = 5;
notedata.SetNumTracks( 5 );
out.m_NotesType = NOTES_TYPE_PUMP_SINGLE;
if( sFName.Find("double") != -1 )
{
notedata.m_iNumTracks = 10;
notedata.SetNumTracks( 10 );
out.m_NotesType = NOTES_TYPE_PUMP_DOUBLE;
} else if( sFName.Find("_2") != -1 ) {
notedata.m_iNumTracks = 10;
notedata.SetNumTracks( 10 );
out.m_NotesType = NOTES_TYPE_PUMP_COUPLE;
}
}
@@ -112,7 +112,7 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Notes &out )
// the length of a note in a row depends on TICKCOUNT
float fBeatThisRow = r/(float)iTickCount;
int row = BeatToNoteRow(fBeatThisRow);
for( int t=0; t < notedata.m_iNumTracks; t++ )
for( int t=0; t < notedata.GetNumTracks(); t++ )
{
if( sRowString[t] == '4' )
{
+7 -7
View File
@@ -335,7 +335,7 @@ void Player::DrawPrimitives()
m_frameJudgement.Draw();
for( int c=0; c<m_iNumTracks; c++ )
for( int c=0; c<GetNumTracks(); c++ )
m_HoldJudgement[c].Draw();
}
@@ -346,7 +346,7 @@ void Player::Step( int col )
//LOG->Trace( "Player::HandlePlayerStep()" );
ASSERT( col >= 0 && col <= m_iNumTracks );
ASSERT( col >= 0 && col <= GetNumTracks() );
const float fSongBeat = GAMESTATE->m_fSongBeat;
@@ -447,7 +447,7 @@ void Player::Step( int col )
if (score > TNS_NONE) {
bool bRowDestroyed = true;
for( int t=0; t<m_iNumTracks; t++ ) // did this complete the elimination of the row?
for( int t=0; t<GetNumTracks(); t++ ) // did this complete the elimination of the row?
{
if( GetTapNote(t, iIndexOverlappingNote) != TAP_EMPTY && // there is a note here
GetTapNoteScore(t, iIndexOverlappingNote) == TNS_NONE ) // and it doesn't have a score
@@ -471,7 +471,7 @@ void Player::OnRowDestroyed( int iIndexThatWasSteppedOn )
// find the minimum score of the row
TapNoteScore score = TNS_MARVELOUS;
for( int t=0; t<m_iNumTracks; t++ )
for( int t=0; t<GetNumTracks(); t++ )
{
TapNoteScore tns = GetTapNoteScore(t, iIndexThatWasSteppedOn);
if( tns >= TNS_BOO )
@@ -502,7 +502,7 @@ void Player::OnRowDestroyed( int iIndexThatWasSteppedOn )
}
int iNumNotesInThisRow = 0;
for( int c=0; c<m_iNumTracks; c++ ) // for each column
for( int c=0; c<GetNumTracks(); c++ ) // for each column
{
if( GetTapNote(c, iIndexThatWasSteppedOn) != TAP_EMPTY ) // if there is a note in this col
{
@@ -565,7 +565,7 @@ int Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat )
for( int r=iStartCheckingAt; r<iMissIfOlderThanThisIndex; r++ )
{
int iNumMissesThisRow = 0;
for( int t=0; t<m_iNumTracks; t++ )
for( int t=0; t<GetNumTracks(); t++ )
{
if( GetTapNote(t, r) != TAP_EMPTY && GetTapNoteScore(t, r) == TNS_NONE )
{
@@ -595,7 +595,7 @@ void Player::CrossedRow( int iNoteRow )
if( PREFSMAN->m_bAutoPlay || GAMESTATE->m_bDemonstration )
{
// check to see if there's at the crossed row
for( int t=0; t<m_iNumTracks; t++ )
for( int t=0; t<GetNumTracks(); t++ )
{
if( GetTapNote(t, iNoteRow) != TAP_EMPTY )
this->Step( t );
+5 -5
View File
@@ -249,7 +249,7 @@ ScreenEdit::ScreenEdit()
m_NoteFieldRecord.SetZoom( 1.0f );
m_NoteFieldRecord.Load( &noteData, PLAYER_1, -150, 350 );
m_Clipboard.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks;
m_Clipboard.SetNumTracks( m_NoteFieldEdit.GetNumTracks() );
m_Player.Load( PLAYER_1, &noteData, NULL, NULL );
m_Player.SetXY( PLAYER_X, PLAYER_Y );
@@ -715,7 +715,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
const float fSongBeat = GAMESTATE->m_fSongBeat;
const int iSongIndex = BeatToNoteRow( fSongBeat );
if( iCol >= m_NoteFieldEdit.m_iNumTracks ) // this button is not in the range of columns for this StyleDef
if( iCol >= m_NoteFieldEdit.GetNumTracks() ) // this button is not in the range of columns for this StyleDef
break;
/* XXX: easier to do with 4s */
@@ -784,7 +784,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
const float fEndBeat = GAMESTATE->m_fSongBeat + fBeatsToMove;
// check to see if they're holding a button
for( int col=0; col<m_NoteFieldEdit.m_iNumTracks && col<=10; col++ )
for( int col=0; col<m_NoteFieldEdit.GetNumTracks() && col<=10; col++ )
{
const DeviceInput di(DEVICE_KEYBOARD, SDLK_1+col);
@@ -937,7 +937,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
// initialize m_NoteFieldRecord
m_NoteFieldRecord.ClearAll();
m_NoteFieldRecord.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks;
m_NoteFieldRecord.SetNumTracks( m_NoteFieldEdit.GetNumTracks() );
m_NoteFieldRecord.m_fBeginMarker = m_NoteFieldEdit.m_fBeginMarker;
m_NoteFieldRecord.m_fEndMarker = m_NoteFieldEdit.m_fEndMarker;
@@ -973,7 +973,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
case SDLK_DELETE:
{
NoteData temp;
temp.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks;
temp.SetNumTracks( m_NoteFieldEdit.GetNumTracks() );
int iTakeFromRow=0;
int iPasteAtRow;
switch( DeviceI.button )