Skip to content

Commit 453f540

Browse files
committed
Fix race condition in Item Printer state machine.
1 parent 02fd340 commit 453f540

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ ItemPrinterPrizeResult ItemPrinterRNG::run_print_at_date(
340340
material,
341341
}
342342
);
343+
context.wait_for(std::chrono::milliseconds(250));
343344
next_wait_time = std::chrono::seconds(120);
344345
switch (ret){
345346
case 0:
@@ -396,8 +397,12 @@ ItemPrinterPrizeResult ItemPrinterRNG::run_print_at_date(
396397
pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
397398
resume_game_from_home(env.console, context, false);
398399

399-
if (!prompt.detect(env.console.video().snapshot())){
400+
context.wait_for(250ms);
401+
402+
VideoSnapshot snapshot = env.console.video().snapshot();
403+
if (!prompt.detect(snapshot)){
400404
env.log("Expected to be on prompt menu. Backing out.", COLOR_RED);
405+
// snapshot->save("noprompt.png");
401406
stats.errors++;
402407
env.update_stats();
403408
pbf_mash_button(context, BUTTON_B, 500);
@@ -406,7 +411,7 @@ ItemPrinterPrizeResult ItemPrinterRNG::run_print_at_date(
406411

407412
// Wait for trigger time.
408413
context.wait_until(trigger_time);
409-
pbf_press_button(context, BUTTON_A, 10, 10);
414+
pbf_press_button(context, BUTTON_A, 80ms, 500ms);
410415
continue;
411416
}
412417
case 4:{

0 commit comments

Comments
 (0)