Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Marsey
Browse files Browse the repository at this point in the history
  • Loading branch information
misandrie committed Nov 4, 2023
1 parent 30ec509 commit 2d5aa4f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 3 additions & 4 deletions Marsey/GameAssemblyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Marsey;
public class GameAssemblyManager
{
private static Harmony? _harmony;
private static readonly int MaxLoops = 50;

/// <summary>
/// Sets the _harmony field in the class.
Expand Down Expand Up @@ -53,7 +52,7 @@ public static void GetGameAssemblies(out Assembly? clientAss, out Assembly? robu
clientSharedAss = null;

int loops = 0;
while ((robustSharedAss == null || clientAss == null || clientSharedAss == null) && loops < MaxLoops)
while ((robustSharedAss == null || clientAss == null || clientSharedAss == null) && loops < MarseyVars.MaxLoops)
{
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (var e in asms)
Expand All @@ -77,10 +76,10 @@ public static void GetGameAssemblies(out Assembly? clientAss, out Assembly? robu
}

loops++;
Thread.Sleep(200);
Thread.Sleep(MarseyVars.LoopCooldown);
}

if (loops >= MaxLoops)
if (loops >= MarseyVars.MaxLoops)
{
Utility.Log(Utility.LogType.WARN, "Total amount of loops exhausted.");

Expand Down
2 changes: 1 addition & 1 deletion Marsey/MarseyPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void Boot(Assembly? robClientAssembly)
{
if (robClientAssembly == null) throw new Exception("Robust.Client was null.");

GameAssemblyManager.Init(new Harmony("com.validhunters.marseyloader"));
GameAssemblyManager.Init(new Harmony(MarseyVars.Identifier));

FileHandler.LoadAssemblies(new []{"Marsey", "Enabled"});

Expand Down
13 changes: 13 additions & 0 deletions Marsey/MarseyVars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Marsey;

public class MarseyVars
{
// Namespace identifier for Harmony
public const string Identifier = "com.validhunters.marseyloader";

// Max amount of loops allowed to catch game assemblies
public const int MaxLoops = 50;

// Cooldown to try the loop again, in ms
public const int LoopCooldown = 200;
}

0 comments on commit 2d5aa4f

Please sign in to comment.