Skip to content

Commit

Permalink
Fix tModLoader#702, always load ModLoaderMod when cancel is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
Chicken-Bones committed Oct 30, 2019
1 parent 7222641 commit a5c09d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions patches/tModLoader/Terraria.ModLoader/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,18 @@ private static void Load(CancellationToken token = default) {

if (OnSuccessfulLoad != null) {
OnSuccessfulLoad();
OnSuccessfulLoad = null;
}
else {
Main.menuMode = 0;
}
}
catch when (token.IsCancellationRequested) {
if (Unload())
Main.menuMode = Interface.modsMenuID;
// cancel needs to reload with ModLoaderMod and all others skipped
skipLoad = true;
OnSuccessfulLoad += () => Main.menuMode = Interface.modsMenuID;

isLoading = false;
Load(); // don't provide a token, loading just ModLoaderMod should be quick
}
catch (Exception e) {
var responsibleMods = new List<string>();
Expand Down Expand Up @@ -172,10 +175,13 @@ private static void Load(CancellationToken token = default) {
foreach (var mod in responsibleMods)
DisableMod(mod);

isLoading = false; // disable loading flag, because server will just instantly retry reload
DisplayLoadError(msg, e, e.Data.Contains("fatal"), responsibleMods.Count == 0);
}
finally {
isLoading = false;
OnSuccessfulLoad = null;
skipLoad = false;
}
}

Expand Down

0 comments on commit a5c09d7

Please sign in to comment.