From 3e1311473d3d47f73967a8d183b50e30079cdb32 Mon Sep 17 00:00:00 2001 From: zander3312 Date: Fri, 17 Oct 2025 20:46:09 +0000 Subject: [PATCH] Improved netgame chat input eating --- src/d_clisrv.c | 2 +- src/d_main.cpp | 2 +- src/g_game.c | 2 ++ src/hu_stuff.c | 1 + src/hu_stuff.h | 3 +++ src/k_menu.h | 2 +- src/k_menufunc.c | 6 +++++- 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7d3fbfe60..6fed621db 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2247,7 +2247,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic #ifdef HAVE_THREADS I_lock_mutex(&k_menu_mutex); #endif - M_UpdateMenuCMD(0, true); + M_UpdateMenuCMD(0, true, false); if (cl_mode == CL_CONFIRMCONNECT) { diff --git a/src/d_main.cpp b/src/d_main.cpp index f62beab0b..79fd36704 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -343,7 +343,7 @@ void D_ProcessEvents(boolean callresponders) // Update menu CMD for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - M_UpdateMenuCMD(i, false); + M_UpdateMenuCMD(i, false, chat_keydown); } } diff --git a/src/g_game.c b/src/g_game.c index fff406bdb..c5139ad89 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1413,6 +1413,7 @@ boolean G_Responder(event_t *ev) if (HU_Responder(ev)) { hu_keystrokes = true; + chat_keydown = true; return true; // chat ate the event } } @@ -1522,6 +1523,7 @@ boolean G_Responder(event_t *ev) return true; case ev_keyup: + chat_keydown = false; // prevents repeat inputs from inputs made with chat open return false; // always let key up events filter down case ev_mouse: diff --git a/src/hu_stuff.c b/src/hu_stuff.c index fe66f84bf..d1cc516bd 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -85,6 +85,7 @@ patch_t *frameslash; // framerate stuff. Used in screen.c static player_t *plr; boolean hu_keystrokes; // :) +boolean chat_keydown; boolean chat_on; // entering a chat message? boolean g_voicepushtotalk_on; // holding PTT? static char w_chat[HU_MAXMSGLEN + 1]; diff --git a/src/hu_stuff.h b/src/hu_stuff.h index b3e1ebbec..1b84f30e7 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -124,6 +124,9 @@ typedef enum // some functions void HU_AddChatText(const char *text, boolean playsound); +// set true when key is pressed while chat is open +extern boolean chat_keydown; + // set true when entering a chat message extern boolean chat_on; diff --git a/src/k_menu.h b/src/k_menu.h index 04d3d6d29..353db4cbb 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -748,7 +748,7 @@ void M_SetMenuDelay(UINT8 i); void M_SortServerList(void); -void M_UpdateMenuCMD(UINT8 i, boolean bailrequired); +void M_UpdateMenuCMD(UINT8 i, boolean bailrequired, boolean chat_open); boolean M_Responder(event_t *ev); boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt); boolean M_MenuButtonHeld(UINT8 pid, UINT32 bt); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index dad4391ac..6c08e6c4c 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -1084,7 +1084,7 @@ void M_SetMenuDelay(UINT8 i) } } -void M_UpdateMenuCMD(UINT8 i, boolean bailrequired) +void M_UpdateMenuCMD(UINT8 i, boolean bailrequired, boolean chat_open) { UINT8 mp = max(1, setup_numplayers); @@ -1097,6 +1097,10 @@ void M_UpdateMenuCMD(UINT8 i, boolean bailrequired) menucmd[i].buttonsHeld = menucmd[i].buttons; menucmd[i].buttons = 0; + // Eat inputs made when chat is open + if (chat_open) + return; + if (G_PlayerInputDown(i, gc_screenshot, mp)) { menucmd[i].buttons |= MBT_SCREENSHOT; } if (G_PlayerInputDown(i, gc_startmovie, mp)) { menucmd[i].buttons |= MBT_STARTMOVIE; } if (G_PlayerInputDown(i, gc_startlossless, mp)) { menucmd[i].buttons |= MBT_STARTLOSSLESS; }