From 30063b30d454009af601c54d3bce9371af25ef4c Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 20 Oct 2026 21:42:30 -0700 Subject: [PATCH] Fix BBQ save/reset milestones across stalled and batched rounds The farmer saved and reset when the completion count was an exact multiple of SAVE_NUM_QUESTS. A round that completed nothing while the count sat at 0 or 50 saved again, and a round going from 49 to 52 skipped the 50 milestone entirely. Compare the count before and after each round and ask end_round() to save once when it crosses a multiple of the interval. Stalled rounds and an interval of 0 never save. Fix the option label to say "completing", not "attempting". Add two PokemonSV::BBQFarmerRounds scenarios that fail with the old rule: a round that skips past a milestone, and rounds with no completions. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonSV/Options/PokemonSV_BBQOption.cpp | 2 +- .../Farming/PokemonSV_BBQSoloFarmer.cpp | 11 ++++++++- .../Programs/Farming/PokemonSV_BBQTests.cpp | 23 +++++++++---------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp index 57986e80d2..da09d46a59 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp @@ -149,7 +149,7 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option) 1000 ) , SAVE_NUM_QUESTS( - "Save and reset the game after attempting this many quests:
This preserves progress and prevents potential game lags from long runs.
0 disables this option.", + "Save and reset the game after completing this many quests:
This preserves progress and prevents potential game lags from long runs.
0 disables this option.", LockMode::UNLOCK_WHILE_RUNNING, 50 ) , INVERTED_FLIGHT( diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp index 3a4fd0dce2..7cd2c4c15e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp @@ -123,6 +123,13 @@ bool exclusions_leave_a_blue_quest(const BBQOption& options){ // language is wrong so no quest is read, or there is no BP left to reroll. const size_t MAX_READS_WITHOUT_DOABLE_QUEST = 30; +// Whether a round that took the completed count from previous_completed +// to completed crossed a nonzero multiple of the save interval. +bool bbq_save_due(uint64_t previous_completed, uint64_t completed, uint64_t interval){ + return interval != 0 && completed > previous_completed + && completed / interval > previous_completed / interval; +} + } void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& game){ @@ -179,6 +186,7 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga quest_list.clear(); } + const uint64_t completed_before_round = num_completed_quests; for (auto current_quest : quests_to_do){ //Check if quest was already completed (ex. 500 meters completed while navigating to take a photo) quest_list = read_panel(); @@ -205,7 +213,8 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga quests_to_do.clear(); uint64_t temp_save_num_option = options.SAVE_NUM_QUESTS; - game.end_round(temp_save_num_option != 0 && num_completed_quests % temp_save_num_option == 0); + // A round can cross a milestone without ending at an exact multiple. + game.end_round(bbq_save_due(completed_before_round, num_completed_quests, temp_save_num_option)); } } diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index 62d531a54c..c35ca22e4f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -317,7 +317,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected = "read process " + round_of_3 + " end", }, { - .name = "saves at exact multiples", + .name = "saves at each milestone", .num_quests = 6, .save_num_quests = 3, .expected_completed = 6, @@ -331,9 +331,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected = "", }, - // The ways the loop gets stuck or loses time. Scenarios named - // "today:" state the current behavior, so that each fix shows up as a - // change to one of them. + // The ways the loop used to get stuck or lose time. { // sneak-up fails in round 1 and is still on the panel in round 2, // where only the two new quests are attempted. @@ -363,23 +361,24 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected = read_30_times + "error", }, { - // Today: the save check only looks for exact multiples, so going - // from 0 to 3 skips the milestone at 2 without saving. - .name = "today: a round that skips past a milestone does not save", + // 0 -> 3 crosses the milestone at 2 without landing on it. + .name = "saves when a round skips past a milestone", .num_quests = 6, .save_num_quests = 2, .expected_completed = 6, - .expected = round_of_3 + " end " + round_of_3 + " end(save)", + .expected = round_of_3 + " end(save) " + round_of_3 + " end(save)", }, { - // Today: round 1 completes nothing, but 0 is a multiple of 2, so - // it saves anyway. Every quest failed, so the farmer then stops. - .name = "today: a round without completions saves", + // Round 1 completes nothing. It must not save, even though the + // count (0) is a multiple of the interval. + // Every quest fails, so nothing doable is left and the farmer + // stops, but the round with no completions doesn't save. + .name = "round without completions does not save", .num_quests = 3, .save_num_quests = 2, .outcomes = {false, false, false}, .expected_completed = 0, - .expected = "read process read do read do read do end(save) read process", + .expected = "read process read do read do read do end read process", }, { // sneak-up fails, then leaves the panel along with make-tm. Round 2