Fixed UnknownStyleSupport.
This commit is contained in:
@@ -73,7 +73,7 @@ void SMLoader::LoadFromTokens(
|
|||||||
Trim( sDifficulty );
|
Trim( sDifficulty );
|
||||||
Trim( sNoteData );
|
Trim( sNoteData );
|
||||||
|
|
||||||
// LOG->Trace( "Steps::LoadFromTokens()" );
|
// LOG->Trace( "Steps::LoadFromTokens(), %s", sStepsType.c_str() );
|
||||||
|
|
||||||
// backwards compatibility hacks:
|
// backwards compatibility hacks:
|
||||||
// HACK: We eliminated "ez2-single-hard", but we should still handle it.
|
// HACK: We eliminated "ez2-single-hard", but we should still handle it.
|
||||||
@@ -85,6 +85,7 @@ void SMLoader::LoadFromTokens(
|
|||||||
sStepsType = "para-single";
|
sStepsType = "para-single";
|
||||||
|
|
||||||
out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
|
out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
|
||||||
|
out.m_StepsTypeStr = sStepsType;
|
||||||
out.SetDescription( sDescription );
|
out.SetDescription( sDescription );
|
||||||
out.SetCredit( sDescription ); // this is often used for both.
|
out.SetCredit( sDescription ); // this is often used for both.
|
||||||
out.SetChartName(sDescription); // yeah, one more for good measure.
|
out.SetChartName(sDescription); // yeah, one more for good measure.
|
||||||
|
|||||||
@@ -643,6 +643,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
|
|||||||
if( sValueName=="STEPSTYPE" )
|
if( sValueName=="STEPSTYPE" )
|
||||||
{
|
{
|
||||||
pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] );
|
pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] );
|
||||||
|
pNewNotes->m_StepsTypeStr= sParams[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( sValueName=="CHARTSTYLE" )
|
else if( sValueName=="CHARTSTYLE" )
|
||||||
@@ -965,6 +966,7 @@ bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
|
|||||||
if( sValueName=="STEPSTYPE" )
|
if( sValueName=="STEPSTYPE" )
|
||||||
{
|
{
|
||||||
pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] );
|
pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] );
|
||||||
|
pNewNotes->m_StepsTypeStr= sParams[1];
|
||||||
bSSCFormat = true;
|
bSSCFormat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,9 +206,9 @@ static RString GetSMNotesTag( const Song &song, const Steps &in )
|
|||||||
lines.push_back( "" );
|
lines.push_back( "" );
|
||||||
// Escape to prevent some clown from making a comment of "\r\n;"
|
// Escape to prevent some clown from making a comment of "\r\n;"
|
||||||
lines.push_back( ssprintf("//---------------%s - %s----------------",
|
lines.push_back( ssprintf("//---------------%s - %s----------------",
|
||||||
GAMEMAN->GetStepsTypeInfo(in.m_StepsType).szName, SmEscape(in.GetDescription()).c_str()) );
|
in.m_StepsTypeStr.c_str(), SmEscape(in.GetDescription()).c_str()) );
|
||||||
lines.push_back( song.m_vsKeysoundFile.empty() ? "#NOTES:" : "#NOTES2:" );
|
lines.push_back( song.m_vsKeysoundFile.empty() ? "#NOTES:" : "#NOTES2:" );
|
||||||
lines.push_back( ssprintf( " %s:", GAMEMAN->GetStepsTypeInfo(in.m_StepsType).szName ) );
|
lines.push_back( ssprintf( " %s:", in.m_StepsTypeStr.c_str() ) );
|
||||||
RString desc = (USE_CREDIT ? in.GetCredit() : in.GetChartName());
|
RString desc = (USE_CREDIT ? in.GetCredit() : in.GetChartName());
|
||||||
lines.push_back( ssprintf( " %s:", SmEscape(desc).c_str() ) );
|
lines.push_back( ssprintf( " %s:", SmEscape(desc).c_str() ) );
|
||||||
lines.push_back( ssprintf( " %s:", DifficultyToString(in.GetDifficulty()).c_str() ) );
|
lines.push_back( ssprintf( " %s:", DifficultyToString(in.GetDifficulty()).c_str() ) );
|
||||||
|
|||||||
@@ -349,10 +349,10 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
|
|||||||
lines.push_back( "" );
|
lines.push_back( "" );
|
||||||
// Escape to prevent some clown from making a comment of "\r\n;"
|
// Escape to prevent some clown from making a comment of "\r\n;"
|
||||||
lines.push_back( ssprintf("//---------------%s - %s----------------",
|
lines.push_back( ssprintf("//---------------%s - %s----------------",
|
||||||
GAMEMAN->GetStepsTypeInfo(in.m_StepsType).szName, SmEscape(in.GetDescription()).c_str()) );
|
in.m_StepsTypeStr.c_str(), SmEscape(in.GetDescription()).c_str()) );
|
||||||
lines.push_back( "#NOTEDATA:;" ); // our new separator.
|
lines.push_back( "#NOTEDATA:;" ); // our new separator.
|
||||||
lines.push_back( ssprintf( "#CHARTNAME:%s;", SmEscape(in.GetChartName()).c_str()));
|
lines.push_back( ssprintf( "#CHARTNAME:%s;", SmEscape(in.GetChartName()).c_str()));
|
||||||
lines.push_back( ssprintf( "#STEPSTYPE:%s;", GAMEMAN->GetStepsTypeInfo(in.m_StepsType).szName ) );
|
lines.push_back( ssprintf( "#STEPSTYPE:%s;", in.m_StepsTypeStr.c_str() ) );
|
||||||
lines.push_back( ssprintf( "#DESCRIPTION:%s;", SmEscape(in.GetDescription()).c_str() ) );
|
lines.push_back( ssprintf( "#DESCRIPTION:%s;", SmEscape(in.GetDescription()).c_str() ) );
|
||||||
lines.push_back( ssprintf( "#CHARTSTYLE:%s;", SmEscape(in.GetChartStyle()).c_str() ) );
|
lines.push_back( ssprintf( "#CHARTSTYLE:%s;", SmEscape(in.GetChartStyle()).c_str() ) );
|
||||||
lines.push_back( ssprintf( "#DIFFICULTY:%s;", DifficultyToString(in.GetDifficulty()).c_str() ) );
|
lines.push_back( ssprintf( "#DIFFICULTY:%s;", DifficultyToString(in.GetDifficulty()).c_str() ) );
|
||||||
|
|||||||
+30
-1
@@ -42,7 +42,7 @@
|
|||||||
* @brief The internal version of the cache for StepMania.
|
* @brief The internal version of the cache for StepMania.
|
||||||
*
|
*
|
||||||
* Increment this value to invalidate the current cache. */
|
* Increment this value to invalidate the current cache. */
|
||||||
const int FILE_CACHE_VERSION = 220;
|
const int FILE_CACHE_VERSION = 221;
|
||||||
|
|
||||||
/** @brief How long does a song sample last by default? */
|
/** @brief How long does a song sample last by default? */
|
||||||
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
|
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
|
||||||
@@ -89,6 +89,11 @@ Song::~Song()
|
|||||||
FOREACH( Steps*, m_vpSteps, s )
|
FOREACH( Steps*, m_vpSteps, s )
|
||||||
SAFE_DELETE( *s );
|
SAFE_DELETE( *s );
|
||||||
m_vpSteps.clear();
|
m_vpSteps.clear();
|
||||||
|
FOREACH(Steps*, m_UnknownStyleSteps, s)
|
||||||
|
{
|
||||||
|
SAFE_DELETE(*s);
|
||||||
|
}
|
||||||
|
m_UnknownStyleSteps.clear();
|
||||||
|
|
||||||
// It's the responsibility of the owner of this Song to make sure
|
// It's the responsibility of the owner of this Song to make sure
|
||||||
// that all pointers to this Song and its Steps are invalidated.
|
// that all pointers to this Song and its Steps are invalidated.
|
||||||
@@ -99,6 +104,7 @@ void Song::DetachSteps()
|
|||||||
m_vpSteps.clear();
|
m_vpSteps.clear();
|
||||||
FOREACH_ENUM( StepsType, st )
|
FOREACH_ENUM( StepsType, st )
|
||||||
m_vpStepsByType[st].clear();
|
m_vpStepsByType[st].clear();
|
||||||
|
m_UnknownStyleSteps.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
float Song::GetFirstSecond() const
|
float Song::GetFirstSecond() const
|
||||||
@@ -154,6 +160,11 @@ void Song::Reset()
|
|||||||
m_vpSteps.clear();
|
m_vpSteps.clear();
|
||||||
FOREACH_ENUM( StepsType, st )
|
FOREACH_ENUM( StepsType, st )
|
||||||
m_vpStepsByType[st].clear();
|
m_vpStepsByType[st].clear();
|
||||||
|
FOREACH(Steps*, m_UnknownStyleSteps, s)
|
||||||
|
{
|
||||||
|
SAFE_DELETE(*s);
|
||||||
|
}
|
||||||
|
m_UnknownStyleSteps.clear();
|
||||||
|
|
||||||
Song empty;
|
Song empty;
|
||||||
*this = empty;
|
*this = empty;
|
||||||
@@ -1023,6 +1034,10 @@ bool Song::SaveToSMFile()
|
|||||||
|
|
||||||
vpStepsToSave.push_back( pSteps );
|
vpStepsToSave.push_back( pSteps );
|
||||||
}
|
}
|
||||||
|
FOREACH_CONST(Steps*, m_UnknownStyleSteps, s)
|
||||||
|
{
|
||||||
|
vpStepsToSave.push_back(*s);
|
||||||
|
}
|
||||||
|
|
||||||
return NotesWriterSM::Write( sPath, *this, vpStepsToSave );
|
return NotesWriterSM::Write( sPath, *this, vpStepsToSave );
|
||||||
|
|
||||||
@@ -1055,6 +1070,10 @@ bool Song::SaveToSSCFile( RString sPath, bool bSavingCache )
|
|||||||
pSteps->SetFilename(path);
|
pSteps->SetFilename(path);
|
||||||
vpStepsToSave.push_back( pSteps );
|
vpStepsToSave.push_back( pSteps );
|
||||||
}
|
}
|
||||||
|
FOREACH_CONST(Steps*, m_UnknownStyleSteps, s)
|
||||||
|
{
|
||||||
|
vpStepsToSave.push_back(*s);
|
||||||
|
}
|
||||||
|
|
||||||
if (bSavingCache)
|
if (bSavingCache)
|
||||||
{
|
{
|
||||||
@@ -1504,9 +1523,19 @@ RString Song::GetTranslitFullTitle() const
|
|||||||
|
|
||||||
void Song::AddSteps( Steps* pSteps )
|
void Song::AddSteps( Steps* pSteps )
|
||||||
{
|
{
|
||||||
|
// Songs of unknown stepstype are saved as a forwards compatibility feature
|
||||||
|
// so that editing a simfile made by a future version that has a new style
|
||||||
|
// won't delete those steps. -Kyz
|
||||||
|
if(pSteps->m_StepsType != StepsType_Invalid)
|
||||||
|
{
|
||||||
m_vpSteps.push_back( pSteps );
|
m_vpSteps.push_back( pSteps );
|
||||||
ASSERT_M( pSteps->m_StepsType < NUM_StepsType, ssprintf("%i", pSteps->m_StepsType) );
|
ASSERT_M( pSteps->m_StepsType < NUM_StepsType, ssprintf("%i", pSteps->m_StepsType) );
|
||||||
m_vpStepsByType[pSteps->m_StepsType].push_back( pSteps );
|
m_vpStepsByType[pSteps->m_StepsType].push_back( pSteps );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_UnknownStyleSteps.push_back(pSteps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Song::DeleteSteps( const Steps* pSteps, bool bReAutoGen )
|
void Song::DeleteSteps( const Steps* pSteps, bool bReAutoGen )
|
||||||
|
|||||||
@@ -447,6 +447,8 @@ private:
|
|||||||
vector<Steps*> m_vpSteps;
|
vector<Steps*> m_vpSteps;
|
||||||
/** @brief the Steps of a particular StepsType that belong to this Song. */
|
/** @brief the Steps of a particular StepsType that belong to this Song. */
|
||||||
vector<Steps*> m_vpStepsByType[NUM_StepsType];
|
vector<Steps*> m_vpStepsByType[NUM_StepsType];
|
||||||
|
/** @brief the Steps that are of unrecognized Styles. */
|
||||||
|
vector<Steps*> m_UnknownStyleSteps;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+11
-1
@@ -258,8 +258,16 @@ float Steps::PredictMeter() const
|
|||||||
|
|
||||||
void Steps::TidyUpData()
|
void Steps::TidyUpData()
|
||||||
{
|
{
|
||||||
|
// Don't set the StepsType to dance single if it's invalid. That just
|
||||||
|
// causes unrecognized charts to end up where they don't belong.
|
||||||
|
// Leave it as StepsType_Invalid so the Song can handle it specially. This
|
||||||
|
// is a forwards compatibility feature, so that if a future version adds a
|
||||||
|
// new style, editing a simfile with unrecognized Steps won't silently
|
||||||
|
// delete them. -Kyz
|
||||||
if( m_StepsType == StepsType_Invalid )
|
if( m_StepsType == StepsType_Invalid )
|
||||||
m_StepsType = StepsType_dance_single;
|
{
|
||||||
|
LOG->Warn("Detected steps with unknown style '%s' in '%s'", m_StepsTypeStr.c_str(), m_pSong->m_sSongFileName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if( GetDifficulty() == Difficulty_Invalid )
|
if( GetDifficulty() == Difficulty_Invalid )
|
||||||
SetDifficulty( StringToDifficulty(GetDescription()) );
|
SetDifficulty( StringToDifficulty(GetDescription()) );
|
||||||
@@ -465,12 +473,14 @@ void Steps::AutogenFrom( const Steps *parent_, StepsType ntTo )
|
|||||||
{
|
{
|
||||||
parent = parent_;
|
parent = parent_;
|
||||||
m_StepsType = ntTo;
|
m_StepsType = ntTo;
|
||||||
|
m_StepsTypeStr= GAMEMAN->GetStepsTypeInfo(ntTo).szName;
|
||||||
m_Timing = parent->m_Timing;
|
m_Timing = parent->m_Timing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Steps::CopyFrom( Steps* pSource, StepsType ntTo, float fMusicLengthSeconds ) // pSource does not have to be of the same StepsType
|
void Steps::CopyFrom( Steps* pSource, StepsType ntTo, float fMusicLengthSeconds ) // pSource does not have to be of the same StepsType
|
||||||
{
|
{
|
||||||
m_StepsType = ntTo;
|
m_StepsType = ntTo;
|
||||||
|
m_StepsTypeStr= GAMEMAN->GetStepsTypeInfo(ntTo).szName;
|
||||||
NoteData noteData;
|
NoteData noteData;
|
||||||
pSource->GetNoteData( noteData );
|
pSource->GetNoteData( noteData );
|
||||||
noteData.SetNumTracks( GAMEMAN->GetStepsTypeInfo(ntTo).iNumTracks );
|
noteData.SetNumTracks( GAMEMAN->GetStepsTypeInfo(ntTo).iNumTracks );
|
||||||
|
|||||||
@@ -177,6 +177,8 @@ public:
|
|||||||
void PushSelf( lua_State *L );
|
void PushSelf( lua_State *L );
|
||||||
|
|
||||||
StepsType m_StepsType;
|
StepsType m_StepsType;
|
||||||
|
/** @brief The string form of the StepsType, for dealing with unrecognized styles. */
|
||||||
|
RString m_StepsTypeStr;
|
||||||
/** @brief The Song these Steps are associated with */
|
/** @brief The Song these Steps are associated with */
|
||||||
Song *m_pSong;
|
Song *m_pSong;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user