Skip to content

Commit

Permalink
Fix #36 hang on load if license is acquired
Browse files Browse the repository at this point in the history
  • Loading branch information
katycat5e committed Aug 28, 2021
1 parent 92f59ea commit 5947c14
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions PJSaveLoadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,7 @@ public static void OnSaveGameLoaded()

if( loadedData != null )
{
if( loadedData.GetInt(VERSION_KEY) == CURRENT_DATA_VERSION )
{
if( loadedData.GetBool(HAS_LICENSE_P1_KEY) == true )
{
PassengerJobs.Log("Acquiring passengers license");
LicenseManager.AcquireJobLicense(PassLicenses.Passengers1);

Inventory.Instance.RemoveMoney(PassengerLicenseUtil.PASS1_COST);
}
}
else
if( loadedData.GetInt(VERSION_KEY) != CURRENT_DATA_VERSION )
{
PassengerJobs.Warning("Save file contains incompatible data version");
loadedData = null;
Expand All @@ -132,6 +122,17 @@ public static void OnSaveGameLoaded()
}
}

public static void OnInventoryStarted()
{
if( (loadedData != null) && (loadedData.GetBool(HAS_LICENSE_P1_KEY) == true) && Inventory.Exists )
{
PassengerJobs.Log("Acquiring passengers license");
LicenseManager.AcquireJobLicense(PassLicenses.Passengers1);

Inventory.Instance.RemoveMoney(PassengerLicenseUtil.PASS1_COST);
}
}

public static void InjectJobChains( JobsSaveGameData mainJobData )
{
// inject job chains into main game data
Expand Down Expand Up @@ -198,6 +199,15 @@ static void OnSaveLoaded( bool __result )
}
}

[HarmonyPatch(typeof(StartingItemsController), nameof(StartingItemsController.AddStartingItems))]
static class StartingItemsController_Patch
{
static void Postfix()
{
PJSaveLoadManager.OnInventoryStarted();
}
}

[HarmonyPatch(typeof(JobChainController), nameof(JobChainController.GetJobChainSaveData))]
static class JCC_GetJobChainSaveData_Patch
{
Expand Down

0 comments on commit 5947c14

Please sign in to comment.