From edd0edd93eab66c91abad99bf9d8cc6cc95f1b4f Mon Sep 17 00:00:00 2001 From: Barinade Date: Sun, 8 Dec 2019 23:22:27 -0600 Subject: [PATCH] Remove vectors from GetSMNoteDataString ... do we really need these? --- src/Etterna/Models/NoteData/NoteDataUtil.cpp | 402 +++++++++---------- 1 file changed, 190 insertions(+), 212 deletions(-) diff --git a/src/Etterna/Models/NoteData/NoteDataUtil.cpp b/src/Etterna/Models/NoteData/NoteDataUtil.cpp index d70992f377..a64aa34fc4 100644 --- a/src/Etterna/Models/NoteData/NoteDataUtil.cpp +++ b/src/Etterna/Models/NoteData/NoteDataUtil.cpp @@ -581,98 +581,86 @@ void NoteDataUtil::GetSMNoteDataString(const NoteData& in, RString& sRet) { // Get note data - vector parts; - parts.emplace_back(in); + NoteData nd = in; float fLastBeat = -1.0f; - FOREACH(NoteData, parts, nd) - { - InsertHoldTails(*nd); - fLastBeat = max(fLastBeat, nd->GetLastBeat()); - } + InsertHoldTails(nd); + fLastBeat = max(fLastBeat, nd.GetLastBeat()); auto iLastMeasure = static_cast(fLastBeat / BEATS_PER_MEASURE); sRet = ""; - FOREACH(NoteData, parts, nd) + for (int m = 0; m <= iLastMeasure; ++m) // foreach measure { - if (nd != parts.begin()) - sRet.append("&\n"); - for (int m = 0; m <= iLastMeasure; ++m) // foreach measure - { - if (m) - sRet.append(1, ','); - sRet += ssprintf(" // measure %d\n", m); - - NoteType nt = GetSmallestNoteTypeForMeasure(*nd, m); - int iRowSpacing; - if (nt == NoteType_Invalid) - iRowSpacing = 1; - else - iRowSpacing = lround(NoteTypeToBeat(nt) * ROWS_PER_BEAT); - // (verify first) - // iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) ); - - const int iMeasureStartRow = m * ROWS_PER_MEASURE; - const int iMeasureLastRow = (m + 1) * ROWS_PER_MEASURE - 1; - - for (int r = iMeasureStartRow; r <= iMeasureLastRow; - r += iRowSpacing) { - for (int t = 0; t < nd->GetNumTracks(); ++t) { - const TapNote& tn = nd->GetTapNote(t, r); - char c; - switch (tn.type) { - case TapNoteType_Empty: - c = '0'; - break; - case TapNoteType_Tap: - c = '1'; - break; - case TapNoteType_HoldHead: - switch (tn.subType) { - case TapNoteSubType_Hold: - c = '2'; - break; - case TapNoteSubType_Roll: - c = '4'; - break; - // case TapNoteSubType_Mine: c = 'N'; break; - default: - FAIL_M( - ssprintf("Invalid tap note subtype: %i", - tn.subType)); - } - break; - case TapNoteType_HoldTail: - c = '3'; - break; - case TapNoteType_Mine: - c = 'M'; - break; - case TapNoteType_AutoKeysound: - c = 'K'; - break; - case TapNoteType_Lift: - c = 'L'; - break; - case TapNoteType_Fake: - c = 'F'; - break; - default: - c = '\0'; - FAIL_M( - ssprintf("Invalid tap note type: %i", tn.type)); - } - sRet.append(1, c); - - // hey maybe if we have TapNoteType_Item we can do things - // here. - if (tn.iKeysoundIndex >= 0) - sRet.append(ssprintf("[%d]", tn.iKeysoundIndex)); + if (m) + sRet.append(1, ','); + sRet += ssprintf(" // measure %d\n", m); + + NoteType nt = GetSmallestNoteTypeForMeasure(nd, m); + int iRowSpacing; + if (nt == NoteType_Invalid) + iRowSpacing = 1; + else + iRowSpacing = lround(NoteTypeToBeat(nt) * ROWS_PER_BEAT); + // (verify first) + // iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) ); + + const int iMeasureStartRow = m * ROWS_PER_MEASURE; + const int iMeasureLastRow = (m + 1) * ROWS_PER_MEASURE - 1; + + for (int r = iMeasureStartRow; r <= iMeasureLastRow; r += iRowSpacing) { + for (int t = 0; t < nd.GetNumTracks(); ++t) { + const TapNote& tn = nd.GetTapNote(t, r); + char c; + switch (tn.type) { + case TapNoteType_Empty: + c = '0'; + break; + case TapNoteType_Tap: + c = '1'; + break; + case TapNoteType_HoldHead: + switch (tn.subType) { + case TapNoteSubType_Hold: + c = '2'; + break; + case TapNoteSubType_Roll: + c = '4'; + break; + // case TapNoteSubType_Mine: c = 'N'; break; + default: + FAIL_M(ssprintf("Invalid tap note subtype: %i", + tn.subType)); + } + break; + case TapNoteType_HoldTail: + c = '3'; + break; + case TapNoteType_Mine: + c = 'M'; + break; + case TapNoteType_AutoKeysound: + c = 'K'; + break; + case TapNoteType_Lift: + c = 'L'; + break; + case TapNoteType_Fake: + c = 'F'; + break; + default: + c = '\0'; + FAIL_M(ssprintf("Invalid tap note type: %i", tn.type)); } + sRet.append(1, c); - sRet.append(1, '\n'); + // hey maybe if we have TapNoteType_Item we can do things + // here. + if (tn.iKeysoundIndex >= 0) + sRet.append(ssprintf("[%d]", tn.iKeysoundIndex)); } + + sRet.append(1, '\n'); } } } @@ -681,14 +669,10 @@ void NoteDataUtil::GetETTNoteDataString(const NoteData& in, RString& sRet) { // Get note data - vector parts; - parts.emplace_back(in); + NoteData nd = in; float fLastBeat = -1.f; - FOREACH(NoteData, parts, nd) - { - fLastBeat = max(fLastBeat, nd->GetLastBeat()); - } + fLastBeat = max(fLastBeat, nd.GetLastBeat()); auto iLastMeasure = static_cast(fLastBeat / BEATS_PER_MEASURE); @@ -699,136 +683,130 @@ NoteDataUtil::GetETTNoteDataString(const NoteData& in, RString& sRet) return; } - FOREACH(NoteData, parts, nd) - { - if (nd != parts.begin()) - sRet.append("&\n"); - for (int m = 0; m <= iLastMeasure; ++m) { - if (m) - sRet.append(1, ','); - NoteType nt = GetSmallestNoteTypeForMeasure(*nd, m); - int iRowSpacing; - if (nt == NoteType_Invalid) - iRowSpacing = 1; - else - iRowSpacing = lround(NoteTypeToBeat(nt) * ROWS_PER_BEAT); - - const int iMeasureStartRow = m * ROWS_PER_MEASURE; - const int iMeasureLastRow = (m + 1) * ROWS_PER_MEASURE - 1; - - sRet.append(to_string(nt)); - for (int r = iMeasureStartRow; r <= iMeasureLastRow; - r += iRowSpacing) { - string halp; - for (int t = 0; t < nd->GetNumTracks(); ++t) { - const TapNote& tn = nd->GetTapNote(t, r); - if (tn.type == TapNoteType_Empty) { - halp.append("E"); - continue; - } else if (tn.type == TapNoteType_Tap) { - halp.append("T"); - continue; - } else if (tn.type == TapNoteType_HoldHead) { - if (tn.subType == TapNoteSubType_Hold) { - halp.append("H"); - continue; - } - if (tn.subType == TapNoteSubType_Roll) { - halp.append("R"); - continue; - } - } else if (tn.type == TapNoteType_HoldTail) { - halp.append("J"); - continue; - } else if (tn.type == TapNoteType_Mine) { - halp.append("*"); - continue; - } else if (tn.type == TapNoteType_Lift) { - halp.append("^"); + for (int m = 0; m <= iLastMeasure; ++m) { + if (m) + sRet.append(1, ','); + NoteType nt = GetSmallestNoteTypeForMeasure(nd, m); + int iRowSpacing; + if (nt == NoteType_Invalid) + iRowSpacing = 1; + else + iRowSpacing = lround(NoteTypeToBeat(nt) * ROWS_PER_BEAT); + + const int iMeasureStartRow = m * ROWS_PER_MEASURE; + const int iMeasureLastRow = (m + 1) * ROWS_PER_MEASURE - 1; + + sRet.append(to_string(nt)); + for (int r = iMeasureStartRow; r <= iMeasureLastRow; r += iRowSpacing) { + string halp; + for (int t = 0; t < nd.GetNumTracks(); ++t) { + const TapNote& tn = nd.GetTapNote(t, r); + if (tn.type == TapNoteType_Empty) { + halp.append("E"); + continue; + } else if (tn.type == TapNoteType_Tap) { + halp.append("T"); + continue; + } else if (tn.type == TapNoteType_HoldHead) { + if (tn.subType == TapNoteSubType_Hold) { + halp.append("H"); continue; - } else if (tn.type == TapNoteType_Fake) { - halp.append("V"); + } + if (tn.subType == TapNoteSubType_Roll) { + halp.append("R"); continue; } + } else if (tn.type == TapNoteType_HoldTail) { + halp.append("J"); + continue; + } else if (tn.type == TapNoteType_Mine) { + halp.append("*"); + continue; + } else if (tn.type == TapNoteType_Lift) { + halp.append("^"); + continue; + } else if (tn.type == TapNoteType_Fake) { + halp.append("V"); + continue; } - - if (halp == "EEEE") - halp = "?"; - else if (halp == "TTEE") - halp = "M"; - else if (halp == "EETT") - halp = "W"; - else if (halp == "TEEE") - halp = "L"; - else if (halp == "ETEE") - halp = "D"; - else if (halp == "EETE") - halp = "U"; - else if (halp == "EEET") - halp = "Y"; - else if (halp == "TEET") - halp = "B"; - else if (halp == "ETTE") - halp = "Z"; - else if (halp == "ETET") - halp = "G"; - else if (halp == "TETE") - halp = "K"; - else if (halp == "TTTE") - halp = "U"; - else if (halp == "ETTT") - halp = "I"; - else if (halp == "TETT") - halp = "O"; - else if (halp == "TTET") - halp = "P"; - - sRet.append(halp); } - sRet.append("\n"); - } - size_t oop = 1; - for (;;) { - oop = sRet.find("??", oop - 1); - if (oop == string::npos) - break; - sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "~"); - } - oop = 1; - for (;;) { - oop = sRet.find("~~", oop - 1); - if (oop == string::npos) - break; - sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "|"); - } - oop = 1; - for (;;) { - oop = sRet.find("||", oop - 1); - if (oop == string::npos) - break; - sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "!"); - } - oop = 1; - for (;;) { - oop = sRet.find("!!", oop - 1); - if (oop == string::npos) - break; - sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "-"); - } - oop = 1; - for (;;) { - oop = sRet.find("--", oop - 1); - if (oop == string::npos) - break; - sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "`"); - } - oop = 1; - for (;;) { - oop = sRet.find("``", oop - 1); - if (oop == string::npos) - break; - sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "."); + + if (halp == "EEEE") + halp = "?"; + else if (halp == "TTEE") + halp = "M"; + else if (halp == "EETT") + halp = "W"; + else if (halp == "TEEE") + halp = "L"; + else if (halp == "ETEE") + halp = "D"; + else if (halp == "EETE") + halp = "U"; + else if (halp == "EEET") + halp = "Y"; + else if (halp == "TEET") + halp = "B"; + else if (halp == "ETTE") + halp = "Z"; + else if (halp == "ETET") + halp = "G"; + else if (halp == "TETE") + halp = "K"; + else if (halp == "TTTE") + halp = "U"; + else if (halp == "ETTT") + halp = "I"; + else if (halp == "TETT") + halp = "O"; + else if (halp == "TTET") + halp = "P"; + + sRet.append(halp); } + sRet.append("\n"); + } + size_t oop = 1; + for (;;) { + oop = sRet.find("??", oop - 1); + if (oop == string::npos) + break; + sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "~"); + } + oop = 1; + for (;;) { + oop = sRet.find("~~", oop - 1); + if (oop == string::npos) + break; + sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "|"); + } + oop = 1; + for (;;) { + oop = sRet.find("||", oop - 1); + if (oop == string::npos) + break; + sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "!"); + } + oop = 1; + for (;;) { + oop = sRet.find("!!", oop - 1); + if (oop == string::npos) + break; + sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "-"); + } + oop = 1; + for (;;) { + oop = sRet.find("--", oop - 1); + if (oop == string::npos) + break; + sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "`"); + } + oop = 1; + for (;;) { + oop = sRet.find("``", oop - 1); + if (oop == string::npos) + break; + sRet.replace(sRet.begin() + oop, sRet.begin() + oop + 2, "."); } sRet.shrink_to_fit(); }