Skip to content

Commit

Permalink
Maybe fixed game freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
kinsi55 committed Sep 6, 2021
1 parent abb3681 commit befb8a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions HarmonyPatches/GameScenesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,14 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
// Original GC call, replaced with our custom logic
list[422].operand = AccessTools.Method(typeof(PatchGameScenesManager), nameof(__PostFix));

// Exit point for original UnloadUnusedAssets() call
var UnloadUnusedAssetsExit = il.DefineLabel();
list[413].labels.Add(UnloadUnusedAssetsExit);

// Add a skip conditional for the original UnloadUnusedAssets() call
list.InsertRange(patchOffset, new[] {
// We need to clear the old __current so the game doesnt explode
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(list[patchOffset]),
new CodeInstruction(OpCodes.Ldnull),
new CodeInstruction(OpCodes.Stfld, list[412].operand),

new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PatchGameScenesManager), nameof(__IsEnabled))),
new CodeInstruction(OpCodes.Brtrue, UnloadUnusedAssetsExit)
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PatchGameScenesManager), nameof(__IsEnabled))).MoveLabelsFrom(list[patchOffset]),
/*
* The UnloadUnusedAssets call will set the state to 7 and continue with that on the next tick - This just jumps straight to that
* It should already have a label for the enumator switch case so this is an extra failsafe I guess
*/
new CodeInstruction(OpCodes.Brtrue, list[419].labels[0])
});

Plugin.Log.Info("Patched GameScenesManager");
Expand Down Expand Up @@ -91,6 +86,7 @@ public static void __PostFix() {
//return;
// The second condition is a failsafe
} else if(YES == "GameCore") {
Application.backgroundLoadingPriority = ThreadPriority.Low;
isStartingSong = false;
isInSong = true;
if(gcSkipCounterGame++ % Configuration.PluginConfig.Instance.GcInterval != 0) return;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "GottaGoFast",
"name": "Gotta Go Fast",
"author": "Kinsi55",
"version": "0.1.1",
"version": "0.1.2",
"description": "Significantly decreases the time it takes to (re)start songs",
"gameVersion": "1.16.2",
"dependsOn": {
Expand Down

0 comments on commit befb8a3

Please sign in to comment.