Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t>& kept_counts){
int total_kept = 0;
bool DonutMaker::should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector<uint16_t>& 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;
Expand Down Expand Up @@ -650,14 +648,16 @@ void DonutMaker::program(SingleSwitchProgramEnvironment& env, ProControllerConte
reset_map_filter_state(env, context);

std::vector<uint16_t> 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++;
env.update_stats();
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DonutMaker : public SingleSwitchProgramInstance{

private:
bool match_powers(SingleSwitchProgramEnvironment& env, ProControllerContext& context, std::vector<uint16_t>& kept_counts);
bool should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector<uint16_t>& kept_counts);
bool should_stop(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const std::vector<uint16_t>& 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);
Expand Down
Loading