fix up soft shuffle to not use a goto

This commit is contained in:
AJ Kelly
2010-07-04 15:10:51 -05:00
parent b0ddb50a43
commit a7da3658d1
+28 -42
View File
@@ -132,13 +132,13 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
}
*/
/* Set the hold note to have infinite length. We'll clamp it when
* we hit the tail. */
/* Set the hold note to have infinite length. We'll clamp
* it when we hit the tail. */
tn.iDuration = MAX_NOTE_ROW;
break;
case '3':
{
/* This is the end of a hold. Search for the beginning. */
// This is the end of a hold. Search for the beginning.
int iHeadRow;
if( !out.IsHoldNoteAtRow( iTrack, iIndex, &iHeadRow ) )
{
@@ -150,7 +150,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
out.FindTapNote( iTrack, iHeadRow )->second.iDuration = iIndex - iHeadRow;
}
/* This won't write tn, but keep parsing normally anyway. */
// This won't write tn, but keep parsing normally anyway.
break;
}
// case 'm':
@@ -245,7 +245,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
}
}
/* Make sure we don't have any hold notes that didn't find a tail. */
// Make sure we don't have any hold notes that didn't find a tail.
for( int t=0; t<out.GetNumTracks(); t++ )
{
NoteData::iterator begin = out.begin( t );
@@ -264,14 +264,11 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
begin = next;
}
}
}
void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, const RString &sSMNoteData_, bool bComposite )
{
//
// Load note data
//
RString sSMNoteData;
RString::size_type iIndexCommentStart = 0;
RString::size_type iIndexCommentEnd = 0;
@@ -289,7 +286,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, const RString &sSMNo
}
sSMNoteData.append( p, origSize - iIndexCommentEnd );
/* Clear notes, but keep the same number of tracks. */
// Clear notes, but keep the same number of tracks.
int iNumTracks = out.GetNumTracks();
out.Init();
out.SetNumTracks( iNumTracks );
@@ -346,9 +343,7 @@ void NoteDataUtil::InsertHoldTails( NoteData &inout )
void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
{
//
// Get note data
//
vector<NoteData> parts;
float fLastBeat = -1.0f;
@@ -420,7 +415,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
sRet.append( ssprintf("{%s:%.2f}", tn.sAttackModifiers.c_str(),
tn.fAttackDurationSeconds) );
}
// hey maybe if we have TapNote::item we can do shit here.
// hey maybe if we have TapNote::item we can do things here.
if( tn.iKeysoundIndex >= 0 )
sRet.append( ssprintf("[%d]",tn.iKeysoundIndex) );
}
@@ -490,7 +485,7 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o
if( in.GetNumTracks() > iNewNumTracks )
{
/* Use a different algorithm for reducing tracks. */
// Use a different algorithm for reducing tracks.
LoadOverlapped( in, out, iNewNumTracks );
return;
}
@@ -581,7 +576,7 @@ void NoteDataUtil::LoadOverlapped( const NoteData &in, NoteData &out, int iNewNu
if( tnFrom.type == TapNote::empty )
continue;
/* If this is a hold note, find the end. */
// If this is a hold note, find the end.
int iEndIndex = row;
if( tnFrom.type == TapNote::hold_head )
iEndIndex = row + tnFrom.iDuration;
@@ -591,14 +586,14 @@ void NoteDataUtil::LoadOverlapped( const NoteData &in, NoteData &out, int iNewNu
{
if( iEndIndex - LastSourceRow[iTrackTo] < ShiftThreshold )
{
/* This destination track is in use by a different source track. Use the
* least-recently-used track. */
/* This destination track is in use by a different source
* track. Use the least-recently-used track. */
for( int DestTrack = 0; DestTrack < iNewNumTracks; ++DestTrack )
if( LastSourceRow[DestTrack] < LastSourceRow[iTrackTo] )
iTrackTo = DestTrack;
}
/* If it's still in use, then we just don't have an available track. */
// If it's still in use, then we just don't have an available track.
if( iEndIndex - LastSourceRow[iTrackTo] < ShiftThreshold )
continue;
}
@@ -631,7 +626,7 @@ int FindLongestOverlappingHoldNoteForAnyTrack( const NoteData &in, int iRow )
return iMaxTailRow;
}
/* For every row in "in" with a tap or hold on any track, enable the specified tracks in "out". */
// For every row in "in" with a tap or hold on any track, enable the specified tracks in "out".
void LightTransformHelper( const NoteData &in, NoteData &out, const vector<int> &aiTracks )
{
for( unsigned i = 0; i < aiTracks.size(); ++i )
@@ -654,7 +649,7 @@ void LightTransformHelper( const NoteData &in, NoteData &out, const vector<int>
if( iHoldEnd != -1 )
{
/* If we found a hold note, add it to all tracks. */
// If we found a hold note, add it to all tracks.
for( unsigned i = 0; i < aiTracks.size(); ++i )
{
int t = aiTracks[i];
@@ -666,7 +661,7 @@ void LightTransformHelper( const NoteData &in, NoteData &out, const vector<int>
if( in.IsRowEmpty(r) )
continue;
/* Enable every track in the output. */
// Enable every track in the output.
for( unsigned i = 0; i < aiTracks.size(); ++i )
{
int t = aiTracks[i];
@@ -675,7 +670,7 @@ void LightTransformHelper( const NoteData &in, NoteData &out, const vector<int>
}
}
/* For every track enabled in "in", enable all tracks in "out". */
// For every track enabled in "in", enable all tracks in "out".
void NoteDataUtil::LoadTransformedLights( const NoteData &in, NoteData &out, int iNewNumTracks )
{
// reset all notes
@@ -690,15 +685,15 @@ void NoteDataUtil::LoadTransformedLights( const NoteData &in, NoteData &out, int
LightTransformHelper( in, out, aiTracks );
}
/* This transform is specific to StepsType_lights_cabinet. */
// This transform is specific to StepsType_lights_cabinet.
#include "LightsManager.h" // for LIGHT_*
void NoteDataUtil::LoadTransformedLightsFromTwo( const NoteData &marquee, const NoteData &bass, NoteData &out )
{
ASSERT( marquee.GetNumTracks() >= 4 );
ASSERT( bass.GetNumTracks() >= 1 );
/* For each track in "marquee", enable a track in the marquee lights. This will
* reinit out. */
/* For each track in "marquee", enable a track in the marquee lights.
* This will reinit out. */
{
NoteData transformed_marquee;
transformed_marquee.CopyAll( marquee );
@@ -708,7 +703,7 @@ void NoteDataUtil::LoadTransformedLightsFromTwo( const NoteData &marquee, const
out.LoadTransformed( transformed_marquee, NUM_CabinetLight, iOriginalTrackToTakeFrom );
}
/* For each track in "bass", enable the bass lights. */
// For each track in "bass", enable the bass lights.
{
vector<int> aiTracks;
aiTracks.push_back( LIGHT_BASS_LEFT );
@@ -716,7 +711,7 @@ void NoteDataUtil::LoadTransformedLightsFromTwo( const NoteData &marquee, const
LightTransformHelper( bass, out, aiTracks );
}
/* Delete all mines. */
// Delete all mines.
NoteDataUtil::RemoveMines( out );
}
@@ -1005,7 +1000,6 @@ void NoteDataUtil::RemoveAllButPlayer( NoteData &inout, PlayerNumber pn )
}
}
static void GetTrackMapping( StepsType st, NoteDataUtil::TrackMapping tt, int NumTracks, int *iTakeFromTrack )
{
// Identity transform for cases not handled below.
@@ -1078,7 +1072,7 @@ static void GetTrackMapping( StepsType st, NoteDataUtil::TrackMapping tt, int Nu
if( tt == NoteDataUtil::right )
{
/* Invert. */
// Invert.
int iTrack[MAX_NOTE_TRACKS];
memcpy( iTrack, iTakeFromTrack, sizeof(iTrack) );
for( int t = 0; t < MAX_NOTE_TRACKS; ++t )
@@ -1090,7 +1084,6 @@ static void GetTrackMapping( StepsType st, NoteDataUtil::TrackMapping tt, int Nu
break;
case NoteDataUtil::mirror:
mirror_all:
for( int t=0; t<NumTracks; t++ )
iTakeFromTrack[t] = NumTracks-t-1;
break;
@@ -1118,8 +1111,7 @@ mirror_all:
// soft shuffle, as described at
// http://www.stepmania.com/forums/showthread.php?t=19469
/*
* one of the following at random:
/* one of the following at random:
*
* 0. No columns changed
* 1. Left and right columns swapped
@@ -1133,8 +1125,7 @@ mirror_all:
* horizontal, vertical,
* diagonally top left to bottom right,
* diagonally bottom left to top right.
* (above text from forums)
*/
* (above text from forums) */
// TRICKY: Shuffle so that both player get the same shuffle mapping
// in the same round.
@@ -1146,10 +1137,8 @@ mirror_all:
// XXX: cases 1 and 2 only implemented for dance_*
switch( iRandChoice )
{
case 1:
// left and right mirror
case 2:
// up and down mirror
case 1: // left and right mirror
case 2: // up and down mirror
switch( st )
{
case StepsType_dance_single:
@@ -1231,9 +1220,8 @@ mirror_all:
default: break;
}
break;
case 3:
// full mirror
goto mirror_all;
case 3: // full mirror
GetTrackMapping( st, NoteDataUtil::mirror, NumTracks, iTakeFromTrack );
break;
case 0:
default:
@@ -1657,10 +1645,8 @@ TrackIterator::TrackIterator()
void NoteDataUtil::AddMines( NoteData &inout, int iStartIndex, int iEndIndex )
{
//
// Change whole rows at a time to be tap notes. Otherwise, it causes
// major problems for our scoring system. -Chris
//
int iRowCount = 0;
int iPlaceEveryRows = 6;