From 1954074fb8c090bb8d1e151dafb8e536b62d60d8 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Fri, 22 Sep 2023 17:10:36 +0000 Subject: [PATCH] ChaosMod: Forcibly stop effect threads 60 seconds after effect stop request --- ChaosMod/Components/EffectDispatcher.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ChaosMod/Components/EffectDispatcher.cpp b/ChaosMod/Components/EffectDispatcher.cpp index 1db4c542b..a041f86c3 100644 --- a/ChaosMod/Components/EffectDispatcher.cpp +++ b/ChaosMod/Components/EffectDispatcher.cpp @@ -470,12 +470,6 @@ void EffectDispatcher::UpdateEffects(int deltaTime) activeEffects++; } - if (effect.IsStopping) - { - it++; - continue; - } - if (effect.HideEffectName && EffectThreads::HasThreadOnStartExecuted(effect.ThreadId)) { effect.HideEffectName = false; @@ -512,8 +506,16 @@ void EffectDispatcher::UpdateEffects(int deltaTime) if ((effect.MaxTime > 0.f && effect.Timer <= 0.f) || activeEffects > maxEffects) { - EffectThreads::StopThread(effect.ThreadId); - effect.IsStopping = true; + if (effect.Timer < -60.f) + { + // Effect took over 60 seconds to stop, forcibly stop it in a blocking manner + EffectThreads::StopThreadImmediately(effect.ThreadId); + } + else if (!effect.IsStopping) + { + EffectThreads::StopThread(effect.ThreadId); + effect.IsStopping = true; + } } it++;