Skip to content

Commit

Permalink
Add failsafe to mod session loading (same as the base EverestModule c…
Browse files Browse the repository at this point in the history
…lass)
  • Loading branch information
maddie480 committed Mar 28, 2021
1 parent ede0ad7 commit 4aac513
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions UI/ReturnToLobbyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Monocle;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -282,9 +283,15 @@ private static bool loadModSessions(Session session) {
// restore all mod sessions we can restore.
foreach (EverestModule mod in Everest.Modules) {
if (mod._Session != null && sessions.TryGetValue(mod.Metadata.Name, out string savedSession)) {
// note: we are deserializing the session rather than just storing the object, because loading the session usually does that,
// and a mod could react to a setter on its session being called.
YamlHelper.DeserializerUsing(mod._Session).Deserialize(savedSession, mod.SessionType);
try {
// note: we are deserializing the session rather than just storing the object, because loading the session usually does that,
// and a mod could react to a setter on its session being called.
YamlHelper.DeserializerUsing(mod._Session).Deserialize(savedSession, mod.SessionType);
} catch (Exception e) {
// this is the same fallback message as the base EverestModule class if something goes wrong.
Logger.Log(LogLevel.Warn, "CollabUtils2/ReturnToLobbyHelper", "Failed to load the session of " + mod.Metadata.Name + "!");
Logger.LogDetailed(e);
}
}
}

Expand Down

0 comments on commit 4aac513

Please sign in to comment.