From 59ac494c1981c6d977bdd81bf3524c890b2bb2a8 Mon Sep 17 00:00:00 2001 From: Boondorl Date: Thu, 30 Jan 2025 22:19:47 -0500 Subject: [PATCH 1/2] Make CopyBloodColor readonly Allows getting blood colors from default Actors. --- wadsrc/static/zscript/actors/actor.zs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 029855b2c..0893c107f 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1302,7 +1302,7 @@ class Actor : Thinker native native bool A_SetSize(double newradius = -1, double newheight = -1, bool testpos = false); native void A_SprayDecal(String name, double dist = 172, vector3 offset = (0, 0, 0), vector3 direction = (0, 0, 0), bool useBloodColor = false, color decalColor = 0, TranslationID translation = 0); native void A_SetMugshotState(String name); - native void CopyBloodColor(Actor other); + native void CopyBloodColor(readonly other); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recipient, int sourcefield, int recipientfield=AAPTR_DEFAULT, int flags=0); From f21b68c8f6914f2038fb7749727331078712b50a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 31 Jan 2025 06:05:55 -0500 Subject: [PATCH 2/2] - revamp priority changing on windows, add cvar `i_allowprioritychange` to disallow priority changing entirely, allowing batch scripts to dictate GZDoom's process priority --- src/common/platform/win32/i_input.cpp | 16 ++++++++++------ src/common/platform/win32/i_system.cpp | 5 ++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/common/platform/win32/i_input.cpp b/src/common/platform/win32/i_input.cpp index 45a74fe0c..5c25c3019 100644 --- a/src/common/platform/win32/i_input.cpp +++ b/src/common/platform/win32/i_input.cpp @@ -128,6 +128,7 @@ EXTERN_CVAR(Bool, i_pauseinbackground); CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR (Bool, i_allowprioritychange, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) static void I_CheckGUICapture () { @@ -485,13 +486,16 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_ACTIVATEAPP: AppActive = (wParam == TRUE); - if (wParam || !i_pauseinbackground) + if (!i_pauseinbackground && i_allowprioritychange) { - SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS); - } - else if (!noidle && !(sysCallbacks.NetGame && sysCallbacks.NetGame())) - { - SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); + if (wParam) + { + SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS); + } + else if (!noidle && !(sysCallbacks.NetGame && sysCallbacks.NetGame())) + { + SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); + } } S_SetSoundPaused (wParam); break; diff --git a/src/common/platform/win32/i_system.cpp b/src/common/platform/win32/i_system.cpp index caed820b0..c2615d51f 100644 --- a/src/common/platform/win32/i_system.cpp +++ b/src/common/platform/win32/i_system.cpp @@ -244,6 +244,9 @@ void CalculateCPUSpeed() // probably never use the performance statistics. min_diff = freq.LowPart * 11 / 200; + // just in case we were launched with a custom priority class, keep it + DWORD OldPriorityClass = GetPriorityClass(GetCurrentProcess()); + // Minimize the chance of task switching during the testing by going very // high priority. This is another reason to avoid timing for too long. SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); @@ -258,7 +261,7 @@ void CalculateCPUSpeed() do { QueryPerformanceCounter(&count1); } while ((count1.QuadPart - count2.QuadPart) < min_diff); ClockCalibration.Unclock(); - SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); + SetPriorityClass(GetCurrentProcess(), OldPriorityClass); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); PerfToSec = double(count1.QuadPart - count2.QuadPart) / (double(ClockCalibration.GetRawCounter()) * freq.QuadPart);