Skip to content

Commit

Permalink
30 FPS patching
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Sep 5, 2015
1 parent 4e5e45c commit 2f10023
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions moduleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ public class MMPatchLoader : LoadingSystem
private static readonly List<ModuleManagerPostPatchCallback> postPatchCallbacks =
new List<ModuleManagerPostPatchCallback>();

private const float yieldInterval = 1f/30f; // Patch at ~30fps

public static MMPatchLoader Instance { get; private set; }

private void Awake()
Expand Down Expand Up @@ -577,7 +579,7 @@ private List<string> PrePatchInit()
envInfo += " " + Environment.OSVersion.Platform + " " + ModuleManager.intPtr.ToInt64().ToString("X16") + "\n";
//envInfo += " " + Convert.ToString(ModuleManager.intPtr.ToInt64(), 2) + " " + Convert.ToString(ModuleManager.intPtr.ToInt64() >> 63, 2) + "\n";
string gamePath = Environment.GetCommandLineArgs()[0];
envInfo += " Args: " + gamePath.Split(Path.DirectorySeparatorChar).Last() + string.Join(" ", Environment.GetCommandLineArgs().Skip(1).ToArray()) + "\n";
envInfo += " Args: " + gamePath.Split(Path.DirectorySeparatorChar).Last() + " " + string.Join(" ", Environment.GetCommandLineArgs().Skip(1).ToArray()) + "\n";
envInfo += " Executable SHA256 " + FileSHA(gamePath);

log(envInfo);
Expand Down Expand Up @@ -678,9 +680,6 @@ Coroutine StartCoroutine(IEnumerator enumerator, bool blocking)

private IEnumerator ProcessPatch(bool blocking)
{

AssemblyLoader.LoadedAssembly textureReplacer = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name.StartsWith("TextureReplacer", StringComparison.Ordinal));

IsCacheUpToDate();
yield return null;

Expand Down Expand Up @@ -1311,8 +1310,8 @@ public IEnumerator ApplyPatch(List<string> excludePaths, string Stage)
activity = "ModuleManager " + Stage;

UrlDir.UrlConfig[] allConfigs = GameDatabase.Instance.root.AllConfigs.ToArray();

int yieldRate = Math.Max(allConfigs.Length / 4, 10);
float nextYield = Time.realtimeSinceStartup + yieldInterval;

for (int modsIndex = 0; modsIndex < allConfigs.Length; modsIndex++)
{
Expand Down Expand Up @@ -1432,8 +1431,11 @@ public IEnumerator ApplyPatch(List<string> excludePaths, string Stage)
if (lastErrorCount < errorCount)
addErrorFiles(mod.parent, errorCount - lastErrorCount);
}
if (modsIndex % yieldRate == yieldRate - 1)
if (nextYield < Time.realtimeSinceStartup)
{
nextYield = Time.realtimeSinceStartup + yieldInterval;
yield return null;
}
}
}

Expand Down

0 comments on commit 2f10023

Please sign in to comment.