Skip to content

Commit

Permalink
Attempt at synchorizing with 1.3/Flashpoint, and adding in clauses to…
Browse files Browse the repository at this point in the history
… prevent the whole game from crashing if it runs into a problem trying to serialize known panic states.
  • Loading branch information
RealityMachina committed Dec 2, 2018
1 parent ab70e9a commit 6de9afa
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions PunchinOut/SaveGamePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}

0 comments on commit 6de9afa

Please sign in to comment.