From bfefd2363e40795d47e3fa87c5a9babdb3dc6619 Mon Sep 17 00:00:00 2001 From: Boondorl Date: Sat, 7 Jun 2025 14:10:11 -0400 Subject: [PATCH] Stop HUD messages from ticking when game is paused These are often synchronized to the world so should be treated as such. --- src/g_statusbar/shared_sbar.cpp | 39 +++++++++++++++++-------------- src/scripting/vmthunks.cpp | 20 ++++++++++++++++ wadsrc/static/zscript/doombase.zs | 2 ++ 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 27575a5c6..94715337f 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -71,6 +71,8 @@ #define XHAIRPICKUPSIZE (2+XHAIRSHRINKSIZE) #define POWERUPICONSIZE 32 +int WorldPaused(); + IMPLEMENT_CLASS(DBaseStatusBar, false, true) IMPLEMENT_POINTERS_START(DBaseStatusBar) @@ -682,31 +684,34 @@ int DBaseStatusBar::GetPlayer () void DBaseStatusBar::Tick () { - PrevCrosshairSize = CrosshairSize; - - for (size_t i = 0; i < countof(Messages); ++i) + if (!WorldPaused()) { - DHUDMessageBase *msg = Messages[i]; + PrevCrosshairSize = CrosshairSize; - while (msg) + for (size_t i = 0; i < countof(Messages); ++i) { - DHUDMessageBase *next = msg->Next; + DHUDMessageBase* msg = Messages[i]; - if (msg->CallTick ()) + while (msg) { - DetachMessage(msg); - msg->Destroy(); + DHUDMessageBase* next = msg->Next; + + if (msg->CallTick()) + { + DetachMessage(msg); + msg->Destroy(); + } + msg = next; } - msg = next; - } - // If the crosshair has been enlarged, shrink it. - if (CrosshairSize > 1.) - { - CrosshairSize -= XHAIRSHRINKSIZE; - if (CrosshairSize < 1.) + // If the crosshair has been enlarged, shrink it. + if (CrosshairSize > 1.) { - CrosshairSize = 1.; + CrosshairSize -= XHAIRSHRINKSIZE; + if (CrosshairSize < 1.) + { + CrosshairSize = 1.; + } } } } diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 87a4858b2..099a98196 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -61,6 +61,9 @@ #include "texturemanager.h" #include "v_draw.h" +extern int paused; +extern bool pauseext; + DVector2 AM_GetPosition(); int Net_GetLatency(int *ld, int *ad); void PrintPickupMessage(bool localview, const FString &str); @@ -499,6 +502,23 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) return 0; } +int WorldPaused() +{ + if (paused) + return true; + + if (netgame || gamestate != GS_LEVEL) + return false; + + return pauseext || menuactive == MENU_On || ConsoleState != c_up; +} + +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, WorldPaused, WorldPaused) +{ + PARAM_PROLOGUE; + ACTION_RETURN_BOOL(WorldPaused()); +} + static sector_t *PointInSectorXY(FLevelLocals *self, double x, double y) { return self->PointInSector(x ,y); diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index 185a27f2a..79a96c30d 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -625,6 +625,8 @@ struct LevelLocals native native void SpawnParticle(FSpawnParticleParams p); native VisualThinker SpawnVisualThinker(Class type); + + clearscope native static bool WorldPaused(); } // a few values of this need to be readable by the play code.