diff --git a/include/decl.h b/include/decl.h index 96a0ce9c7..aa8b02b51 100644 --- a/include/decl.h +++ b/include/decl.h @@ -201,6 +201,9 @@ struct instance_globals_b { /* zap.c */ struct monst *buzzer; /* zapper/caster/breather who initiates buzz() */ + /* new */ + boolean bot_disabled; + boolean havestate; unsigned long magic; /* validate that structure layout is preserved */ }; diff --git a/include/hack.h b/include/hack.h index 1ad6027ca..270b45fc8 100644 --- a/include/hack.h +++ b/include/hack.h @@ -763,7 +763,7 @@ struct sinfo { int in_checkpoint; /* saving insurance checkpoint */ int in_parseoptions; /* in parseoptions */ int in_role_selection; /* role/race/&c selection menus in progress */ - int in_getlin; /* inside interface getline routine */ + int in_getlin; /* inside interface getlin routine */ int config_error_ready; /* config_error_add is ready, available */ int beyond_savefile_load; /* set when past savefile loading */ #ifdef PANICLOG diff --git a/src/botl.c b/src/botl.c index f0534b480..1e1fb7c24 100644 --- a/src/botl.c +++ b/src/botl.c @@ -245,7 +245,7 @@ do_statusline2(void) void bot(void) { - if (gp.program_state.in_getlin) + if (gb.bot_disabled) return; /* dosave() flags completion by setting u.uhp to -1; suppress_map_output() covers program_state.restoring and is used for status as well as map */ @@ -267,7 +267,7 @@ bot(void) void timebot(void) { - if (gp.program_state.in_getlin) + if (gb.bot_disabled) return; /* we're called when iflags.time_botl is set and general gc.context.botl is clear; iflags.time_botl gets set whenever gm.moves changes value diff --git a/src/decl.c b/src/decl.c index c47879468..03c6b5559 100644 --- a/src/decl.c +++ b/src/decl.c @@ -248,6 +248,7 @@ const struct instance_globals_b g_init_b = { FALSE, /* bucx_filter */ /* zap.c */ NULL, /* buzzer -- monst that zapped/cast/breathed to initiate buzz() */ + FALSE, /* bot_disabled */ TRUE, /* havestate*/ IVMAGIC /* b_magic to validate that structure layout has been preserved */ diff --git a/src/end.c b/src/end.c index 1791a29dd..416e77d47 100644 --- a/src/end.c +++ b/src/end.c @@ -851,6 +851,7 @@ panic VA_DECL(const char *, str) if (gp.program_state.panicking++) NH_abort(NULL); /* avoid loops - this should never happen*/ + gb.bot_disabled = TRUE; if (iflags.window_inited) { raw_print("\r\nOops..."); wait_synch(); /* make sure all pending output gets flushed */ diff --git a/src/windows.c b/src/windows.c index f710b4648..ccd4477ee 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1682,8 +1682,12 @@ get_menu_coloring(const char *str, int *color, int *attr) void getlin(const char *query, register char *bufp) { + boolean old_bot_disabled = gb.bot_disabled; + gp.program_state.in_getlin = 1; + gb.bot_disabled = TRUE; (*windowprocs.win_getlin)(query, bufp); + gb.bot_disabled = old_bot_disabled; gp.program_state.in_getlin = 0; } /*windows.c*/ diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index fffcffc95..a3ccae78d 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -152,7 +152,7 @@ curses_status_update( if (fldidx != BL_FLUSH) { if (fldidx < 0 || fldidx >= MAXBLSTATS) { - gc.context.botlx = gc.context.botl = FALSE; /* avoid bot() */ + /* panic immediately sets gb.bot_disabled to avoid bot() */ panic("curses_status_update(%d)", fldidx); } changed_fields |= (1 << fldidx);