From 6de9afa870b287ef615e055d7e058f93d500b06d Mon Sep 17 00:00:00 2001 From: RealityMachina Date: Sun, 2 Dec 2018 15:17:08 -0500 Subject: [PATCH] Attempt at synchorizing with 1.3/Flashpoint, and adding in clauses to prevent the whole game from crashing if it runs into a problem trying to serialize known panic states. --- PunchinOut/SaveGamePatcher.cs | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/PunchinOut/SaveGamePatcher.cs b/PunchinOut/SaveGamePatcher.cs index 2278ffe..e4e01a4 100644 --- a/PunchinOut/SaveGamePatcher.cs +++ b/PunchinOut/SaveGamePatcher.cs @@ -15,25 +15,49 @@ public static class GameInstanceSave_Constructor_Patch { static void Postfix(GameInstanceSave __instance) { - Holder.SerializeStorageJson(__instance.InstanceGUID, __instance.SaveTime); + try + { + Holder.SerializeStorageJson(__instance.InstanceGUID, __instance.SaveTime); + } + catch + { + // TODO: should do something here if the holder reports an error trying to serialize + return; + } } } [HarmonyPatch(typeof(GameInstance), "Load")] public static class GameInstance_Load_Patch { - static void Prefix(GameInstanceSave save) + static void Prefix(GameInstance __instance, GameInstanceSave save) { - Holder.Resync(save.SaveTime); + try + { + Holder.Resync(save.SaveTime); + } + catch + { + // TODO: should do something here if the holder reports an error trying to serialize + return; + } } } [HarmonyPatch(typeof(SimGameState), "_OnFirstPlayInit")] public static class SimGameState_FirstPlayInit_Patch { - static void Postfix(SimGameState __instance) //we're doing a new campaign, so we need to sync the json with the new addition + static void Postfix(SimGameState __instance, SimGameState.SimGameType gameType, bool allowDebug) //we're doing a new campaign, so we need to sync the json with the new addition { - Holder.SyncNewCampaign(); + try + { + Holder.SyncNewCampaign(); + } + catch + { + // TODO: should do something here if the holder reports an error + return; + } } } }