From 40ec9b68e9efada330da1b22457e5ef188abe697 Mon Sep 17 00:00:00 2001 From: EZ Date: Thu, 29 Jan 2026 22:15:32 -0800 Subject: [PATCH] Fixed Global Donut Limit Duplicate Count --- .../PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp | 8 ++++---- .../PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp index 63f0afa04f..8bb9ecc401 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp @@ -579,14 +579,12 @@ void save_donut(SingleSwitchProgramEnvironment& env, ProControllerContext& conte } // Check if all user defined limits are reached or the global max keepers limit is reached -bool DonutMaker::should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector& kept_counts){ - int total_kept = 0; +bool DonutMaker::should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector& kept_counts, uint16_t total_kept) { bool limit_reached = true; for (size_t i = 0; i < kept_counts.size(); i++){ if (kept_counts[i] < FLAVOR_POWERS.snapshot()[i].limit){ limit_reached = false; } - total_kept += kept_counts[i]; } if (total_kept >= MAX_KEEPERS){ return true; @@ -650,6 +648,7 @@ void DonutMaker::program(SingleSwitchProgramEnvironment& env, ProControllerConte reset_map_filter_state(env, context); std::vector kept_counts(FLAVOR_POWERS.snapshot().size(), 0); + uint16_t total_kept = 0; while(true){ const bool should_keep = donut_iteration(env, context, kept_counts); stats.resets++; @@ -657,7 +656,8 @@ void DonutMaker::program(SingleSwitchProgramEnvironment& env, ProControllerConte send_program_status_notification(env, NOTIFICATION_STATUS); if (should_keep){ - if (should_stop(env, context, kept_counts)){ + total_kept++; + if (should_stop(env, context, kept_counts, total_kept)){ break; } save_donut(env, context); diff --git a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h index e12fbbe56d..9c7cc82bb9 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h +++ b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h @@ -37,7 +37,7 @@ class DonutMaker : public SingleSwitchProgramInstance{ private: bool match_powers(SingleSwitchProgramEnvironment& env, ProControllerContext& context, std::vector& kept_counts); - bool should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector& kept_counts); + bool should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector& kept_counts, uint16_t total_kept); void animation_to_donut(SingleSwitchProgramEnvironment& env, ProControllerContext& context); void add_berries_and_make_donut(SingleSwitchProgramEnvironment& env, ProControllerContext& context); void open_berry_menu_from_ansha(SingleSwitchProgramEnvironment& env, ProControllerContext& context);