Skip to content

Commit

Permalink
Allow content bundles to be marked as "Server GC"
Browse files Browse the repository at this point in the history
A content bundle (replay) can now specify "please use server GC thanks"

Also cleaned up the RedialApi env var clearing stuff a bit.

Launcher side of #177
  • Loading branch information
PJB3005 committed Sep 7, 2024
1 parent 197244f commit c72dc75
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions SS14.Launcher.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GC/@EntryIndexedValue">GC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VM/@EntryIndexedValue">VM</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Avalonia/@EntryIndexedValue">True</s:Boolean>
Expand Down
7 changes: 7 additions & 0 deletions SS14.Launcher/Models/Connector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ private async Task LaunchContentBundleInternal(IStorageFile file, CancellationTo
//

installation = await InstallContentBundleAsync(zipFile, zipHash, metadata, cancel);

if (metadata.ServerGC == true)
installation = installation with { ServerGC = true };
}

Log.Debug("Launching client");
Expand Down Expand Up @@ -467,6 +470,9 @@ private async Task<ContentLaunchInfo> InstallContentBundleAsync(
EnvVar("DOTNET_TieredPGO", "1");
EnvVar("DOTNET_ReadyToRun", "0");

if (launchInfo.ServerGC)
EnvVar("DOTNET_gcServer", "1");

ConfigureMultiWindow(launchInfo, startInfo);

// DON'T ENABLE THIS THE LOADER USES THE LAUNCHER .NET VERSION ALWAYS SO ROLLFORWARD SHOULDN'T BE SPECIFIED.
Expand Down Expand Up @@ -688,6 +694,7 @@ public ConnectException(ConnectionStatus status, Exception inner)
}

public sealed record ContentBundleMetadata(
[property: JsonPropertyName("server_gc")] bool? ServerGC,
[property: JsonPropertyName("engine_version")] string EngineVersion,
[property: JsonPropertyName("base_build")] ContentBundleBaseBuild? BaseBuild
);
Expand Down
2 changes: 1 addition & 1 deletion SS14.Launcher/Models/ContentLaunchInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
/// <summary>
/// Information loaded by the updater that we need to launch the game.
/// </summary>
public sealed record ContentLaunchInfo(long Version, (string Module, string Version)[] ModuleInfo);
public sealed record ContentLaunchInfo(long Version, (string Module, string Version)[] ModuleInfo, bool ServerGC = false);

32 changes: 29 additions & 3 deletions SS14.Loader/RedialApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ namespace SS14.Loader;

internal sealed class RedialApi : IRedialApi
{
// We have to reset these env vars to avoid leaking through state on redial.
private static readonly string[] EnvVarsToClear = [
// Robust config
"ROBUST_AUTH_TOKEN",
"ROBUST_AUTH_USERID",
"ROBUST_AUTH_PUBKEY",
"ROBUST_AUTH_SERVER",

// Launcher config.
"SS14_LOADER_CONTENT_DB",
"SS14_LOADER_CONTENT_VERSION",
"SS14_DISABLE_SIGNING",
"SS14_LAUNCHER_PATH",
"SS14_LOG_CLIENT",

// .NET config
"DOTNET_MULTILEVEL_LOOKUP",

// .NET performance config.
"DOTNET_TieredPGO",
"DOTNET_TC_QuickJitForLoops",
"DOTNET_ReadyToRun",
"DOTNET_gcServer",
];

private readonly string _launcher;

public RedialApi(string launcher)
Expand All @@ -35,9 +60,10 @@ public void Redial(Uri uri, string text = "")
}
};

startInfo.EnvironmentVariables.Remove("DOTNET_TieredPGO");
startInfo.EnvironmentVariables.Remove("DOTNET_TC_QuickJitForLoops");
startInfo.EnvironmentVariables.Remove("DOTNET_ReadyToRun");
foreach (var envVar in EnvVarsToClear)
{
startInfo.EnvironmentVariables.Remove(envVar);
}

Process.Start(startInfo);
}
Expand Down

0 comments on commit c72dc75

Please sign in to comment.