Client should work again
™️
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Torch.Client
|
|||||||
{
|
{
|
||||||
public const string SpaceEngineersBinaries = "Bin64";
|
public const string SpaceEngineersBinaries = "Bin64";
|
||||||
private static string _spaceEngInstallAlias = null;
|
private static string _spaceEngInstallAlias = null;
|
||||||
|
|
||||||
public static string SpaceEngineersInstallAlias
|
public static string SpaceEngineersInstallAlias
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -26,7 +27,8 @@ namespace Torch.Client
|
|||||||
if (_spaceEngInstallAlias == null)
|
if (_spaceEngInstallAlias == null)
|
||||||
{
|
{
|
||||||
// ReSharper disable once AssignNullToNotNullAttribute
|
// ReSharper disable once AssignNullToNotNullAttribute
|
||||||
_spaceEngInstallAlias = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "SpaceEngineersAlias");
|
_spaceEngInstallAlias = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location),
|
||||||
|
"SpaceEngineersAlias");
|
||||||
}
|
}
|
||||||
return _spaceEngInstallAlias;
|
return _spaceEngInstallAlias;
|
||||||
}
|
}
|
||||||
@@ -52,16 +54,20 @@ namespace Torch.Client
|
|||||||
{
|
{
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
#endif
|
#endif
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
if (!TorchLauncher.IsTorchWrapped())
|
||||||
|
|
||||||
// Early config: Resolve SE install directory.
|
|
||||||
if (!File.Exists(Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile)))
|
|
||||||
SetupSpaceEngInstallAlias();
|
|
||||||
|
|
||||||
using (new TorchAssemblyResolver(Path.Combine(SpaceEngineersInstallAlias, SpaceEngineersBinaries)))
|
|
||||||
{
|
{
|
||||||
RunClient();
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
|
// Early config: Resolve SE install directory.
|
||||||
|
if (!File.Exists(Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile)))
|
||||||
|
SetupSpaceEngInstallAlias();
|
||||||
|
|
||||||
|
TorchLauncher.Launch(Assembly.GetEntryAssembly().FullName, args,
|
||||||
|
Path.Combine(SpaceEngineersInstallAlias, SpaceEngineersBinaries));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RunClient();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -77,7 +83,8 @@ namespace Torch.Client
|
|||||||
|
|
||||||
// TODO look at Steam/config/Config.VDF? Has alternate directories.
|
// TODO look at Steam/config/Config.VDF? Has alternate directories.
|
||||||
var steamDir =
|
var steamDir =
|
||||||
Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Valve\\Steam", "SteamPath", null) as string;
|
Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Valve\\Steam", "SteamPath",
|
||||||
|
null) as string;
|
||||||
if (steamDir != null)
|
if (steamDir != null)
|
||||||
{
|
{
|
||||||
spaceEngineersDirectory = Path.Combine(steamDir, _steamSpaceEngineersDirectory);
|
spaceEngineersDirectory = Path.Combine(steamDir, _steamSpaceEngineersDirectory);
|
||||||
@@ -97,7 +104,8 @@ namespace Torch.Client
|
|||||||
{
|
{
|
||||||
if (dialog.ShowDialog() != DialogResult.OK)
|
if (dialog.ShowDialog() != DialogResult.OK)
|
||||||
{
|
{
|
||||||
var ex = new FileNotFoundException("Unable to find the Space Engineers install directory, aborting");
|
var ex = new FileNotFoundException(
|
||||||
|
"Unable to find the Space Engineers install directory, aborting");
|
||||||
_log.Fatal(ex);
|
_log.Fatal(ex);
|
||||||
LogManager.Flush();
|
LogManager.Flush();
|
||||||
throw ex;
|
throw ex;
|
||||||
@@ -109,11 +117,12 @@ namespace Torch.Client
|
|||||||
$"Unable to find {0} in {1}. Are you sure it's the Space Engineers install directory?",
|
$"Unable to find {0} in {1}. Are you sure it's the Space Engineers install directory?",
|
||||||
"Invalid Space Engineers Directory", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
"Invalid Space Engineers Directory", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
break;
|
break;
|
||||||
} while (true); // Repeat until they confirm.
|
} while (true); // Repeat until they confirm.
|
||||||
}
|
}
|
||||||
if (!JunctionLink(SpaceEngineersInstallAlias, spaceEngineersDirectory))
|
if (!JunctionLink(SpaceEngineersInstallAlias, spaceEngineersDirectory))
|
||||||
{
|
{
|
||||||
var ex = new IOException($"Failed to create junction link {SpaceEngineersInstallAlias} => {spaceEngineersDirectory}. Aborting.");
|
var ex = new IOException(
|
||||||
|
$"Failed to create junction link {SpaceEngineersInstallAlias} => {spaceEngineersDirectory}. Aborting.");
|
||||||
_log.Fatal(ex);
|
_log.Fatal(ex);
|
||||||
LogManager.Flush();
|
LogManager.Flush();
|
||||||
throw ex;
|
throw ex;
|
||||||
@@ -121,7 +130,8 @@ namespace Torch.Client
|
|||||||
string junctionVerify = Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile);
|
string junctionVerify = Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile);
|
||||||
if (!File.Exists(junctionVerify))
|
if (!File.Exists(junctionVerify))
|
||||||
{
|
{
|
||||||
var ex = new FileNotFoundException($"Junction link is not working. File {junctionVerify} does not exist");
|
var ex = new FileNotFoundException(
|
||||||
|
$"Junction link is not working. File {junctionVerify} does not exist");
|
||||||
_log.Fatal(ex);
|
_log.Fatal(ex);
|
||||||
LogManager.Flush();
|
LogManager.Flush();
|
||||||
throw ex;
|
throw ex;
|
||||||
@@ -153,7 +163,7 @@ namespace Torch.Client
|
|||||||
|
|
||||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
var ex = (Exception)e.ExceptionObject;
|
var ex = (Exception) e.ExceptionObject;
|
||||||
_log.Error(ex);
|
_log.Error(ex);
|
||||||
LogManager.Flush();
|
LogManager.Flush();
|
||||||
MessageBox.Show(ex.StackTrace, ex.Message);
|
MessageBox.Show(ex.StackTrace, ex.Message);
|
||||||
|
@@ -26,22 +26,19 @@ namespace Torch.Client
|
|||||||
{
|
{
|
||||||
public class TorchClient : TorchBase, ITorchClient
|
public class TorchClient : TorchBase, ITorchClient
|
||||||
{
|
{
|
||||||
private MyCommonProgramStartup _startup;
|
|
||||||
private IMyRender _renderer;
|
|
||||||
|
|
||||||
protected override uint SteamAppId => 244850;
|
protected override uint SteamAppId => 244850;
|
||||||
protected override string SteamAppName => "Space Engineers";
|
protected override string SteamAppName => "SpaceEngineers";
|
||||||
|
|
||||||
public TorchClient()
|
public TorchClient()
|
||||||
{
|
{
|
||||||
Config = new TorchClientConfig();
|
Config = new TorchClientConfig();
|
||||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||||
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerLobby
|
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerLobby
|
||||||
? new MultiplayerManagerLobby(this)
|
? new MultiplayerManagerLobby(this)
|
||||||
: null);
|
: null);
|
||||||
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerClientBase
|
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerClientBase
|
||||||
? new MultiplayerManagerClient(this)
|
? new MultiplayerManagerClient(this)
|
||||||
: null);
|
: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
@@ -49,38 +46,22 @@ namespace Torch.Client
|
|||||||
Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
|
Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
|
||||||
MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
|
MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
|
||||||
Log.Info("Initializing Torch Client");
|
Log.Info("Initializing Torch Client");
|
||||||
_startup = new MyCommonProgramStartup(RunArgs);
|
Config.InstancePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
SpaceEngineersGame.SetupBasicGameInfo();
|
SteamAppName);
|
||||||
SpaceEngineersGame.SetupPerGameSettings();
|
|
||||||
if (_startup.PerformReporting())
|
|
||||||
throw new InvalidOperationException("Torch client won't launch when started in error reporting mode");
|
|
||||||
|
|
||||||
_startup.PerformAutoconnect();
|
|
||||||
if (!_startup.CheckSingleInstance())
|
|
||||||
throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time.");
|
|
||||||
|
|
||||||
var appDataPath = _startup.GetAppDataPath();
|
|
||||||
Config.InstancePath = appDataPath;
|
|
||||||
base.Init();
|
base.Init();
|
||||||
OverrideMenus();
|
OverrideMenus();
|
||||||
SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}");
|
SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Destroy()
|
|
||||||
{
|
|
||||||
base.Destroy();
|
|
||||||
_startup.DetectSharpDxLeaksAfterRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OverrideMenus()
|
private void OverrideMenus()
|
||||||
{
|
{
|
||||||
var credits = new MyCreditsDepartment("Torch Developed By")
|
var credits = new MyCreditsDepartment("Torch Developed By")
|
||||||
{
|
{
|
||||||
Persons = new List<MyCreditsPerson>
|
Persons = new List<MyCreditsPerson>
|
||||||
{
|
{
|
||||||
new MyCreditsPerson("THE TORCH TEAM"),
|
new MyCreditsPerson("THE TORCH TEAM"),
|
||||||
new MyCreditsPerson("http://github.com/TorchSE"),
|
new MyCreditsPerson("http://github.com/TorchSE"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MyPerGameSettings.Credits.Departments.Insert(0, credits);
|
MyPerGameSettings.Credits.Departments.Insert(0, credits);
|
||||||
|
|
||||||
@@ -96,12 +77,11 @@ namespace Torch.Client
|
|||||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
if (renderWindowField == null)
|
if (renderWindowField == null)
|
||||||
return;
|
return;
|
||||||
var window = renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as System.Windows.Forms.Form;
|
var window =
|
||||||
|
renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as
|
||||||
|
System.Windows.Forms.Form;
|
||||||
if (window != null)
|
if (window != null)
|
||||||
renderThread.Invoke(() =>
|
renderThread.Invoke(() => { window.Text = title; });
|
||||||
{
|
|
||||||
window.Text = title;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Restart()
|
public override void Restart()
|
||||||
@@ -109,4 +89,4 @@ namespace Torch.Client
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user