From 01db7b5f7c716deb174fd9f7c0f554ac172c32e8 Mon Sep 17 00:00:00 2001 From: Raymond Wright Date: Tue, 28 Apr 2020 20:47:14 +0100 Subject: [PATCH] Fix bug with second act GH3 CoP squeeze Early whammy in SP phrases was sometimes ignored, meaning chopt didn't realise the second activation could go from the Y in the first solo to the RBO. --- src/optimiser.cpp | 5 ++++- tests/optimiser_unittest.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/optimiser.cpp b/src/optimiser.cpp index 6dd660c3..f0c96189 100644 --- a/src/optimiser.cpp +++ b/src/optimiser.cpp @@ -64,7 +64,10 @@ Optimiser::CacheKey Optimiser::advance_cache_key(CacheKey key) const if (key.point == m_song->points().cend()) { return key; } - const auto pos = key.point->hit_window_start; + auto pos = key.point->hit_window_start; + if (key.point != m_song->points().cbegin()) { + pos = std::prev(key.point)->hit_window_start; + } if (pos.beat >= key.position.beat) { key.position = pos; } diff --git a/tests/optimiser_unittest.cpp b/tests/optimiser_unittest.cpp index 5217a693..5eeb7b51 100644 --- a/tests/optimiser_unittest.cpp +++ b/tests/optimiser_unittest.cpp @@ -221,4 +221,21 @@ TEST_CASE("optimal_path produces the correct path") REQUIRE(opt_path.score_boost == 750); REQUIRE(opt_path.activations.size() == 1); } + + // There was a bug where sustains at the start of an SP phrase right after + // an activation/start of song had their early whammy discounted, if that + // note didn't also grant SP. This affected a squeeze in GH3 Cult of + // Personality. This test is to catch that. + SECTION("Early whammy at start of an SP phrase is always counted") + { + std::vector notes {{0, 1420}, {1500}, {1600}}; + std::vector phrases {{0, 1550}}; + NoteTrack note_track {notes, phrases, {}}; + ProcessedSong track {note_track, 192, {}, 1.0, 1.0}; + Optimiser optimiser {&track}; + auto opt_path = optimiser.optimal_path(); + + REQUIRE(opt_path.score_boost == 50); + REQUIRE(opt_path.activations.size() == 1); + } }