From 974aacfb7b62df176d1758ed7baeb8ab34c601ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 4 Mar 2025 10:25:02 -0300 Subject: [PATCH] fix crash if chat key is pressed during the loading screen --- src/ct_chat.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index a12bb9f205..b6d96aa4e7 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -251,14 +251,18 @@ void CT_Drawer (void) { // [MK] allow the status bar to take over chat prompt drawing bool skip = false; - IFVIRTUALPTR(StatusBar, DBaseStatusBar, DrawChat) + + if(StatusBar) { - FString txt = ChatQueue; - VMValue params[] = { (DObject*)StatusBar, &txt }; - int rv; - VMReturn ret(&rv); - VMCall(func, params, countof(params), &ret, 1); - if (!!rv) return; + IFVIRTUALPTR(StatusBar, DBaseStatusBar, DrawChat) + { + FString txt = ChatQueue; + VMValue params[] = { (DObject*)StatusBar, &txt }; + int rv; + VMReturn ret(&rv); + VMCall(func, params, countof(params), &ret, 1); + if (!!rv) return; + } } FStringf prompt("%s ", GStrings.GetString("TXT_SAY")); @@ -269,8 +273,8 @@ void CT_Drawer (void) scalex = 1; int scale = active_con_scale(drawer); int screen_width = twod->GetWidth() / scale; - int screen_height= twod->GetHeight() / scale; - int st_y = StatusBar->GetTopOfStatusbar() / scale; + int screen_height = twod->GetHeight() / scale; + int st_y = StatusBar ? (StatusBar->GetTopOfStatusbar() / scale) : screen_height; y += ((twod->GetHeight() == viewheight && viewactive) || gamestate != GS_LEVEL) ? screen_height : st_y;