Apply suggestions from code review

develop
Josh Cooper 2022-10-24 17:57:14 -07:00 committed by GitHub
parent 754e1dd4ac
commit 606f204b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

@ -40,7 +40,7 @@ void onTick(color_ostream& out, void* tick);
void onJobStart(color_ostream &out, void* job); void onJobStart(color_ostream &out, void* job);
void onJobCompletion(color_ostream &out, void* job); void onJobCompletion(color_ostream &out, void* job);
uint64_t tick_threshold = 50; uint64_t tick_threshold = 1000;
bool focus_jobs_enabled = false; bool focus_jobs_enabled = false;
bool disengage_enabled = false; bool disengage_enabled = false;
bool unpause_enabled = false; bool unpause_enabled = false;
@ -174,7 +174,8 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) {
} }
} }
} }
while (unpause_enabled && !world->status.popups.empty()) { int failsafe = 0;
while (unpause_enabled && !world->status.popups.empty() && ++failsafe <= 10) {
// dismiss announcement popup(s) // dismiss announcement popup(s)
Gui::getCurViewscreen(true)->feed_key(interface_key::CLOSE_MEGA_ANNOUNCEMENT); Gui::getCurViewscreen(true)->feed_key(interface_key::CLOSE_MEGA_ANNOUNCEMENT);
if (World::ReadPauseState()) { if (World::ReadPauseState()) {
@ -182,6 +183,9 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) {
World::SetPauseState(false); World::SetPauseState(false);
} }
} }
if (failsafe) {
out.printerr("spectate encountered a problem dismissing a popup!");
}
if (disengage_enabled && !World::ReadPauseState()) { if (disengage_enabled && !World::ReadPauseState()) {
if (our_dorf && our_dorf->id != df::global::ui->follow_unit) { if (our_dorf && our_dorf->id != df::global::ui->follow_unit) {
plugin_enable(out, false); plugin_enable(out, false);