Skip to content

Commit 2f087d1

Browse files
committed
Fix update menu detection. Fix unrecoverable exception when failing to run away.
1 parent c5a7375 commit 2f087d1

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace PokemonAutomation{
2626
const bool IS_BETA_VERSION = true;
2727
const int PROGRAM_VERSION_MAJOR = 0;
2828
const int PROGRAM_VERSION_MINOR = 54;
29-
const int PROGRAM_VERSION_PATCH = 4;
29+
const int PROGRAM_VERSION_PATCH = 5;
3030

3131
const std::string PROGRAM_VERSION_BASE =
3232
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,28 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
287287

288288

289289

290+
#if 1
291+
// HomeMenuDetector detector0(console);
292+
// StartGameUserSelectDetector detector1(console);
293+
UpdatePopupDetector detector2(console);
294+
// detector0.make_overlays(overlays);
295+
// detector1.make_overlays(overlays);
296+
detector2.make_overlays(overlays);
297+
cout << detector2.detect(feed.snapshot()) << endl;
298+
#endif
299+
300+
301+
290302
// ImageRGB32 image0("menu-light.png");
291303
// ImageRGB32 image1("menu-dark.png");
292304
// ImageRGB32 image2("menu-jpn.png");
293305

294-
306+
#if 0
295307
env.log("Touching date to prevent rollover.");
296308
pbf_press_button(context, BUTTON_HOME, 160ms, PokemonSwSh::GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
297309
touch_date_from_home(console, context, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
298310
resume_game_no_interact(console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
299-
311+
#endif
300312

301313

302314

@@ -426,15 +438,6 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
426438
#endif
427439

428440

429-
#if 0
430-
HomeMenuDetector detector0(console);
431-
StartGameUserSelectDetector detector1(console);
432-
UpdatePopupDetector detector2(console);
433-
// detector0.make_overlays(overlays);
434-
// detector1.make_overlays(overlays);
435-
detector2.make_overlays(overlays);
436-
cout << detector2.detect(feed.snapshot()) << endl;
437-
#endif
438441

439442

440443
#if 0

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool UpdatePopupDetector_Switch1::detect(const ImageViewRGB32& screen){
149149
UpdatePopupDetector_Switch2::UpdatePopupDetector_Switch2(Color color)
150150
: m_color(color)
151151
, m_box_top(0.25, 0.31, 0.50, 0.02)
152-
, m_box_mid(0.25, 0.482, 0.50, 0.02)
152+
// , m_box_mid(0.25, 0.482, 0.50, 0.02)
153153
, m_top(0.10, 0.17, 0.80, 0.03)
154154
, m_left(0.08, 0.25, 0.10, 0.38)
155155
, m_bottom_solid(0.10, 0.86, 0.80, 0.04)
@@ -158,7 +158,7 @@ UpdatePopupDetector_Switch2::UpdatePopupDetector_Switch2(Color color)
158158

159159
void UpdatePopupDetector_Switch2::make_overlays(VideoOverlaySet& items) const{
160160
items.add(m_color, m_box_top);
161-
items.add(m_color, m_box_mid);
161+
// items.add(m_color, m_box_mid);
162162
items.add(m_color, m_top);
163163
items.add(m_color, m_left);
164164
items.add(m_color, m_bottom_solid);
@@ -181,13 +181,15 @@ bool UpdatePopupDetector_Switch2::detect(const ImageViewRGB32& screen){
181181

182182
// cout << "white: " << white << endl;
183183

184+
#if 0
184185
ImageStats stats_box_mid = image_stats(extract_box_reference(screen, m_box_mid));
185186
if (stats_box_mid.stddev.sum() > 10){
186187
return false;
187188
}
188189
if (euclidean_distance(stats_box_top.average, stats_box_mid.average) > 10){
189190
return false;
190191
}
192+
#endif
191193

192194
ImageStats stats_left = image_stats(extract_box_reference(screen, m_left));
193195
// cout << stats_left.stddev << endl;

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class UpdatePopupDetector_Switch2 : public StaticScreenDetector{
4444
private:
4545
Color m_color;
4646
ImageFloatBox m_box_top;
47-
ImageFloatBox m_box_mid;
47+
// ImageFloatBox m_box_mid;
4848
ImageFloatBox m_top;
4949
ImageFloatBox m_left;
5050
ImageFloatBox m_bottom_solid;

SerialPrograms/Source/PokemonSwSh/Programs/PokemonSwSh_EncounterHandler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ void run_away(
6060
pbf_press_button(context, BUTTON_A, 80ms, 0ms);
6161
continue;
6262
default:
63+
context->logger().log("Unable to detect end of battle. Assume successful run away.", COLOR_ORANGE);
64+
return;
65+
#if 0
6366
throw OperationFailedException(
6467
ErrorReport::SEND_ERROR_REPORT,
6568
"Unable to run away. Are you stuck in the battle?",
6669
stream
6770
);
71+
#endif
6872
}
6973
}
7074
}

SerialPrograms/Source/PokemonSwSh/Programs/ShinyHuntAutonomous/PokemonSwSh_ShinyHuntAutonomous-Regi.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ void ShinyHuntAutonomousRegi::program(SingleSwitchProgramEnvironment& env, ProCo
143143
if (result.shiny_type == ShinyType::UNKNOWN){
144144
stats.add_error();
145145
pbf_mash_button(context, BUTTON_B, TICKS_PER_SECOND);
146-
try{
147-
run_away(env.console, context, EXIT_BATTLE_TIMEOUT0);
148-
}catch (OperationFailedException&){}
146+
run_away(env.console, context, EXIT_BATTLE_TIMEOUT0);
149147
error = true;
150148
continue;
151149
}

0 commit comments

Comments
 (0)