22
33#include " Main.h"
44
5+ #include " Components/CrossingChallenge.h"
56#include " Components/DebugMenu.h"
67#include " Components/DebugSocket.h"
78#include " Components/EffectDispatchTimer.h"
@@ -31,6 +32,7 @@ static struct
3132 bool ClearEffectsShortcutEnabled = false ;
3233 bool ToggleModShortcutEnabled = false ;
3334 bool ToggleModState = false ;
35+ bool DisableMod = false ;
3436 bool PauseTimerShortcutEnabled = false ;
3537 bool HaveLateHooksRan = false ;
3638 bool AntiSoftlockShortcutEnabled = false ;
@@ -204,6 +206,8 @@ static void Init()
204206
205207 INIT_COMPONENT (" HelpTextQueue" , " script help text queue" , HelpTextQueue);
206208
209+ INIT_COMPONENT (" CrossingChallenge" , " Crossing Challenge" , CrossingChallenge);
210+
207211#ifdef WITH_DEBUG_PANEL_SUPPORT
208212 if (DoesFeatureFlagExist (" enabledebugsocket" ))
209213 INIT_COMPONENT (" DebugSocket" , " Debug Websocket" , DebugSocket);
@@ -227,6 +231,15 @@ static void MainRun()
227231
228232 ms_Flags.ToggleModState = g_OptionsManager.GetConfigValue ({ " DisableStartup" }, OPTION_DEFAULT_DISABLE_STARTUP);
229233
234+ if (!g_Components.empty ())
235+ {
236+ for (auto component : g_Components)
237+ component->OnModPauseCleanup ();
238+
239+ g_Components.clear ();
240+ }
241+ ClearEntityPool ();
242+
230243 Init ();
231244
232245 bool isDisabled = false ;
@@ -246,10 +259,8 @@ static void MainRun()
246259 }
247260 }
248261
249- if (ms_Flags.ToggleModState )
262+ if (ms_Flags.ToggleModState || ms_Flags. DisableMod )
250263 {
251- ms_Flags.ToggleModState = false ;
252-
253264 if (!isDisabled)
254265 {
255266 isDisabled = true ;
@@ -273,7 +284,7 @@ static void MainRun()
273284 for (auto component : g_Components)
274285 component->OnModPauseCleanup ();
275286 }
276- else
287+ else if (ms_Flags. ToggleModState )
277288 {
278289 isDisabled = false ;
279290
@@ -288,6 +299,9 @@ static void MainRun()
288299 // Restart the main part of the mod completely
289300 Init ();
290301 }
302+
303+ ms_Flags.ToggleModState = false ;
304+ ms_Flags.DisableMod = false ;
291305 }
292306
293307 if (isDisabled)
@@ -323,8 +337,8 @@ static void MainRun()
323337
324338 for (auto component : g_Components)
325339 component->OnRun ();
340+ }
326341 }
327- }
328342
329343namespace Main
330344{
@@ -337,6 +351,8 @@ namespace Main
337351
338352 void OnCleanup ()
339353 {
354+ for (auto component : g_Components)
355+ component->OnModPauseCleanup ();
340356 }
341357
342358 void OnKeyboardInput (DWORD key, WORD repeats, BYTE scanCode, BOOL isExtended, BOOL isWithAlt, BOOL wasDownBefore,
@@ -391,4 +407,9 @@ namespace Main
391407 for (auto component : g_Components)
392408 component->OnKeyInput (key, wasDownBefore, isUpNow, isCtrlPressed, isShiftPressed, isWithAlt);
393409 }
410+
411+ void Stop ()
412+ {
413+ ms_Flags.DisableMod = true ;
414+ }
394415}
0 commit comments