@@ -116,7 +116,7 @@ void ShinyHunt_WildZoneEntrance::program(SingleSwitchProgramEnvironment& env, Pr
116116
117117 uint8_t shiny_count = 0 ;
118118
119- while ( true ) {
119+ { // first run with shiny detection
120120 float shiny_coefficient = 1.0 ;
121121 PokemonLA::ShinySoundDetector shiny_detector (env.console , [&](float error_coefficient) -> bool {
122122 // Warning: This callback will be run from a different thread than this function.
@@ -127,21 +127,16 @@ void ShinyHunt_WildZoneEntrance::program(SingleSwitchProgramEnvironment& env, Pr
127127 return true ;
128128 });
129129
130- int ret = run_until<ProControllerContext>(env.console , context,
131- [&](ProControllerContext& context) {
132- while (true ) {
133- send_program_status_notification (env, NOTIFICATION_STATUS);
134- stats.resets ++;
135- enter_wild_zone_entrance (env.console , context);
136- env.update_stats ();
137- }
138- },
139- {{shiny_detector}});
140-
141- // This should never happen.
142- if (ret != 0 ) {
143- continue ;
144- }
130+ run_until<ProControllerContext>(env.console , context,
131+ [&](ProControllerContext& context) {
132+ while (true ) {
133+ send_program_status_notification (env, NOTIFICATION_STATUS);
134+ stats.resets ++;
135+ enter_wild_zone_entrance (env.console , context);
136+ env.update_stats ();
137+ }
138+ },
139+ {{shiny_detector}});
145140
146141 context.wait_for (std::chrono::milliseconds (1000 ));
147142
@@ -152,8 +147,16 @@ void ShinyHunt_WildZoneEntrance::program(SingleSwitchProgramEnvironment& env, Pr
152147 pbf_mash_button (context, BUTTON_A, 600ms); // teleporting or just mashing button
153148 pbf_mash_button (context, BUTTON_B, 200ms); // in case need to dismiss map
154149
155- if (SHINY_DETECTED.on_shiny_sound (env, env.console , context, shiny_count, shiny_coefficient)) {
156- break ;
150+ SHINY_DETECTED.on_shiny_sound (env, env.console , context, shiny_count, shiny_coefficient);
151+ }
152+
153+ // continue with shiny detection if pointless
154+ if (SHINY_DETECTED.ACTION != ShinySoundDetectedAction::STOP_PROGRAM) {
155+ while (true ) {
156+ send_program_status_notification (env, NOTIFICATION_STATUS);
157+ stats.resets ++;
158+ enter_wild_zone_entrance (env.console , context);
159+ env.update_stats ();
157160 }
158161 }
159162
0 commit comments