Skip to content

Commit

Permalink
change the order of argument
Browse files Browse the repository at this point in the history
like Mojang launcher
  • Loading branch information
AlphaBs committed Oct 3, 2021
1 parent 366ae27 commit 6eecb83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
21 changes: 8 additions & 13 deletions CmlLib/Core/Launcher/MLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class MLaunch
"-XX:G1ReservePercent=20",
"-XX:MaxGCPauseMillis=50",
"-XX:G1HeapRegionSize=16M"
// "-Xss1M"
};

public MLaunch(MLaunchOption option)
Expand Down Expand Up @@ -109,29 +110,23 @@ public string[] CreateArg()
};

// JVM argument
var requireMemoryArgs = false;


// version-specific jvm arguments
if (version.JvmArguments != null)
args.AddRange(Mapper.MapInterpolation(version.JvmArguments, argDict));

// default jvm arguments
if (LaunchOption.JVMArguments != null)
args.AddRange(LaunchOption.JVMArguments);
else
{
args.AddRange(DefaultJavaParameter);
requireMemoryArgs = true;
}

// version-specific jvm arguments
if (version.JvmArguments != null)
args.AddRange(Mapper.MapInterpolation(version.JvmArguments, argDict));

// Xmx, Xms
if (requireMemoryArgs)
{
if (LaunchOption.MaximumRamMb > 0)
args.Add("-Xmx" + LaunchOption.MaximumRamMb + "m");

if (LaunchOption.MinimumRamMb > 0)
args.Add("-Xms" + LaunchOption.MinimumRamMb + "m");

args.AddRange(DefaultJavaParameter);
}

if (version.JvmArguments == null)
Expand Down
7 changes: 5 additions & 2 deletions CmlLib/Core/Version/MVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,25 @@ public void InheritFrom(MVersion parentVersion)
{
if (Libraries != null)
Libraries = Libraries.Concat(parentVersion.Libraries).ToArray();
//Libraries = parentVersion.Libraries.Concat(Libraries).ToArray();
else
Libraries = parentVersion.Libraries;
}

if (parentVersion.GameArguments != null)
{
if (GameArguments != null)
GameArguments = GameArguments.Concat(parentVersion.GameArguments).ToArray();
//GameArguments = GameArguments.Concat(parentVersion.GameArguments).ToArray();
GameArguments = parentVersion.GameArguments.Concat(GameArguments).ToArray();
else
GameArguments = parentVersion.GameArguments;
}

if (parentVersion.JvmArguments != null)
{
if (JvmArguments != null)
JvmArguments = JvmArguments.Concat(parentVersion.JvmArguments).ToArray();
//JvmArguments = JvmArguments.Concat(parentVersion.JvmArguments).ToArray();
JvmArguments = parentVersion.JvmArguments.Concat(JvmArguments).ToArray();
else
JvmArguments = parentVersion.JvmArguments;
}
Expand Down

0 comments on commit 6eecb83

Please sign in to comment.