File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed
Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 66#include " Components/EffectSound/EffectSoundManager.h"
77#include " Components/MetaModifiers.h"
88#include " Effects/EffectCategory.h"
9+ #include " Effects/EffectThreads.h"
910#include " Effects/EffectTimedType.h"
1011#include " Effects/EnabledEffects.h"
1112#include " Effects/Register/RegisteredEffectsMetadata.h"
@@ -284,7 +285,18 @@ void EffectDispatcher::UpdateEffects(float deltaTime)
284285 m_PermanentEffects.clear ();
285286 SharedState.DispatchedEffectsLog .clear ();
286287
287- EffectThreads::StopThreadsImmediately ();
288+ static bool startedStopping = false ;
289+
290+ if (!startedStopping)
291+ {
292+ EffectThreads::StopThreadsImmediately ();
293+ startedStopping = true ;
294+ }
295+
296+ if (EffectThreads::GetThreadCount () > 0 )
297+ return ;
298+
299+ startedStopping = false ;
288300
289301 // Ensure player control isn't stuck in disabled state
290302 SET_PLAYER_CONTROL (PLAYER_ID (), true , 0 );
Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ namespace EffectThreads
7979 it = _StopThreadImmediately (it);
8080 }
8181
82+ int GetThreadCount ()
83+ {
84+ return m_Threads.size ();
85+ }
86+
8287 void PauseThisThread (DWORD timeMs)
8388 {
8489 auto fiber = GetCurrentFiber ();
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ namespace EffectThreads
5555 bool DoesThreadExist (LPVOID threadId);
5656 bool HasThreadOnStartExecuted (LPVOID threadId);
5757
58+ int GetThreadCount ();
59+
5860 bool IsThreadAnEffectThread ();
5961
6062 EffectThreadSharedData *GetThreadSharedData (LPVOID threadId);
Original file line number Diff line number Diff line change @@ -216,6 +216,17 @@ static void MainRun()
216216
217217 ms_Flags.ToggleModState = g_OptionsManager.GetConfigValue ({ " DisableStartup" }, OPTION_DEFAULT_DISABLE_STARTUP);
218218
219+ if (ComponentExists<EffectDispatcher>())
220+ {
221+ const auto dispatcher = GetComponent<EffectDispatcher>();
222+ dispatcher->ClearEffects ();
223+ while (dispatcher->IsClearingEffects ())
224+ {
225+ dispatcher->OnRun ();
226+ WAIT (0 );
227+ }
228+ }
229+
219230 for (auto &component : g_Components)
220231 component->OnModPauseCleanup ();
221232
You can’t perform that action at this time.
0 commit comments