From 9df433f89015f7b4525b59229bc1fb3062be9c60 Mon Sep 17 00:00:00 2001 From: Leaflet Date: Sun, 18 Jan 2026 17:12:04 +0800 Subject: [PATCH] Fix bug in pressany() --- include/screen.h | 1 + src/screen.c | 13 +++++++++---- utils/game/chicken.c | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/screen.h b/include/screen.h index c017a0f..76621a8 100644 --- a/include/screen.h +++ b/include/screen.h @@ -39,6 +39,7 @@ extern void clearscr(); extern int press_any_key(); extern int press_any_key_ex(const char *msg, int sec); +extern int press_any_key_no_prompt(int sec); extern void set_input_echo(int echo); diff --git a/src/screen.c b/src/screen.c index e75d55b..735fb66 100644 --- a/src/screen.c +++ b/src/screen.c @@ -98,16 +98,21 @@ inline int press_any_key() int press_any_key_ex(const char *msg, int sec) { - int ch = 0; - int duration = 0; - time_t t_begin = time(NULL); - moveto(SCREEN_ROWS, 0); clrtoeol(); prints(msg); iflush(); + return press_any_key_no_prompt(sec); +} + +inline int press_any_key_no_prompt(int sec) +{ + int ch = 0; + int duration = 0; + time_t t_begin = time(NULL); + igetch_reset(); do diff --git a/utils/game/chicken.c b/utils/game/chicken.c index f9cf326..59fbbcd 100644 --- a/utils/game/chicken.c +++ b/utils/game/chicken.c @@ -672,7 +672,7 @@ int pressany(int i) moveto(23, 0); prints(" %s ", cstate[i]); iflush(); - ch = igetch_t(MIN(BBS_max_user_idle_time, 60)); + ch = press_any_key_no_prompt(60); moveto(23, 0); clrtoeol(); iflush(); @@ -688,7 +688,7 @@ int guess() clrtoeol(); iflush(); - ch = igetch_t(MIN(BBS_max_user_idle_time, 60)); + ch = press_any_key_no_prompt(60); if ((ch != '1') && (ch != '2') && (ch != '3')) { return -1; // error input