Skip to content

Commit

Permalink
generic infinite loop catcher. warns if no adv was spent for 10 adv i…
Browse files Browse the repository at this point in the history
…n a row. aborts once it reaches 30 in a row.
  • Loading branch information
taltamir committed Sep 4, 2023
1 parent 9f15554 commit fb2c183
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions RELEASE/scripts/autoscend/auto_post_adv.ash
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,31 @@ boolean auto_post_adventure()
remove_property("auto_combatDirective");
remove_property("auto_digitizeDirective");
//try to catch infinite loop where we repeatedly try to do the same thing.
//works with code found in auto_pre_adv.ash
if(my_session_adv() == get_property("_auto_inf_session_adv").to_int())
{
auto_log_debug("auto_post_adv.ash detected that no adventure was spent");
//count how many times in a row we went with no adv spent
set_property("_auto_inf_counter", get_property("_auto_inf_counter").to_int()+1);
if(get_property("_auto_inf_counter").to_int() >= 30)
{
auto_log_error("no adventure was spent " +get_property("_auto_inf_counter")+ " times in a row which suggests we are stuck in an infinite loop. Stopping autoscend");
remove_property("_auto_inf_counter");
set_property("auto_interrupt", true);
}
else if(get_property("_auto_inf_counter").to_int() > 10)
{
auto_log_warning("no adventure was spent " +get_property("_auto_inf_counter")+ " times in a row");
}
}
else //clear values
{
remove_property("_auto_inf_counter");
}
auto_log_info("Post Adventure done, beep.", "purple");
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions RELEASE/scripts/autoscend/auto_pre_adv.ash
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ boolean auto_pre_adventure()
set_property("auto_priorLocation", place);
auto_log_info("Pre Adventure at " + place + " done, beep.", "blue");

//try to catch infinite loop where we repeatedly try to do the same thing.
//works with code found in auto_post_adv.ash
set_property("_auto_inf_session_adv", my_session_adv());

//to avoid constant flipping on the MCD. change it right before adventuring
int mcd_target = get_property("auto_mcd_target").to_int();
if(current_mcd() != mcd_target)
Expand Down

0 comments on commit fb2c183

Please sign in to comment.