Skip to content

Commit

Permalink
stop LevelUpdate update chain after an error
Browse files Browse the repository at this point in the history
  • Loading branch information
nhruo123 committed Aug 5, 2023
1 parent f2e41f7 commit 94c14e3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Celeste.Mod.mm/Patches/Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 94c14e3

Please sign in to comment.