diff --git a/Torch.API/ConnectionState.cs b/Torch.API/ConnectionState.cs
index 5565c6c..aa48ead 100644
--- a/Torch.API/ConnectionState.cs
+++ b/Torch.API/ConnectionState.cs
@@ -8,11 +8,34 @@ namespace Torch.API
[Flags]
public enum ConnectionState
{
+ ///
+ /// Unknown state.
+ ///
Unknown,
+
+ ///
+ /// Connected to game.
+ ///
Connected = 1,
+
+ ///
+ /// Left the game.
+ ///
Left = 2,
+
+ ///
+ /// Disconnected from the game.
+ ///
Disconnected = 4,
+
+ ///
+ /// Kicked from the game.
+ ///
Kicked = 8,
+
+ ///
+ /// Banned from the game.
+ ///
Banned = 16,
}
}
\ No newline at end of file
diff --git a/Torch.API/IChatMessage.cs b/Torch.API/IChatMessage.cs
index 30356dd..e9dbc11 100644
--- a/Torch.API/IChatMessage.cs
+++ b/Torch.API/IChatMessage.cs
@@ -8,9 +8,24 @@ namespace Torch.API
{
public interface IChatMessage
{
+ ///
+ /// The time the message was created.
+ ///
DateTime Timestamp { get; }
+
+ ///
+ /// The SteamID of the message author.
+ ///
ulong SteamId { get; }
+
+ ///
+ /// The name of the message author.
+ ///
string Name { get; }
+
+ ///
+ /// The content of the message.
+ ///
string Message { get; }
}
}
diff --git a/Torch.API/IPlayer.cs b/Torch.API/IPlayer.cs
index db4d09e..e2357a4 100644
--- a/Torch.API/IPlayer.cs
+++ b/Torch.API/IPlayer.cs
@@ -7,10 +7,24 @@ using VRage.Game.ModAPI;
namespace Torch.API
{
+ ///
+ /// Represents a player on the server.
+ ///
public interface IPlayer
{
+ ///
+ /// The name of the player.
+ ///
string Name { get; }
+
+ ///
+ /// The SteamID of the player.
+ ///
ulong SteamId { get; }
+
+ ///
+ /// The player's current connection state.
+ ///
ConnectionState State { get; }
}
}
diff --git a/Torch.API/ModAPI/TorchAPI.cs b/Torch.API/ModAPI/TorchAPI.cs
new file mode 100644
index 0000000..60560c8
--- /dev/null
+++ b/Torch.API/ModAPI/TorchAPI.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Text;
+using System.Threading.Tasks;
+
+//Needed so Torch can set the instance here without exposing anything bad to mods or creating a circular dependency.
+[assembly: InternalsVisibleTo("Torch")]
+namespace Torch.API.ModAPI
+{
+ ///
+ /// Entry point for mods to access Torch.
+ ///
+ public static class TorchAPI
+ {
+ internal static ITorchBase Instance;
+ }
+}
diff --git a/Torch.API/ModAPI/TorchAPIGateway.cs b/Torch.API/ModAPI/TorchAPIGateway.cs
deleted file mode 100644
index b74114a..0000000
--- a/Torch.API/ModAPI/TorchAPIGateway.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Torch.API.ModAPI
-{
- /* TODO: this without causing a circular dependency
- public static class TorchAPIGateway
- {
- public static Version Version => TorchBase.Instance.TorchVersion;
-
- public static IMultiplayer Multiplayer => TorchBase.Instance.Multiplayer;
-
- public static IPluginManager Plugins => TorchBase.Instance.Plugins;
- }*/
-}
diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj
index 3a737c3..60f537f 100644
--- a/Torch.API/Torch.API.csproj
+++ b/Torch.API/Torch.API.csproj
@@ -30,6 +30,7 @@
x64
prompt
MinimumRecommendedRules.ruleset
+ bin\x64\Release\Torch.API.xml
@@ -168,10 +169,10 @@
-
+
diff --git a/Torch.Client/Torch.Client.csproj b/Torch.Client/Torch.Client.csproj
index 947d5e8..b56672d 100644
--- a/Torch.Client/Torch.Client.csproj
+++ b/Torch.Client/Torch.Client.csproj
@@ -35,6 +35,7 @@
prompt
MinimumRecommendedRules.ruleset
true
+ bin\x64\Release\Torch.Client.xml
torchicon.ico
diff --git a/Torch.Launcher/App.config b/Torch.Launcher/App.config
deleted file mode 100644
index bae5d6d..0000000
--- a/Torch.Launcher/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/Torch.Launcher/App.xaml b/Torch.Launcher/App.xaml
deleted file mode 100644
index 09b2f9a..0000000
--- a/Torch.Launcher/App.xaml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
diff --git a/Torch.Launcher/App.xaml.cs b/Torch.Launcher/App.xaml.cs
deleted file mode 100644
index f7e54a7..0000000
--- a/Torch.Launcher/App.xaml.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Torch.Launcher
-{
- ///
- /// Interaction logic for App.xaml
- ///
- public partial class App : Application
- {
- }
-}
diff --git a/Torch.Launcher/Config.cs b/Torch.Launcher/Config.cs
deleted file mode 100644
index b8a8637..0000000
--- a/Torch.Launcher/Config.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml.Serialization;
-
-namespace Torch.Launcher
-{
- public class Config
- {
- public int Version { get; set; }
- public string RemoteFilePath { get; set; }
- public string SpaceDirectory { get; set; }
-
- private Config()
- {
- Version = 0;
- RemoteFilePath = "ftp://athena.jimmacle.com/";
- SpaceDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64";
- }
-
- public static string GetConfigPath()
- {
- var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- var pistonFolder = Path.Combine(appdata, "Piston");
- if (!Directory.Exists(pistonFolder))
- Directory.CreateDirectory(pistonFolder);
- return Path.Combine(appdata, "Piston\\config.xml");
- }
-
- public static Config Load()
- {
- if (!File.Exists(GetConfigPath()))
- return new Config();
-
- XmlSerializer ser = new XmlSerializer(typeof(Config));
- using (var f = File.OpenRead(GetConfigPath()))
- {
- using (var sr = new StreamReader(f))
- {
- return (Config)ser.Deserialize(sr);
- }
- }
- }
-
- public void Save()
- {
- XmlSerializer ser = new XmlSerializer(typeof(Config));
- using (var sw = new StreamWriter(GetConfigPath()))
- {
- ser.Serialize(sw, this);
- }
- }
- }
-}
diff --git a/Torch.Launcher/MainWindow.xaml b/Torch.Launcher/MainWindow.xaml
deleted file mode 100644
index 108a75d..0000000
--- a/Torch.Launcher/MainWindow.xaml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/Torch.Launcher/MainWindow.xaml.cs b/Torch.Launcher/MainWindow.xaml.cs
deleted file mode 100644
index d2d2335..0000000
--- a/Torch.Launcher/MainWindow.xaml.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.IO;
-using System.Reflection;
-using Microsoft.Win32;
-
-namespace Torch.Launcher
-{
- ///
- /// Interaction logic for MainWindow.xaml
- ///
- public partial class MainWindow : Window
- {
- private Config _config;
- private TorchFileManager _fileManager;
-
- public MainWindow()
- {
- InitializeComponent();
- _config = Config.Load();
- Title += $" v{_config.Version}";
- _fileManager = new TorchFileManager(_config.RemoteFilePath);
-
- CheckSpaceDirectory();
- CheckSEBranch();
- UpdatePistonFiles();
- }
-
- protected override void OnClosing(CancelEventArgs e)
- {
- _config.Save();
- base.OnClosing(e);
- }
-
- private bool CheckSpaceDirectory()
- {
- if (Directory.Exists(_config.SpaceDirectory) && Directory.GetFiles(_config.SpaceDirectory).Any(i => i.Contains("SpaceEngineers.exe")))
- return true;
-
- var dialog = new SpaceDirPrompt();
- dialog.ShowDialog();
-
- if (dialog.Success)
- {
- _config.SpaceDirectory = dialog.SelectedDir;
- return true;
- }
-
- return false;
- }
-
- private void CheckSEBranch()
- {
- try
- {
- var seAsm = Assembly.LoadFrom(Path.Combine(_config.SpaceDirectory, "VRage.Game.dll"));
- MessageBox.Show("found SE assembly");
- var gameType = seAsm.ExportedTypes.First(x => x.Name == "MyFinalBuildConstants");
- MessageBox.Show("found build constant class");
- var stable = (bool)gameType.GetField("IS_STABLE", BindingFlags.Public | BindingFlags.Static).GetValue(null);
- this.Title += $"SE Branch: {(stable ? "Stable" : "Develop")}";
- }
- catch (Exception e)
- {
- MessageBox.Show("Unable to check SE branch.\n\n" + e.Message + "\n\n" + e.StackTrace);
- }
- }
-
- private void UpdatePistonFiles()
- {
- var i = 0;
- var files = _fileManager.GetDirectoryList();
- foreach (var file in files)
- {
- if (_fileManager.UpdateIfNew(file, _config.SpaceDirectory))
- {
- i++;
- }
- }
-
- InfoLabel.Content = $"Updated {i} files";
- }
-
- private void LaunchBtn_Click(object sender, RoutedEventArgs e)
- {
- if (!CheckSpaceDirectory())
- return;
-
- Directory.SetCurrentDirectory(_config.SpaceDirectory);
- Process.Start(Path.Combine(_config.SpaceDirectory, "PistonClient.exe"));
- Environment.Exit(0);
- }
-
- private void UpdateBtn_Click(object sender, RoutedEventArgs e)
- {
- var btn = (Button)sender;
-
- btn.Content = "Up to date!";
- btn.IsEnabled = false;
- }
- }
-}
diff --git a/Torch.Launcher/Properties/AssemblyInfo.cs b/Torch.Launcher/Properties/AssemblyInfo.cs
deleted file mode 100644
index 796b5f6..0000000
--- a/Torch.Launcher/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Piston.Launcher")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Piston.Launcher")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-//In order to begin building localizable applications, set
-//CultureYouAreCodingWith in your .csproj file
-//inside a . For example, if you are using US english
-//in your source files, set the to en-US. Then uncomment
-//the NeutralResourceLanguage attribute below. Update the "en-US" in
-//the line below to match the UICulture setting in the project file.
-
-//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-
-
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- //(used if a resource is not found in the page,
- // or application resource dictionaries)
- ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
- //(used if a resource is not found in the page,
- // app, or any theme specific resource dictionaries)
-)]
-
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Torch.Launcher/Properties/Resources.Designer.cs b/Torch.Launcher/Properties/Resources.Designer.cs
deleted file mode 100644
index c52d0c4..0000000
--- a/Torch.Launcher/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Torch.Launcher.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Torch.Launcher.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/Torch.Launcher/Properties/Resources.resx b/Torch.Launcher/Properties/Resources.resx
deleted file mode 100644
index af7dbeb..0000000
--- a/Torch.Launcher/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Torch.Launcher/Properties/Settings.Designer.cs b/Torch.Launcher/Properties/Settings.Designer.cs
deleted file mode 100644
index 3926b12..0000000
--- a/Torch.Launcher/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Torch.Launcher.Properties {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default {
- get {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/Torch.Launcher/Properties/Settings.settings b/Torch.Launcher/Properties/Settings.settings
deleted file mode 100644
index 033d7a5..0000000
--- a/Torch.Launcher/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Torch.Launcher/SpaceDirPrompt.xaml b/Torch.Launcher/SpaceDirPrompt.xaml
deleted file mode 100644
index b983c72..0000000
--- a/Torch.Launcher/SpaceDirPrompt.xaml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
diff --git a/Torch.Launcher/SpaceDirPrompt.xaml.cs b/Torch.Launcher/SpaceDirPrompt.xaml.cs
deleted file mode 100644
index c74b1fc..0000000
--- a/Torch.Launcher/SpaceDirPrompt.xaml.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace Torch.Launcher
-{
- ///
- /// Interaction logic for SpaceDirPrompt.xaml
- ///
- public partial class SpaceDirPrompt : Window
- {
- public string SelectedDir { get; private set; }
- public bool Success { get; private set; }
- public SpaceDirPrompt()
- {
- InitializeComponent();
- }
-
- private void OkButton_Click(object sender, RoutedEventArgs e)
- {
- if (!Directory.Exists(PathBox.Text))
- {
- MessageBox.Show(this, "That's not a valid directory.");
- return;
- }
-
- if (!Directory.GetFiles(PathBox.Text).Any(i => i.Contains("SpaceEngineers.exe")))
- {
- MessageBox.Show(this, "SE was not found in the given directory.");
- return;
- }
-
- Success = true;
- SelectedDir = PathBox.Text;
- Close();
- }
- }
-}
diff --git a/Torch.Launcher/Torch.Launcher.csproj b/Torch.Launcher/Torch.Launcher.csproj
deleted file mode 100644
index b4509d9..0000000
--- a/Torch.Launcher/Torch.Launcher.csproj
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}
- WinExe
- Properties
- Torch.Launcher
- Torch.Launcher
- v4.6.1
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
- true
-
-
-
- true
- bin\x64\Debug\
- DEBUG;TRACE
- full
- x64
- prompt
- MinimumRecommendedRules.ruleset
- true
-
-
- bin\x64\Release\
- TRACE
- true
- pdbonly
- x64
- prompt
- MinimumRecommendedRules.ruleset
- true
-
-
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- SpaceDirPrompt.xaml
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
-
-
- MainWindow.xaml
- Code
-
-
- Designer
- MSBuild:Compile
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Torch.Launcher/TorchFileManager.cs b/Torch.Launcher/TorchFileManager.cs
deleted file mode 100644
index 1ad94bb..0000000
--- a/Torch.Launcher/TorchFileManager.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Torch.Launcher
-{
- public class TorchFileManager
- {
- private readonly string _baseUri;
-
- public TorchFileManager(string baseUri)
- {
- _baseUri = baseUri;
- }
-
- public List GetDirectoryList()
- {
- var fileList = new List();
-
- var response = RequestFtp("", WebRequestMethods.Ftp.ListDirectory);
- using (var tr = (TextReader)new StreamReader(response.GetResponseStream()))
- {
- string line;
- while ((line = tr.ReadLine()) != null)
- fileList.Add(line);
- }
-
- response.Close();
- return fileList;
- }
-
- public bool UpdateIfNew(string fileName, string targetDir)
- {
- var info = GetFileInfo(fileName);
- var localPath = Path.Combine(targetDir, fileName);
- if (File.Exists(localPath))
- {
- var localTime = File.GetLastWriteTime(localPath);
- if (info.LastModified < localTime)
- return false;
- }
-
- File.WriteAllBytes(localPath, DownloadFile(fileName));
- return true;
- }
-
- public byte[] DownloadFile(string fileName)
- {
- byte[] file;
- var response = RequestFtp(fileName, WebRequestMethods.Ftp.DownloadFile);
- using (var s = response.GetResponseStream())
- {
- file = new byte[response.ContentLength];
- s.Read(file, 0, (int)response.ContentLength);
- }
- response.Close();
- return file;
- }
-
- public FileInfo GetFileInfo(string fileName)
- {
- var response = RequestFtp(fileName, WebRequestMethods.Ftp.GetDateTimestamp);
- return new FileInfo
- {
- Name = fileName,
- LastModified = response.LastModified,
- SizeInBytes = response.ContentLength
- };
- }
-
- private FtpWebResponse RequestFtp(string resource, string method)
- {
- var request = (FtpWebRequest)WebRequest.Create(_baseUri + resource);
- request.Credentials = new NetworkCredential("pistonftp", "piston");
- request.Method = method;
-
- try { return (FtpWebResponse)request.GetResponse(); }
- catch (WebException e)
- {
- MessageBox.Show($"{e.Message}\r\n{e.StackTrace}");
- throw;
- }
- }
-
- public struct FileInfo
- {
- public string Name;
- public DateTime LastModified;
- public long SizeInBytes;
- }
- }
-}
diff --git a/Torch.Server/Program.cs b/Torch.Server/Program.cs
index 0d357cd..b555ee7 100644
--- a/Torch.Server/Program.cs
+++ b/Torch.Server/Program.cs
@@ -25,10 +25,11 @@ using System.IO.Compression;
using System.Net;
using Torch.Server.Managers;
using VRage.FileSystem;
+using VRageRender;
namespace Torch.Server
{
- public static class Program
+ internal static class Program
{
private static ITorchServer _server;
private static Logger _log = LogManager.GetLogger("Torch");
@@ -45,7 +46,7 @@ namespace Torch.Server
//Ensures that all the files are downloaded in the Torch directory.
Directory.SetCurrentDirectory(new FileInfo(typeof(Program).Assembly.Location).Directory.ToString());
- IsManualInstall = Directory.GetCurrentDirectory().Contains("DedicatedServer64");
+ IsManualInstall = File.Exists("SpaceEngineersDedicated.exe");
if (!IsManualInstall)
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
@@ -75,7 +76,7 @@ namespace Torch.Server
if (!IsManualInstall)
{
- new ConfigManager().CreateInstance("Instance");
+ //new ConfigManager().CreateInstance("Instance");
options.InstancePath = Path.GetFullPath("Instance");
_log.Warn("Would you like to enable automatic updates? (Y/n):");
@@ -256,17 +257,17 @@ quit";
_server = new TorchServer(options);
_server.Init();
+ if (cli.NoGui || cli.Autostart)
+ {
+ new Thread(() => _server.Start()).Start();
+ }
+
if (!cli.NoGui)
{
var ui = new TorchUI((TorchServer)_server);
ui.LoadConfig(options);
ui.ShowDialog();
}
-
- if (cli.NoGui || cli.Autostart)
- {
- _server.Start();
- }
}
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
@@ -304,7 +305,8 @@ quit";
_cli.WaitForPID = Process.GetCurrentProcess().Id.ToString();
Process.Start(exe, _cli.ToString());
}
- Environment.Exit(-1);
+ //1627 = Function failed during execution.
+ Environment.Exit(1627);
}
}
}
diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj
index 2ea886a..5fd97a7 100644
--- a/Torch.Server/Torch.Server.csproj
+++ b/Torch.Server/Torch.Server.csproj
@@ -35,6 +35,7 @@
prompt
MinimumRecommendedRules.ruleset
true
+ bin\x64\Release\Torch.Server.xml
Torch.Server.Program
@@ -218,6 +219,7 @@
AddWorkshopItemsDialog.xaml
+
BlockView.xaml
diff --git a/Torch.Server/TorchService.cs b/Torch.Server/TorchService.cs
index c78c0b4..2c108ff 100644
--- a/Torch.Server/TorchService.cs
+++ b/Torch.Server/TorchService.cs
@@ -19,7 +19,6 @@ namespace Torch.Server
public TorchService()
{
ServiceName = Name;
- EventLog.Log = "Application";
CanHandlePowerEvent = true;
CanHandleSessionChangeEvent = false;
diff --git a/Torch.Server/ViewModels/BlockLimitViewModel.cs b/Torch.Server/ViewModels/BlockLimitViewModel.cs
index e026cde..7b0667c 100644
--- a/Torch.Server/ViewModels/BlockLimitViewModel.cs
+++ b/Torch.Server/ViewModels/BlockLimitViewModel.cs
@@ -17,7 +17,7 @@ namespace Torch.Server.ViewModels
public string BlockType { get => _blockType; set { _blockType = value; OnPropertyChanged(); } }
public short Limit { get => _limit; set { _limit = value; OnPropertyChanged(); } }
- public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand());
+ //public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand());
public BlockLimitViewModel(SessionSettingsViewModel sessionSettings, string blockType, short limit)
{
@@ -26,6 +26,7 @@ namespace Torch.Server.ViewModels
_limit = limit;
}
+ /* TODO: figure out how WPF commands work
public class DeleteCommand : ICommand
{
///
@@ -42,6 +43,6 @@ namespace Torch.Server.ViewModels
///
public event EventHandler CanExecuteChanged;
- }
+ }*/
}
}
diff --git a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs
index 0414e3b..e62862d 100644
--- a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs
+++ b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs
@@ -57,9 +57,12 @@ namespace Torch.Server.ViewModels
public SessionSettingsViewModel SessionSettings { get; }
public ObservableCollection WorldPaths { get; } = new ObservableCollection();
- public string Administrators { get; set; }
- public string Banned { get; set; }
- public string Mods { get; set; }
+ private string _administrators;
+ public string Administrators { get => _administrators; set { _administrators = value; OnPropertyChanged(); } }
+ private string _banned;
+ public string Banned { get => _banned; set { _banned = value; OnPropertyChanged(); } }
+ private string _mods;
+ public string Mods { get => _mods; set { _mods = value; OnPropertyChanged(); } }
public int AsteroidAmount
{
diff --git a/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs b/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs
index e1f5384..e19179a 100644
--- a/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs
+++ b/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs
@@ -3,6 +3,7 @@ using System.Linq;
using Sandbox.Game.Entities;
using VRage.Game.Entity;
using VRage.Game.ModAPI;
+using System.Threading.Tasks;
namespace Torch.Server.ViewModels.Entities
{
@@ -10,13 +11,13 @@ namespace Torch.Server.ViewModels.Entities
{
private MyVoxelBase Voxel => (MyVoxelBase)Entity;
- public override string Name => string.IsNullOrEmpty(Voxel.StorageName) ? "Unnamed" : Voxel.StorageName;
+ public override string Name => string.IsNullOrEmpty(Voxel.StorageName) ? "UnnamedProcedural" : Voxel.StorageName;
public override bool CanStop => false;
public MTObservableCollection AttachedGrids { get; } = new MTObservableCollection();
- public void UpdateAttachedGrids()
+ public async Task UpdateAttachedGrids()
{
//TODO: fix
return;
@@ -24,7 +25,7 @@ namespace Torch.Server.ViewModels.Entities
AttachedGrids.Clear();
var box = Entity.WorldAABB;
var entities = new List();
- MyGamePruningStructure.GetTopMostEntitiesInBox(ref box, entities, MyEntityQueryType.Static);
+ await TorchBase.Instance.InvokeAsync(() => MyEntities.GetTopMostEntitiesInBox(ref box, entities)).ConfigureAwait(false);
foreach (var entity in entities.Where(e => e is IMyCubeGrid))
{
var gridModel = Tree.Grids.FirstOrDefault(g => g.Entity.EntityId == entity.EntityId);
diff --git a/Torch.Server/ViewModels/SessionSettingsViewModel.cs b/Torch.Server/ViewModels/SessionSettingsViewModel.cs
index f8d380a..9dc583b 100644
--- a/Torch.Server/ViewModels/SessionSettingsViewModel.cs
+++ b/Torch.Server/ViewModels/SessionSettingsViewModel.cs
@@ -10,15 +10,24 @@ using VRage.Library.Utils;
namespace Torch.Server.ViewModels
{
+ ///
+ /// View model for
+ ///
public class SessionSettingsViewModel : ViewModel
{
private MyObjectBuilder_SessionSettings _settings;
+ ///
+ /// Creates a new view model with a new object.
+ ///
public SessionSettingsViewModel() : this(new MyObjectBuilder_SessionSettings())
{
}
+ ///
+ /// Creates a view model using an existing object.
+ ///
public SessionSettingsViewModel(MyObjectBuilder_SessionSettings settings)
{
_settings = settings;
@@ -29,31 +38,38 @@ namespace Torch.Server.ViewModels
public MTObservableCollection BlockLimits { get; } = new MTObservableCollection();
#region Multipliers
+
+ ///
public float InventorySizeMultiplier
{
get => _settings.InventorySizeMultiplier; set { _settings.InventorySizeMultiplier = value; OnPropertyChanged(); }
}
+ ///
public float RefinerySpeedMultiplier
{
get => _settings.RefinerySpeedMultiplier; set { _settings.RefinerySpeedMultiplier = value; OnPropertyChanged(); }
}
+ ///
public float AssemblerEfficiencyMultiplier
{
get => _settings.AssemblerEfficiencyMultiplier; set { _settings.AssemblerEfficiencyMultiplier = value; OnPropertyChanged(); }
}
+ ///
public float AssemblerSpeedMultiplier
{
get => _settings.AssemblerSpeedMultiplier; set { _settings.AssemblerSpeedMultiplier = value; OnPropertyChanged(); }
}
+ ///
public float GrinderSpeedMultiplier
{
get => _settings.GrinderSpeedMultiplier; set { _settings.GrinderSpeedMultiplier = value; OnPropertyChanged(); }
}
+ ///
public float HackSpeedMultiplier
{
get => _settings.HackSpeedMultiplier; set { _settings.HackSpeedMultiplier = value; OnPropertyChanged(); }
@@ -61,26 +77,32 @@ namespace Torch.Server.ViewModels
#endregion
#region NPCs
+
+ ///
public bool EnableDrones
{
get => _settings.EnableDrones; set { _settings.EnableDrones = value; OnPropertyChanged(); }
}
+ ///
public bool EnableEncounters
{
get => _settings.EnableEncounters; set { _settings.EnableEncounters = value; OnPropertyChanged(); }
}
+ ///
public bool EnableSpiders
{
get => _settings.EnableSpiders; set { _settings.EnableSpiders = value; OnPropertyChanged(); }
}
+ ///
public bool EnableWolves
{
get => _settings.EnableWolfs; set { _settings.EnableWolfs = value; OnPropertyChanged(); }
}
+ ///
public bool EnableCargoShips
{
get => _settings.CargoShipsEnabled; set { _settings.CargoShipsEnabled = value; OnPropertyChanged(); }
@@ -88,206 +110,253 @@ namespace Torch.Server.ViewModels
#endregion
#region Environment
+
+ ///
public bool EnableSunRotation
{
get => _settings.EnableSunRotation; set { _settings.EnableSunRotation = value; OnPropertyChanged(); }
}
+ ///
public bool EnableAirtightness
{
get => _settings.EnableOxygenPressurization; set { _settings.EnableOxygenPressurization = value; OnPropertyChanged(); }
}
+ ///
public bool EnableOxygen
{
get => _settings.EnableOxygen; set { _settings.EnableOxygen = value; OnPropertyChanged(); }
}
+ ///
public bool EnableDestructibleBlocks
{
get => _settings.DestructibleBlocks; set { _settings.DestructibleBlocks = value; OnPropertyChanged(); }
}
+ ///
public bool EnableToolShake
{
get => _settings.EnableToolShake; set { _settings.EnableToolShake = value; OnPropertyChanged(); }
}
+ ///
public bool EnableVoxelDestruction
{
get => _settings.EnableVoxelDestruction; set { _settings.EnableVoxelDestruction = value; OnPropertyChanged(); }
}
- public List EnvironmentHostilityValues => Enum.GetNames(typeof(MyEnvironmentHostilityEnum)).ToList();
+ ///
+ /// List used to populate the environment hostility combo box.
+ ///
+ public List EnvironmentHostilityValues { get; } = Enum.GetNames(typeof(MyEnvironmentHostilityEnum)).ToList();
+ ///
public string EnvironmentHostility
{
get => _settings.EnvironmentHostility.ToString(); set { Enum.TryParse(value, true, out _settings.EnvironmentHostility); OnPropertyChanged(); }
}
+ ///
public bool EnableFlora
{
get => _settings.EnableFlora; set { _settings.EnableFlora = value; OnPropertyChanged(); }
}
#endregion
- public List GameModeValues => Enum.GetNames(typeof(MyGameModeEnum)).ToList();
+ ///
+ /// List used to populate the game mode combobox.
+ ///
+ public List GameModeValues { get; } = Enum.GetNames(typeof(MyGameModeEnum)).ToList();
+ ///
public string GameMode
{
get => _settings.GameMode.ToString(); set { Enum.TryParse(value, true, out _settings.GameMode); OnPropertyChanged(); }
}
+ ///
public bool EnableAutoHealing
{
get => _settings.AutoHealing; set { _settings.AutoHealing = value; OnPropertyChanged(); }
}
+ ///
public bool EnableCopyPaste
{
get => _settings.EnableCopyPaste; set { _settings.EnableCopyPaste = value; OnPropertyChanged(); }
}
+ ///
public bool ShowPlayerNamesOnHud
{
get => _settings.ShowPlayerNamesOnHud; set { _settings.ShowPlayerNamesOnHud = value; OnPropertyChanged(); }
}
+ ///
public bool EnableThirdPerson
{
get => _settings.Enable3rdPersonView; set { _settings.Enable3rdPersonView = value; OnPropertyChanged(); }
}
+ ///
public bool EnableSpectator
{
get => _settings.EnableSpectator; set { _settings.EnableSpectator = value; OnPropertyChanged(); }
}
+ ///
public bool SpawnWithTools
{
get => _settings.SpawnWithTools; set { _settings.SpawnWithTools = value; OnPropertyChanged(); }
}
+ ///
public bool EnableConvertToStation
{
get => _settings.EnableConvertToStation; set { _settings.EnableConvertToStation = value; OnPropertyChanged(); }
}
+ ///
public bool EnableJetpack
{
get => _settings.EnableJetpack; set { _settings.EnableJetpack = value; OnPropertyChanged(); }
}
+ ///
public bool EnableRemoteOwnerRemoval
{
get => _settings.EnableRemoteBlockRemoval; set { _settings.EnableRemoteBlockRemoval = value; OnPropertyChanged(); }
}
+ ///
public bool EnableRespawnShips
{
get => _settings.EnableRespawnShips; set { _settings.EnableRespawnShips = value; OnPropertyChanged(); }
}
+ ///
public bool EnableScripterRole
{
get => _settings.EnableScripterRole; set { _settings.EnableScripterRole = value; OnPropertyChanged(); }
}
+ ///
public bool EnableRealisticSound
{
get => _settings.RealisticSound; set { _settings.RealisticSound = value; OnPropertyChanged(); }
}
+ ///
public bool ResetOwnership
{
get => _settings.ResetOwnership; set { _settings.ResetOwnership = value; OnPropertyChanged(); }
}
+ ///
public bool DeleteRespawnShips
{
get => _settings.RespawnShipDelete; set { _settings.RespawnShipDelete = value; OnPropertyChanged(); }
}
+ ///
public bool EnableThrusterDamage
{
get => _settings.ThrusterDamage; set { _settings.ThrusterDamage = value; OnPropertyChanged(); }
}
+ ///
public bool EnableWeapons
{
get => _settings.WeaponsEnabled; set { _settings.WeaponsEnabled = value; OnPropertyChanged(); }
}
+ ///
public bool EnableIngameScripts
{
get => _settings.EnableIngameScripts; set { _settings.EnableIngameScripts = value; OnPropertyChanged(); }
}
+ ///
public uint AutosaveInterval
{
get => _settings.AutoSaveInMinutes; set { _settings.AutoSaveInMinutes = value; OnPropertyChanged(); }
}
+ ///
public int FloraDensity
{
get => _settings.FloraDensity; set { _settings.FloraDensity = value; OnPropertyChanged(); }
}
+ ///
public float FloraDensityMultiplier
{
get => _settings.FloraDensityMultiplier; set { _settings.FloraDensityMultiplier = value; OnPropertyChanged(); }
}
+ ///
public short MaxBackupSaves
{
get => _settings.MaxBackupSaves; set { _settings.MaxBackupSaves = value; OnPropertyChanged(); }
}
+ ///
public int MaxBlocksPerPlayer
{
get => _settings.MaxBlocksPerPlayer; set { _settings.MaxBlocksPerPlayer = value; OnPropertyChanged(); }
}
+ ///
public short MaxFloatingObjects
{
get => _settings.MaxFloatingObjects; set { _settings.MaxFloatingObjects = value; OnPropertyChanged(); }
}
+ ///
public int MaxGridSize
{
get => _settings.MaxGridSize; set { _settings.MaxGridSize = value; OnPropertyChanged(); }
}
+ ///
public short MaxPlayers
{
get => _settings.MaxPlayers; set { _settings.MaxPlayers = value; OnPropertyChanged(); }
}
+ ///
public int PhysicsIterations
{
get => _settings.PhysicsIterations; set { _settings.PhysicsIterations = value; OnPropertyChanged(); }
}
+ ///
public float SpawnTimeMultiplier
{
get => _settings.SpawnShipTimeMultiplier; set { _settings.SpawnShipTimeMultiplier = value; OnPropertyChanged(); }
}
+ ///
public float SunRotationInterval
{
get => _settings.SunRotationIntervalMinutes; set { _settings.SunRotationIntervalMinutes = value; OnPropertyChanged(); }
}
+ ///
public int ViewDistance
{
get => _settings.ViewDistance; set { _settings.ViewDistance = value; OnPropertyChanged(); }
}
+ ///
public int WorldSize
{
get => _settings.WorldSizeKm; set { _settings.WorldSizeKm = value; OnPropertyChanged(); }
}
+ ///
public static implicit operator MyObjectBuilder_SessionSettings(SessionSettingsViewModel viewModel)
{
viewModel._settings.BlockTypeLimits.Dictionary.Clear();
diff --git a/Torch.Server/Views/ChatControl.xaml.cs b/Torch.Server/Views/ChatControl.xaml.cs
index 32c6755..5e9ab16 100644
--- a/Torch.Server/Views/ChatControl.xaml.cs
+++ b/Torch.Server/Views/ChatControl.xaml.cs
@@ -58,6 +58,9 @@ namespace Torch.Server
{
//Can't use Message.Text directly because of object ownership in WPF.
var text = Message.Text;
+ if (string.IsNullOrEmpty(text))
+ return;
+
var commands = _server.Commands;
string response = null;
if (commands.IsCommand(text))
diff --git a/Torch.Server/Views/ConfigControl.xaml b/Torch.Server/Views/ConfigControl.xaml
index 0ad09d1..f399687 100644
--- a/Torch.Server/Views/ConfigControl.xaml
+++ b/Torch.Server/Views/ConfigControl.xaml
@@ -14,7 +14,7 @@
-
+
diff --git a/Torch.Server/Views/ConfigControl.xaml.cs b/Torch.Server/Views/ConfigControl.xaml.cs
index 54f15e7..b931195 100644
--- a/Torch.Server/Views/ConfigControl.xaml.cs
+++ b/Torch.Server/Views/ConfigControl.xaml.cs
@@ -40,6 +40,7 @@ namespace Torch.Server.Views
public MyConfigDedicated Config { get; set; }
private ConfigDedicatedViewModel _viewModel;
private string _configPath;
+ private TorchConfig _torchConfig;
public ConfigControl()
{
@@ -76,6 +77,8 @@ namespace Torch.Server.Views
public void LoadDedicatedConfig(TorchConfig torchConfig)
{
+ _torchConfig = torchConfig;
+ DataContext = null;
MySandboxGame.Config = new MyConfig(MyPerServerSettings.GameNameSafe + ".cfg");
var path = Path.Combine(torchConfig.InstancePath, "SpaceEngineers-Dedicated.cfg");
@@ -90,45 +93,38 @@ namespace Torch.Server.Views
Config.Load(path);
_configPath = path;
- var checkpoint = MyLocalCache.LoadCheckpoint(Config.LoadWorld, out ulong _);
- if (checkpoint == null)
- {
- Log.Error("Failed to load checkpoint when loading DS config.");
- }
- else
- {
- Config.Mods.Clear();
- foreach (var mod in checkpoint.Mods)
- Config.Mods.Add(mod.PublishedFileId);
- }
-
_viewModel = new ConfigDedicatedViewModel(Config);
var worldFolders = Directory.EnumerateDirectories(Path.Combine(torchConfig.InstancePath, "Saves"));
foreach (var f in worldFolders)
_viewModel.WorldPaths.Add(f);
+ LoadWorldMods();
DataContext = _viewModel;
}
- /*
- private void Banned_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
+ private void LoadWorldMods()
{
- var editor = new CollectionEditor {Owner = Window.GetWindow(this)};
- editor.Edit(_viewModel.Banned, "Banned Players");
- }
+ var sandboxPath = Path.Combine(Config.LoadWorld, "Sandbox.sbc");
- private void Administrators_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- var editor = new CollectionEditor { Owner = Window.GetWindow(this) };
- editor.Edit(_viewModel.Administrators, "Administrators");
- }
+ if (!File.Exists(sandboxPath))
+ return;
- private void Mods_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- var editor = new CollectionEditor { Owner = Window.GetWindow(this) };
- editor.Edit(_viewModel.Mods, "Mods");
- }*/
+ MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
+ if (checkpoint == null)
+ {
+ Log.Error($"Failed to load {Config.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {TorchBase.Instance.Config.InstancePath})");
+ return;
+ }
+
+ var sb = new StringBuilder();
+ foreach (var mod in checkpoint.Mods)
+ sb.AppendLine(mod.PublishedFileId.ToString());
+
+ _viewModel.Mods = sb.ToString();
+
+ Log.Info("Loaded mod list from world");
+ }
private void Save_OnClick(object sender, RoutedEventArgs e)
{
@@ -150,5 +146,15 @@ namespace Torch.Server.Views
{
MessageBox.Show("Feature coming soon :)");
}
+
+ private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ //The control doesn't update the binding before firing the event.
+ if (e.AddedItems.Count > 0)
+ {
+ Config.LoadWorld = (string)e.AddedItems[0];
+ LoadWorldMods();
+ }
+ }
}
}
diff --git a/Torch.Server/Views/Converters/InverseBooleanConverter.cs b/Torch.Server/Views/Converters/InverseBooleanConverter.cs
new file mode 100644
index 0000000..29c19dd
--- /dev/null
+++ b/Torch.Server/Views/Converters/InverseBooleanConverter.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Torch.Server.Views.Converters
+{
+ [ValueConversion(typeof(bool), typeof(bool))]
+ public class InverseBooleanConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ if (targetType != typeof(bool))
+ throw new InvalidOperationException("The target must be a boolean");
+
+ return !(bool)value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/Torch.Server/Views/Entities/VoxelMapView.xaml.cs b/Torch.Server/Views/Entities/VoxelMapView.xaml.cs
index 031c30b..ad94562 100644
--- a/Torch.Server/Views/Entities/VoxelMapView.xaml.cs
+++ b/Torch.Server/Views/Entities/VoxelMapView.xaml.cs
@@ -29,7 +29,7 @@ namespace Torch.Server.Views.Entities
private void VoxelMapView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
- ((VoxelMapViewModel)e.NewValue).UpdateAttachedGrids();
+ Task.Run(() => ((VoxelMapViewModel)e.NewValue).UpdateAttachedGrids()).Wait();
}
}
}
diff --git a/Torch.Server/Views/EntitiesControl.xaml.cs b/Torch.Server/Views/EntitiesControl.xaml.cs
index 7395747..4035084 100644
--- a/Torch.Server/Views/EntitiesControl.xaml.cs
+++ b/Torch.Server/Views/EntitiesControl.xaml.cs
@@ -68,8 +68,8 @@ namespace Torch.Server.Views
private void TreeViewItem_OnExpanded(object sender, RoutedEventArgs e)
{
- LogManager.GetLogger("EntitiesControl").Debug(nameof(TreeViewItem_OnExpanded));
- var item = (TreeViewItem)e.Source;
+ //Exact item that was expanded.
+ var item = (TreeViewItem)e.OriginalSource;
if (item.DataContext is ILazyLoad l)
l.Load();
}
diff --git a/Torch.sln b/Torch.sln
index 149cccd..6c9a522 100644
--- a/Torch.sln
+++ b/Torch.sln
@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Client", "Torch.Clien
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Server", "Torch.Server\Torch.Server.csproj", "{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Launcher", "Torch.Launcher\Torch.Launcher.csproj", "{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7AD02A71-1D4C-48F9-A8C1-789A5512424F}"
ProjectSection(SolutionItems) = preProject
NLog.config = NLog.config
@@ -40,10 +38,6 @@ Global
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Debug|x64.Build.0 = Debug|x64
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|x64.ActiveCfg = Release|x64
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|x64.Build.0 = Release|x64
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Debug|x64.ActiveCfg = Debug|x64
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Debug|x64.Build.0 = Debug|x64
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|x64.ActiveCfg = Release|x64
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Torch/Managers/MultiplayerManager.cs b/Torch/Managers/MultiplayerManager.cs
index 2aa3f2a..daeb961 100644
--- a/Torch/Managers/MultiplayerManager.cs
+++ b/Torch/Managers/MultiplayerManager.cs
@@ -83,11 +83,13 @@ namespace Torch.Managers
public IMyPlayer GetPlayerByName(string name)
{
+ ValidateOnlinePlayersList();
return _onlinePlayers.FirstOrDefault(x => x.Value.DisplayName == name).Value;
}
public IMyPlayer GetPlayerBySteamId(ulong steamId)
{
+ ValidateOnlinePlayersList();
_onlinePlayers.TryGetValue(new MyPlayer.PlayerId(steamId), out MyPlayer p);
return p;
}
@@ -116,12 +118,18 @@ namespace Torch.Managers
}
}
+ private void ValidateOnlinePlayersList()
+ {
+ if (_onlinePlayers == null)
+ _onlinePlayers = MySession.Static.Players.GetPrivateField>("m_players");
+ }
+
private void OnSessionLoaded()
{
MyMultiplayer.Static.ClientKicked += OnClientKicked;
MyMultiplayer.Static.ClientLeft += OnClientLeft;
- _onlinePlayers = MySession.Static.Players.GetPrivateField>("m_players");
+ ValidateOnlinePlayersList();
//TODO: Move these with the methods?
RemoveHandlers();
diff --git a/Torch/Managers/NetworkManager/NetworkHandlerBase.cs b/Torch/Managers/NetworkManager/NetworkHandlerBase.cs
index 667077b..dc3ce19 100644
--- a/Torch/Managers/NetworkManager/NetworkHandlerBase.cs
+++ b/Torch/Managers/NetworkManager/NetworkHandlerBase.cs
@@ -27,6 +27,7 @@ namespace Torch.Managers
///
///
///
+ ///
///
public abstract bool Handle(ulong remoteUserId, CallSite site, BitStream stream, object obj, MyPacket packet);
diff --git a/Torch/Managers/ScriptingManager.cs b/Torch/Managers/ScriptingManager.cs
index b0195e6..b599898 100644
--- a/Torch/Managers/ScriptingManager.cs
+++ b/Torch/Managers/ScriptingManager.cs
@@ -5,13 +5,14 @@ using System.Text;
using System.Threading.Tasks;
using Sandbox.ModAPI;
using Torch.API;
+using Torch.API.Managers;
using Torch.API.ModAPI;
using Torch.API.ModAPI.Ingame;
using VRage.Scripting;
namespace Torch.Managers
{
- public class ScriptingManager
+ public class ScriptingManager : IManager
{
private MyScriptWhitelist _whitelist;
@@ -24,7 +25,7 @@ namespace Torch.Managers
using (var whitelist = _whitelist.OpenBatch())
{
- //whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(TorchAPIGateway));
+ whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(TorchAPI));
whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.Both, typeof(GridExtensions));
}
diff --git a/Torch/Managers/UpdateManager.cs b/Torch/Managers/UpdateManager.cs
index e4784d7..a5018a7 100644
--- a/Torch/Managers/UpdateManager.cs
+++ b/Torch/Managers/UpdateManager.cs
@@ -11,7 +11,7 @@ namespace Torch.Managers
///
/// Handles updating of the DS and Torch plugins.
///
- public class UpdateManager
+ public class UpdateManager : IDisposable
{
private Timer _updatePollTimer;
@@ -24,5 +24,11 @@ namespace Torch.Managers
{
}
+
+ ///
+ public void Dispose()
+ {
+ _updatePollTimer?.Dispose();
+ }
}
}
diff --git a/Torch/Persistent.cs b/Torch/Persistent.cs
index 527955f..2dd3d3e 100644
--- a/Torch/Persistent.cs
+++ b/Torch/Persistent.cs
@@ -9,10 +9,10 @@ using Newtonsoft.Json;
namespace Torch
{
///
- /// Simple class that manages saving to disk using JSON serialization.
+ /// Simple class that manages saving to disk using JSON serialization.
///
- /// Data class
- public class Persistent : IDisposable where T : new()
+ /// Data class type
+ public sealed class Persistent : IDisposable where T : new()
{
public string Path { get; set; }
public T Data { get; private set; }
diff --git a/Torch/Torch.csproj b/Torch/Torch.csproj
index 442a8c9..60ab94c 100644
--- a/Torch/Torch.csproj
+++ b/Torch/Torch.csproj
@@ -30,6 +30,7 @@
x64
prompt
MinimumRecommendedRules.ruleset
+ bin\x64\Release\Torch.xml
diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs
index 3e2acaf..aea773d 100644
--- a/Torch/TorchBase.cs
+++ b/Torch/TorchBase.cs
@@ -18,6 +18,7 @@ using Sandbox.ModAPI;
using SpaceEngineers.Game;
using Torch.API;
using Torch.API.Managers;
+using Torch.API.ModAPI;
using Torch.Commands;
using Torch.Managers;
using VRage.Collections;
@@ -30,6 +31,9 @@ using VRage.Utils;
namespace Torch
{
+ ///
+ /// Base class for code shared between the Torch client and server.
+ ///
public abstract class TorchBase : ViewModel, ITorchBase, IPlugin
{
///
@@ -51,10 +55,14 @@ namespace Torch
public event Action SessionLoaded;
public event Action SessionUnloading;
public event Action SessionUnloaded;
- private HashSet _managers;
+ private readonly List _managers;
private bool _init;
+ ///
+ ///
+ ///
+ /// Thrown if a TorchBase instance already exists.
protected TorchBase()
{
if (Instance != null)
@@ -71,19 +79,15 @@ namespace Torch
Network = new NetworkManager(this);
Commands = new CommandManager(this);
- _managers = new HashSet
- {
- Plugins,
- Multiplayer,
- Entities,
- Network,
- Commands
- };
+ _managers = new List {Network, Commands, Plugins, Multiplayer, Entities, new ChatManager(this)};
+
+
+ TorchAPI.Instance = this;
}
- public HashSetReader GetManagers()
+ public ListReader GetManagers()
{
- return new HashSetReader(_managers);
+ return new ListReader(_managers);
}
public T GetManager() where T : class, IManager
@@ -120,11 +124,11 @@ namespace Torch
await Task.Run(() =>
{
- if (!e.WaitOne(60000))
- {
- Log.Error("Save failed!");
- Multiplayer.SendMessage("Save timed out!", "Error");
- }
+ if (e.WaitOne(60000))
+ return;
+
+ Log.Error("Save failed!");
+ Multiplayer.SendMessage("Save timed out!", "Error");
}).ConfigureAwait(false);
}
}
@@ -251,7 +255,7 @@ namespace Torch
public virtual void Start()
{
- Plugins.Init();
+
}
public virtual void Stop() { }