Skip to content

Commit c5a7375

Browse files
committed
Fix date spam routines not detecting console type.
1 parent f20db02 commit c5a7375

File tree

6 files changed

+66
-23
lines changed

6 files changed

+66
-23
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 = 3;
29+
const int PROGRAM_VERSION_PATCH = 4;
3030

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

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
#include "NintendoSwitch/Programs/DateManip/NintendoSwitch_DateManip_24h.h"
132132
#include "CommonTools/Images/BinaryImage_FilterRgb32.h"
133133
#include "NintendoSwitch/Inference/NintendoSwitch2_BinarySliderDetector.h"
134+
#include "PokemonSwSh/Programs/PokemonSwSh_GameEntry.h"
135+
#include "PokemonSwSh/PokemonSwSh_Settings.h"
134136

135137
#include <QPixmap>
136138
#include <QVideoFrame>
@@ -289,6 +291,16 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
289291
// ImageRGB32 image1("menu-dark.png");
290292
// ImageRGB32 image2("menu-jpn.png");
291293

294+
295+
env.log("Touching date to prevent rollover.");
296+
pbf_press_button(context, BUTTON_HOME, 160ms, PokemonSwSh::GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
297+
touch_date_from_home(console, context, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
298+
resume_game_no_interact(console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
299+
300+
301+
302+
303+
#if 0
292304
auto screenshot = feed.snapshot();
293305

294306

@@ -298,7 +310,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
298310
for (auto& item : sliders){
299311
cout << item.first << " : " << item.second.min_y << endl;
300312
}
301-
313+
#endif
302314

303315
#if 0
304316
ImageFloatBox box(0.842007, 0.626446, 0.050186, 0.049587);

SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
*/
66

77
#include "Common/Cpp/Exceptions.h"
8-
#include "CommonFramework/Exceptions/OperationFailedException.h"
8+
//#include "CommonFramework/Exceptions/OperationFailedException.h"
99
//#include "CommonFramework/ImageTools/ImageStats.h"
1010
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1111
//#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
12-
#include "CommonTools/Async/InferenceRoutines.h"
12+
//#include "CommonTools/Async/InferenceRoutines.h"
1313
#include "Controllers/ControllerTypes.h"
1414
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1515
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1616
#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h"
17-
#include "NintendoSwitch/Inference/NintendoSwitch_HomeMenuDetector.h"
17+
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
18+
//#include "NintendoSwitch/Inference/NintendoSwitch_HomeMenuDetector.h"
1819
//#include "NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h"
1920
#include "NintendoSwitch_HomeToDateTime.h"
2021

@@ -53,23 +54,7 @@ bool home_to_date_time_Switch1_feedback(ConsoleHandle& console, ProControllerCon
5354

5455
// Returns true if success. False if not supported.
5556
bool home_to_date_time_with_feedback(ConsoleHandle& console, ProControllerContext& context, bool to_date_change){
56-
for (size_t attempts = 0;; attempts++){
57-
HomeMenuWatcher home_menu(console, 100ms);
58-
int ret = wait_until(
59-
console, context, 5000ms,
60-
{home_menu}
61-
);
62-
if (ret == 0){
63-
break;
64-
}
65-
if (attempts == 2){
66-
OperationFailedException::fire(
67-
ErrorReport::SEND_ERROR_REPORT,
68-
"Unable to find Switch Home",
69-
console
70-
);
71-
}
72-
}
57+
wait_for_home(console, context);
7358

7459
ConsoleTypeDetector_Home detector(console);
7560
ConsoleType console_type = detector.detect_only(console.video().snapshot());

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,42 @@ namespace NintendoSwitch{
3131

3232

3333

34+
35+
36+
37+
void wait_for_home(ConsoleHandle& console, ProControllerContext& context){
38+
// Feedback not available. Just assume we're already on Home.
39+
if (!console.video().snapshot()){
40+
return;
41+
}
42+
43+
for (size_t attempts = 0;; attempts++){
44+
HomeMenuWatcher home_menu(console, 100ms);
45+
int ret = wait_until(
46+
console, context, 5000ms,
47+
{home_menu}
48+
);
49+
if (ret == 0){
50+
break;
51+
}
52+
if (attempts == 2){
53+
OperationFailedException::fire(
54+
ErrorReport::SEND_ERROR_REPORT,
55+
"Unable to find Switch Home",
56+
console
57+
);
58+
}
59+
}
60+
}
61+
62+
63+
64+
65+
66+
67+
68+
69+
3470
void resume_game_from_home(
3571
ConsoleHandle& console, ProControllerContext& context,
3672
bool skip_home_press

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ namespace PokemonAutomation{
1616
namespace NintendoSwitch{
1717

1818

19+
void wait_for_home(ConsoleHandle& console, ProControllerContext& context);
20+
21+
22+
1923
void resume_game_from_home(
2024
ConsoleHandle& console, ProControllerContext& context,
2125
bool skip_home_press = false

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_DateSpam.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
*/
66

77
#include "ClientSource/Libraries/MessageConverter.h"
8-
#include "Controllers/ControllerTypes.h"
8+
//#include "CommonFramework/VideoPipeline/VideoFeed.h"
9+
//#include "Controllers/ControllerTypes.h"
910
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
11+
//#include "NintendoSwitch/Inference/NintendoSwitch_HomeMenuDetector.h"
1012
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
1113
#include "NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h"
1214
#include "NintendoSwitch/Programs/DateSpam/NintendoSwitch_RollDateForward1.h"
@@ -142,6 +144,8 @@ void touch_date_from_home(
142144
ConsoleHandle& console, ProControllerContext& context,
143145
Milliseconds settings_to_home_delay
144146
){
147+
wait_for_home(console, context);
148+
145149
ConsoleType type = console.state().console_type();
146150

147151
if (is_switch1(type)){
@@ -211,6 +215,8 @@ void rollback_hours_from_home(
211215
uint8_t hours,
212216
Milliseconds settings_to_home_delay
213217
){
218+
wait_for_home(console, context);
219+
214220
ConsoleType type = console.state().console_type();
215221

216222
if (is_switch1(type)){

0 commit comments

Comments
 (0)