diff --git a/LATEST_RELEASE_NOTES.md b/LATEST_RELEASE_NOTES.md index 73f63421..c3acc213 100644 --- a/LATEST_RELEASE_NOTES.md +++ b/LATEST_RELEASE_NOTES.md @@ -2,5 +2,7 @@ Bugs addressed in this release: +* [#581](../../issues/581) Calchart 3.7.1 crashes on loading a show + Other changes: diff --git a/src/core/CalChartAnimation.cpp b/src/core/CalChartAnimation.cpp index 271509f6..46e25712 100644 --- a/src/core/CalChartAnimation.cpp +++ b/src/core/CalChartAnimation.cpp @@ -75,8 +75,7 @@ auto AnimateShow(const Show& show) -> Sheets } return std::nullopt; }(nextAnimationSheet); - auto const& cont = curr_sheet->GetContinuityBySymbol(current_symbol).GetParsedContinuity(); - auto empty_cont = std::vector>{}; + auto cont = curr_sheet->GetContinuityBySymbol(current_symbol); return CalChart::Animate::CreateCompileResult( AnimationData{ static_cast(whichMarcher), @@ -84,7 +83,7 @@ auto AnimateShow(const Show& show) -> Sheets endPosition, numBeats, isLastSheet }, - curr_sheet->ContinuityInUse(current_symbol) ? cont : empty_cont, + curr_sheet->ContinuityInUse(current_symbol) ? &cont : nullptr, variablesStates); })); diff --git a/src/core/CalChartAnimationCompile.cpp b/src/core/CalChartAnimationCompile.cpp index f9b90b1b..b697c2a4 100644 --- a/src/core/CalChartAnimationCompile.cpp +++ b/src/core/CalChartAnimationCompile.cpp @@ -62,13 +62,13 @@ struct CompileState : public Compile { auto CreateCompileResult( AnimationData const& animationData, - Proceedures const& proceedures, + Continuity const* proceedures, Variables& variablesStates) -> CompileResult { auto ac = CompileState(animationData, variablesStates); // no continuity was specified - if (proceedures.empty()) { + if (proceedures == nullptr || !proceedures->HasParsedContinuity()) { if (animationData.isLastAnimationSheet) { // use MTRM E Cont::ProcMTRM defcont(std::make_unique(Cont::CC_E)); @@ -78,11 +78,11 @@ auto CreateCompileResult( Cont::ProcEven defcont(std::make_unique(ac.GetBeatsRemaining()), std::make_unique()); defcont.Compile(ac); } - } - - // compile all the commands - for (auto const& proc : proceedures) { - proc->Compile(ac); + } else { + // compile all the commands + for (auto const& proc : proceedures->GetParsedContinuity()) { + proc->Compile(ac); + } } // report if the point didn't make it diff --git a/src/core/CalChartAnimationCompile.h b/src/core/CalChartAnimationCompile.h index 729bfb86..b3f63484 100644 --- a/src/core/CalChartAnimationCompile.h +++ b/src/core/CalChartAnimationCompile.h @@ -75,7 +75,7 @@ struct AnimationData { auto CreateCompileResult( AnimationData const& animationData, - Proceedures const& proceedures, + Continuity const* proceedures, Variables& variablesStates) -> CompileResult; struct Compile { diff --git a/src/core/CalChartContinuity.h b/src/core/CalChartContinuity.h index 65c1d7b3..87eb7365 100644 --- a/src/core/CalChartContinuity.h +++ b/src/core/CalChartContinuity.h @@ -64,6 +64,7 @@ class Continuity { [[nodiscard]] auto Serialize() const -> std::vector; std::vector> const& GetParsedContinuity() const noexcept { return m_parsedContinuity; } + [[nodiscard]] auto HasParsedContinuity() const { return !m_parsedContinuity.empty(); } auto GetText() const { return m_legacyText; } friend void swap(Continuity& lhs, Continuity& rhs) diff --git a/tests/CalChartContinuityTokenTests.cpp b/tests/CalChartContinuityTokenTests.cpp index a4cd90ae..3ebd5476 100644 --- a/tests/CalChartContinuityTokenTests.cpp +++ b/tests/CalChartContinuityTokenTests.cpp @@ -40,7 +40,7 @@ auto GetCompiledResults(Sheets const& sheets, Conts const& proc) true }; - return Animate::CreateCompileResult(animationData, proc, vars); + return Animate::CreateCompileResult(animationData, &proc, vars); } auto CreateSheetsForTest(Coord begin, Coord end, int beats) @@ -84,7 +84,8 @@ TEST_CASE("Fountain", "CalChartContinuityToken") auto procs = std::vector>{}; procs.push_back(std::move(uut)); auto sheets = CreateSheetsForTest({ 0, 0 }, { 8, 16 }, 14); - auto [compiledResults, errors] = GetCompiledResults(sheets, procs); + auto continuity = Continuity(std::move(procs)); + auto [compiledResults, errors] = GetCompiledResults(sheets, continuity); auto goldCompile = std::vector{ Animate::CommandMove{ Coord{ 0, 0 }, 6, Coord{ 128, 128 } }, @@ -105,7 +106,8 @@ TEST_CASE("Fountain with nulls", "CalChartContinuityToken") auto procs = std::vector>{}; procs.push_back(std::move(uut)); auto sheets = CreateSheetsForTest({ 0, 0 }, { 8, 16 }, 16); - auto [compiledResults, errors] = GetCompiledResults(sheets, procs); + auto continuity = Continuity(std::move(procs)); + auto [compiledResults, errors] = GetCompiledResults(sheets, continuity); auto goldCompile = std::vector{ Animate::CommandMove{ Coord{ 0, 0 }, 8, Coord{ 128, 128 } }, @@ -127,7 +129,8 @@ TEST_CASE("HSCM", "CalChartContinuityToken") auto procs = std::vector>{}; procs.push_back(std::move(uut)); auto sheets = CreateSheetsForTest({ 0, 0 }, { -8, 0 }, { 8, -2 }, { 0, 0 }, 40); - auto [compiledResults, errors] = GetCompiledResults(sheets, procs); + auto continuity = Continuity(std::move(procs)); + auto [compiledResults, errors] = GetCompiledResults(sheets, continuity); auto goldCompile = std::vector{ Animate::CommandMove{ Coord{ 0, 0 }, 9, Coord{ -16 * 9, 0 } }, @@ -151,7 +154,8 @@ TEST_CASE("DMCM", "CalChartContinuityToken") auto procs = std::vector>{}; procs.push_back(std::move(uut)); auto sheets = CreateSheetsForTest({ 0, 0 }, { -8, 8 }, { 8, -10 }, { 0, 0 }, 40); - auto [compiledResults, errors] = GetCompiledResults(sheets, procs); + auto continuity = Continuity(std::move(procs)); + auto [compiledResults, errors] = GetCompiledResults(sheets, continuity); auto goldCompile = std::vector{ Animate::CommandMove{ Coord{ 0, 0 }, 9, Coord{ -16 * 9, 16 * 9 } },