From aa47363129e78d8d8ff364f815891a24db8dbffd Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Thu, 1 Aug 2024 22:17:14 +1000 Subject: [PATCH] scr: update the centreprint buffer for the empty message Fixes a bug introduced by me in https://github.com/DarkPlacesEngine/darkplaces/pull/159 where a `svc_finale` message with the empty string could cause a previously displayed engine centreprint to appear again. Signed-off-by: bones_was_here --- cl_screen.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index 6c7e0318..7604fda6 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -143,19 +143,20 @@ for a few moments */ void SCR_CenterPrint(const char *str) { - if (str[0] == '\0') // happens when stepping out of a centreprint trigger on alk1.2 start.bsp - return; - - // Print the message to the console, but only if it's different to the previous message - if (strcmp(str, scr_centerstring)) - Con_CenterPrint(str); - dp_strlcpy(scr_centerstring, str, sizeof(scr_centerstring)); - scr_centertime_off = scr_centertime.value; scr_centertime_start = cl.time; -// count the number of lines for centering + // Print the message to the console and update the scr buffer + // but only if it's different to the previous message + if (strcmp(str, scr_centerstring) == 0) + return; + dp_strlcpy(scr_centerstring, str, sizeof(scr_centerstring)); scr_center_lines = 1; + if (str[0] == '\0') // happens when stepping out of a centreprint trigger on alk1.2 start.bsp + return; + Con_CenterPrint(str); + +// count the number of lines for centering while (*str) { if (*str == '\n') -- 2.39.2