From 94c14e34d759462e12ad965106986879b3758ada Mon Sep 17 00:00:00 2001 From: nhruo Date: Sat, 5 Aug 2023 22:44:30 +0300 Subject: [PATCH] stop LevelUpdate update chain after an error --- Celeste.Mod.mm/Patches/Level.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Celeste.Mod.mm/Patches/Level.cs b/Celeste.Mod.mm/Patches/Level.cs index 93b961d68..01cb1c33d 100644 --- a/Celeste.Mod.mm/Patches/Level.cs +++ b/Celeste.Mod.mm/Patches/Level.cs @@ -502,10 +502,13 @@ private void FixChaserStatesTimeStamp() { } } - private void CheckForErrors() { - if (patch_LevelEnter.ErrorMessage != null) { + private bool CheckForErrors() { + bool errorPresent = patch_LevelEnter.ErrorMessage != null; + if (errorPresent) { LevelEnter.Go(Session, false); } + + return errorPresent; } } @@ -704,6 +707,8 @@ public static void PatchLevelUpdate(ILContext context, CustomAttribute attrib) { // Insert CheckForErrors() at the beginning so we can display an error screen if needed cursor.Emit(OpCodes.Ldarg_0).Emit(OpCodes.Call, m_CheckForErrors); + // Insert an if statement that returns if we find an error at CheckForErrors + cursor.Emit(OpCodes.Brfalse, cursor.Next).Emit(OpCodes.Ret); // insert FixChaserStatesTimeStamp() cursor.Emit(OpCodes.Ldarg_0).Emit(OpCodes.Call, m_FixChaserStatesTimeStamp);