Style cleanup.

This commit is contained in:
Steve Checkoway
2006-08-15 09:54:48 +00:00
parent 7eeccfa412
commit 9d3538d89d
+75 -70
View File
@@ -13,41 +13,42 @@
#include "RageUtil_CharConversions.h" #include "RageUtil_CharConversions.h"
#include "NoteTypes.h" #include "NoteTypes.h"
/* BMS encoding: tap-hold /* BMS encoding: tap-hold
4&8panel: Player1 Player2 * 4&8panel: Player1 Player2
Left 11-51 21-61 * Left 11-51 21-61
Down 13-53 23-63 * Down 13-53 23-63
Up 15-55 25-65 * Up 15-55 25-65
Right 16-56 26-66 * Right 16-56 26-66
*
6panel: Player1 * 6panel: Player1
Left 11-51 * Left 11-51
Left+Up 12-52 * Left+Up 12-52
Down 13-53 * Down 13-53
Up 14-54 * Up 14-54
Up+Right 15-55 * Up+Right 15-55
Right 16-56 * Right 16-56
*
Notice that 15 and 25 have double meanings! What were they thinking??? * Notice that 15 and 25 have double meanings! What were they thinking???
While reading in, use the 6 panel mapping. After reading in, detect if * While reading in, use the 6 panel mapping. After reading in, detect if
only 4 notes are used. If so, shift the Up+Right column back to the Up * only 4 notes are used. If so, shift the Up+Right column back to the Up
column * column
*
BMSes are used for games besides dance and so we're borking up BMSes that are for popn/beat/etc. * BMSes are used for games besides dance and so we're borking up BMSes that are for popn/beat/etc.
*
popn-nine: 11-15,22-25 * popn-nine: 11-15,22-25
popn-five: 13-15,21-22 * popn-five: 13-15,21-22
beat-single5: 11-16 * beat-single5: 11-16
beat-double5: 11-16,21-26 * beat-double5: 11-16,21-26
beat-single7: 11-16,18-19 * beat-single7: 11-16,18-19
beat-double7: 11-16,18-19,21-26,28-29 * beat-double7: 11-16,18-19,21-26,28-29
*
So the magics for these are: * So the magics for these are:
popn-nine: nothing >5, with 12, 14, 22 and/or 24 * popn-nine: nothing >5, with 12, 14, 22 and/or 24
popn-five: nothing >5, with 14 and/or 22 * popn-five: nothing >5, with 14 and/or 22
beat-*: can't tell difference between beat-single and dance-solo * beat-*: can't tell difference between beat-single and dance-solo
18/19 marks beat-single7, 28/29 marks beat-double7 * 18/19 marks beat-single7, 28/29 marks beat-double7
beat-double uses 21-26. */ * beat-double uses 21-26.
*/
enum BmsTrack enum BmsTrack
{ {
@@ -96,7 +97,7 @@ static bool ConvertRawTrackToTapNote( int iRawTrack, BmsTrack &bmsTrackOut, bool
switch( iRawTrack ) switch( iRawTrack )
{ {
case 1: bmsTrackOut = BMS_AUTO_KEYSOUND_1; break; case 1: bmsTrackOut = BMS_AUTO_KEYSOUND_1; break;
case 11: bmsTrackOut = BMS_P1_KEY1; break; case 11: bmsTrackOut = BMS_P1_KEY1; break;
case 12: bmsTrackOut = BMS_P1_KEY2; break; case 12: bmsTrackOut = BMS_P1_KEY2; break;
case 13: bmsTrackOut = BMS_P1_KEY3; break; case 13: bmsTrackOut = BMS_P1_KEY3; break;
@@ -120,7 +121,7 @@ static bool ConvertRawTrackToTapNote( int iRawTrack, BmsTrack &bmsTrackOut, bool
} }
// Find the largest common substring at the start of both strings. // Find the largest common substring at the start of both strings.
static RString FindLargestInitialSubstring( RString string1, RString string2 ) static RString FindLargestInitialSubstring( const RString &string1, const RString &string2 )
{ {
// First see if the whole first string matches an appropriately-sized // First see if the whole first string matches an appropriately-sized
// substring of the second, then keep chopping off the last character of // substring of the second, then keep chopping off the last character of
@@ -130,7 +131,7 @@ static RString FindLargestInitialSubstring( RString string1, RString string2 )
if( string1[i] != string2[i] ) if( string1[i] != string2[i] )
break; break;
return string1.substr(0,i); return string1.substr( 0, i );
} }
static StepsType DetermineStepsType( int iPlayer, const NoteData &nd ) static StepsType DetermineStepsType( int iPlayer, const NoteData &nd )
@@ -160,13 +161,13 @@ static StepsType DetermineStepsType( int iPlayer, const NoteData &nd )
switch( iPlayer ) switch( iPlayer )
{ {
case 1: // "1 player" case 1: // "1 player"
/* Track counts: /* Track counts:
4 - dance 4-panel * 4 - dance 4-panel
5 - pop 5-key * 5 - pop 5-key
6 - dance 6-panel, beat 5-key * 6 - dance 6-panel, beat 5-key
8 - beat 7-key * 8 - beat 7-key
9 - popn 9-key */ * 9 - popn 9-key */
switch( iNumNonEmptyTracks ) switch( iNumNonEmptyTracks )
{ {
case 4: return STEPS_TYPE_DANCE_SINGLE; case 4: return STEPS_TYPE_DANCE_SINGLE;
@@ -181,13 +182,13 @@ static StepsType DetermineStepsType( int iPlayer, const NoteData &nd )
case 9: return STEPS_TYPE_POPN_NINE; case 9: return STEPS_TYPE_POPN_NINE;
default: return STEPS_TYPE_INVALID; default: return STEPS_TYPE_INVALID;
} }
case 2: // couple/battle case 2: // couple/battle
return STEPS_TYPE_DANCE_COUPLE; return STEPS_TYPE_DANCE_COUPLE;
case 3: // double case 3: // double
/* Track counts: /* Track counts:
8 - dance Double * 8 - dance Double
12 - beat Double 5-key * 12 - beat Double 5-key
16 - beat Double 7-key */ * 16 - beat Double 7-key */
switch( iNumNonEmptyTracks ) switch( iNumNonEmptyTracks )
{ {
case 8: return STEPS_TYPE_BEAT_SINGLE7; case 8: return STEPS_TYPE_BEAT_SINGLE7;
@@ -207,15 +208,11 @@ float BMSLoader::GetBeatsPerMeasure( const MeasureToTimeSig_t &sigs, int iMeasur
float fRet = 4.0f; float fRet = 4.0f;
if( time_sig != sigs.end() ) if( time_sig != sigs.end() )
{
fRet *= time_sig->second; fRet *= time_sig->second;
}
time_sig = m_TimeSigAdjustments.find( iMeasure ); time_sig = m_TimeSigAdjustments.find( iMeasure );
if( time_sig != m_TimeSigAdjustments.end() ) if( time_sig != m_TimeSigAdjustments.end() )
{
fRet *= time_sig->second; fRet *= time_sig->second;
}
return fRet; return fRet;
} }
@@ -292,7 +289,7 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa
for( it = mapNameToData.lower_bound("#00000"); it != mapNameToData.end(); ++it ) for( it = mapNameToData.lower_bound("#00000"); it != mapNameToData.end(); ++it )
{ {
const RString &sName = it->first; const RString &sName = it->first;
if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) ) if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1, 5) ) )
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
@@ -305,11 +302,11 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa
vector<TapNote> vTapNotes; vector<TapNote> vTapNotes;
for( size_t i=0; i+1<sNoteData.size(); i+=2 ) for( size_t i=0; i+1<sNoteData.size(); i+=2 )
{ {
RString sNoteId = sNoteData.substr(i,2); RString sNoteId = sNoteData.substr( i, 2 );
if( sNoteId != "00" ) if( sNoteId != "00" )
{ {
TapNote tn = TAP_ORIGINAL_TAP; TapNote tn = TAP_ORIGINAL_TAP;
map<RString,int>::const_iterator it = m_mapWavIdToKeysoundIndex.find(sNoteId); map<RString,int>::const_iterator it = m_mapWavIdToKeysoundIndex.find( sNoteId );
if( it != m_mapWavIdToKeysoundIndex.end() ) if( it != m_mapWavIdToKeysoundIndex.end() )
tn.iKeysoundIndex = it->second; tn.iKeysoundIndex = it->second;
vTapNotes.push_back( tn ); vTapNotes.push_back( tn );
@@ -344,7 +341,7 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa
// shift the auto keysound as far right as possible // shift the auto keysound as far right as possible
int iLastEmptyTrack = -1; int iLastEmptyTrack = -1;
if( ndNotes.GetTapLastEmptyTrack(row,iLastEmptyTrack) && if( ndNotes.GetTapLastEmptyTrack(row, iLastEmptyTrack) &&
iLastEmptyTrack >= BMS_AUTO_KEYSOUND_1 ) iLastEmptyTrack >= BMS_AUTO_KEYSOUND_1 )
{ {
bmsTrack = (BmsTrack)iLastEmptyTrack; bmsTrack = (BmsTrack)iLastEmptyTrack;
@@ -524,13 +521,13 @@ bool BMSLoader::ReadBMSFile( const RString &sPath, NameToData_t &mapNameToData )
while( !file.AtEOF() ) while( !file.AtEOF() )
{ {
RString line; RString line;
if( file.GetLine( line ) == -1 ) if( file.GetLine(line) == -1 )
{ {
LOG->Warn( "Error reading \"%s\": %s", sPath.c_str(), file.GetError().c_str() ); LOG->Warn( "Error reading \"%s\": %s", sPath.c_str(), file.GetError().c_str() );
return false; return false;
} }
StripCrnl(line); StripCrnl( line );
// BMS value names can be separated by a space or a colon. // BMS value names can be separated by a space or a colon.
size_t iIndexOfSeparator = line.find_first_of( ": " ); size_t iIndexOfSeparator = line.find_first_of( ": " );
@@ -575,7 +572,9 @@ bool BMSLoader::GetCommonTagFromMapList( const vector<NameToData_t> &aBMSData, c
sCommonTag = sTag; sCommonTag = sTag;
} }
else else
{
sCommonTag = FindLargestInitialSubstring( sCommonTag, sTag ); sCommonTag = FindLargestInitialSubstring( sCommonTag, sTag );
}
} }
return bFoundOne; return bFoundOne;
@@ -592,14 +591,14 @@ enum
void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out ) void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
{ {
RString sData; RString sData;
if( GetTagFromMap( mapNameToData, "#title", sData ) ) if( GetTagFromMap(mapNameToData, "#title", sData) )
GetMainAndSubTitlesFromFullTitle( sData, out.m_sMainTitle, out.m_sSubTitle ); GetMainAndSubTitlesFromFullTitle( sData, out.m_sMainTitle, out.m_sSubTitle );
GetTagFromMap( mapNameToData, "#artist", out.m_sArtist ); GetTagFromMap( mapNameToData, "#artist", out.m_sArtist );
GetTagFromMap( mapNameToData, "#backbmp", out.m_sBackgroundFile ); GetTagFromMap( mapNameToData, "#backbmp", out.m_sBackgroundFile );
GetTagFromMap( mapNameToData, "#wav", out.m_sMusicFile ); GetTagFromMap( mapNameToData, "#wav", out.m_sMusicFile );
if( GetTagFromMap( mapNameToData, "#bpm", sData ) ) if( GetTagFromMap(mapNameToData, "#bpm", sData) )
{ {
const float fBPM = StringToFloat( sData ); const float fBPM = StringToFloat( sData );
@@ -664,8 +663,8 @@ void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) ) if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) )
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
int iMeasureNo = atoi( sName.substr(1,3).c_str() ); int iMeasureNo = atoi( sName.substr(1, 3).c_str() );
int iBMSTrackNo = atoi( sName.substr(4,2).c_str() ); int iBMSTrackNo = atoi( sName.substr(4, 2).c_str() );
int iStepIndex = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo ); int iStepIndex = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo );
float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo ); float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo );
int iRowsPerMeasure = BeatToNoteRow( fBeatsPerMeasure ); int iRowsPerMeasure = BeatToNoteRow( fBeatsPerMeasure );
@@ -674,7 +673,7 @@ void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
int totalPairs = sData.size() / 2; int totalPairs = sData.size() / 2;
for( int i = 0; i < totalPairs; ++i ) for( int i = 0; i < totalPairs; ++i )
{ {
RString sPair = sData.substr(i*2,2); RString sPair = sData.substr( i*2, 2 );
int iVal = 0; int iVal = 0;
if( sscanf( sPair, "%x", &iVal ) == 0 || iVal == 0 ) if( sscanf( sPair, "%x", &iVal ) == 0 || iVal == 0 )
@@ -718,7 +717,9 @@ void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
} }
} }
else else
{
LOG->Warn( "Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), m_sDir.c_str() ); LOG->Warn( "Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), m_sDir.c_str() );
}
break; break;
} }
case BMS_TRACK_STOP: case BMS_TRACK_STOP:
@@ -737,7 +738,9 @@ void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.m_fStopSeconds ); LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.m_fStopSeconds );
} }
else else
{
LOG->Warn( "Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), m_sDir.c_str() ); LOG->Warn( "Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), m_sDir.c_str() );
}
break; break;
} }
} }
@@ -770,7 +773,9 @@ void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
} }
} }
else else
{
LOG->Warn( "Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), m_sDir.c_str() ); LOG->Warn( "Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), m_sDir.c_str() );
}
break; break;
} }
@@ -787,13 +792,13 @@ void BMSLoader::ReadTimeSigs( const NameToData_t &mapNameToData, MeasureToTimeSi
for( it = mapNameToData.lower_bound("#00000"); it != mapNameToData.end(); ++it ) for( it = mapNameToData.lower_bound("#00000"); it != mapNameToData.end(); ++it )
{ {
const RString &sName = it->first; const RString &sName = it->first;
if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) ) if( sName.size() != 6 || sName[0] != '#' || !IsAnInt(sName.substr(1, 5)) )
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
const RString &sData = it->second; const RString &sData = it->second;
int iMeasureNo = atoi( sName.substr(1,3).c_str() ); int iMeasureNo = atoi( sName.substr(1, 3).c_str() );
int iBMSTrackNo = atoi( sName.substr(4,2).c_str() ); int iBMSTrackNo = atoi( sName.substr(4, 2).c_str() );
if( iBMSTrackNo == BMS_TRACK_TIME_SIG ) if( iBMSTrackNo == BMS_TRACK_TIME_SIG )
out[iMeasureNo] = (float) atof(sData); out[iMeasureNo] = (float) atof(sData);
} }
@@ -920,7 +925,7 @@ bool BMSLoader::LoadFromDir( const RString &sDir, Song &out )
sTag.MakeLower(); sTag.MakeLower();
// XXX: We should do this with filenames too, I have plenty of examples. // XXX: We should do this with filenames too, I have plenty of examples.
// however, filenames will be trickier, as stuffs at the beginning AND // however, filenames will be trickier, as stuff at the beginning AND
// end change per-file, so we'll need a fancier FindLargestInitialSubstring() // end change per-file, so we'll need a fancier FindLargestInitialSubstring()
// XXX: This matches (double), but I haven't seen it used. Again, MORE EXAMPLES NEEDED // XXX: This matches (double), but I haven't seen it used. Again, MORE EXAMPLES NEEDED