mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Disable load context on server ContentStart.
This commit is contained in:
@@ -48,6 +48,10 @@ namespace Robust.Client
|
||||
|
||||
var gc = (GameController) IoCManager.Resolve<IGameController>();
|
||||
gc.SetCommandLineArgs(args);
|
||||
|
||||
// When the game is ran with the startup executable being content,
|
||||
// we have to disable the separate load context.
|
||||
// Otherwise the content assemblies will be loaded twice which causes *many* fun bugs.
|
||||
gc._disableAssemblyLoadContext = contentStart;
|
||||
if (!gc.Startup())
|
||||
{
|
||||
|
||||
@@ -199,6 +199,8 @@ namespace Robust.Server
|
||||
_resources.MountContentDirectory($@"{contentRootDir}Resources/");
|
||||
#endif
|
||||
|
||||
_modLoader.SetUseLoadContext(!DisableLoadContext);
|
||||
|
||||
//identical code in game controller for client
|
||||
if (!_modLoader.TryLoadAssembly<GameShared>(_resources, $"Content.Shared"))
|
||||
{
|
||||
@@ -292,6 +294,8 @@ namespace Robust.Server
|
||||
_shutdownEvent.Set();
|
||||
}
|
||||
|
||||
public bool DisableLoadContext { private get; set; }
|
||||
|
||||
public void OverrideMainLoop(IGameLoop gameLoop)
|
||||
{
|
||||
_mainLoop = gameLoop;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Robust.Server
|
||||
#if FULL_RELEASE
|
||||
throw new System.InvalidOperationException("ContentStart is not available on a full release.");
|
||||
#else
|
||||
Program.Main(args);
|
||||
Program.Start(args, true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace Robust.Server.Interfaces
|
||||
|
||||
internal interface IBaseServerInternal : IBaseServer
|
||||
{
|
||||
bool DisableLoadContext { set; }
|
||||
|
||||
void OverrideMainLoop(IGameLoop gameLoop);
|
||||
|
||||
void SetCommandLineArgs(CommandLineArgs args);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Robust.Server
|
||||
Start(args);
|
||||
}
|
||||
|
||||
internal static void Start(string[] args)
|
||||
internal static void Start(string[] args, bool contentStart=false)
|
||||
{
|
||||
if (_hasStarted)
|
||||
{
|
||||
@@ -31,11 +31,11 @@ namespace Robust.Server
|
||||
|
||||
if (CommandLineArgs.TryParse(args, out var parsed))
|
||||
{
|
||||
ParsedMain(parsed);
|
||||
ParsedMain(parsed, contentStart);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParsedMain(CommandLineArgs args)
|
||||
private static void ParsedMain(CommandLineArgs args, bool contentStart)
|
||||
{
|
||||
IoCManager.InitThread();
|
||||
ServerIoC.RegisterIoC();
|
||||
@@ -45,6 +45,10 @@ namespace Robust.Server
|
||||
|
||||
var server = IoCManager.Resolve<IBaseServerInternal>();
|
||||
|
||||
// When the game is ran with the startup executable being content,
|
||||
// we have to disable the separate load context.
|
||||
// Otherwise the content assemblies will be loaded twice which causes *many* fun bugs.
|
||||
server.DisableLoadContext = contentStart;
|
||||
server.SetCommandLineArgs(args);
|
||||
|
||||
Logger.Info("Server -> Starting");
|
||||
|
||||
Reference in New Issue
Block a user