Compare commits
122 Commits
v1.0.47-ma
...
2.0.29
Author | SHA1 | Date | |
---|---|---|---|
![]() |
646916dc7b | ||
![]() |
563c611e3e | ||
![]() |
579b090c85 | ||
![]() |
f49748da9f | ||
![]() |
534fdd0e49 | ||
![]() |
6070bddd7d | ||
![]() |
d8e2d9fcec | ||
![]() |
615defabb6 | ||
![]() |
0d719ee01f | ||
22c4cfb039 | |||
5f0ffb6f9a | |||
1b2a989441 | |||
![]() |
83dfc7152f | ||
d7e5f53e4f | |||
9b08b39a1f | |||
![]() |
8011f9eed7 | ||
1df791e7a8 | |||
![]() |
bbc2f9046f | ||
117ea7df91 | |||
6ec355f931 | |||
![]() |
343420f1d8 | ||
![]() |
1396c8b1da | ||
![]() |
9900f92133 | ||
![]() |
3be524d169 | ||
ed694ae95b | |||
e9a9e180a8 | |||
a8dfaf6239 | |||
bbdd1c7e01 | |||
e70e1ca4e6 | |||
![]() |
d65c20a05d | ||
f21976cf2d | |||
0c918106bc | |||
6c9ec57d87 | |||
![]() |
b0f491ac88 | ||
![]() |
a426ad9e02 | ||
![]() |
ba75b1583a | ||
![]() |
45068ea932 | ||
![]() |
181e9297a1 | ||
![]() |
e0417d3235 | ||
![]() |
17a244a536 | ||
![]() |
bd27360655 | ||
![]() |
b24eee3ecf | ||
![]() |
9068558a53 | ||
![]() |
9c22948ce9 | ||
![]() |
2b1a5d4c6e | ||
![]() |
2860dda41b | ||
![]() |
5483728a4e | ||
![]() |
32d318be5e | ||
![]() |
f349366b58 | ||
![]() |
73ce979b54 | ||
![]() |
73b95472bc | ||
![]() |
9b832a998d | ||
![]() |
b1087822c9 | ||
![]() |
ef2d35879c | ||
![]() |
83d8eea9ef | ||
![]() |
8cdd992350 | ||
![]() |
b9cb71e11f | ||
![]() |
1a1a7e779a | ||
![]() |
6bcd2ea58e | ||
![]() |
b8a06f7bd7 | ||
![]() |
d44b1a592c | ||
![]() |
d7d556d2f2 | ||
![]() |
850b313269 | ||
![]() |
fe985e1a9c | ||
![]() |
aeea192860 | ||
![]() |
b8be5b2dce | ||
![]() |
ea08d60d58 | ||
![]() |
6493a305f7 | ||
![]() |
bc0a2b89b8 | ||
![]() |
846c2aa42e | ||
![]() |
ac1ec431fd | ||
![]() |
3acaf25376 | ||
![]() |
e8928b6b3b | ||
![]() |
8478ee3752 | ||
![]() |
ead8e3a4fc | ||
![]() |
f73b9df924 | ||
![]() |
d524651da9 | ||
![]() |
2743e5b42d | ||
![]() |
02bd9df059 | ||
![]() |
a5cc132151 | ||
![]() |
92dea1986c | ||
![]() |
c03eb79f81 | ||
![]() |
0ee9c5f97c | ||
![]() |
c283059106 | ||
![]() |
422963517f | ||
![]() |
d2ac0e44be | ||
![]() |
c5acf61f7c | ||
![]() |
197d04a661 | ||
![]() |
99ab7d0eea | ||
![]() |
17f97af52f | ||
![]() |
ed7c897bd2 | ||
![]() |
e4d3c3987f | ||
![]() |
067d8802b6 | ||
![]() |
8f32f64ede | ||
![]() |
90ff3f93f0 | ||
![]() |
ad28b302f9 | ||
![]() |
a0d0976a6a | ||
![]() |
a9c9a0de68 | ||
![]() |
9a967345b9 | ||
![]() |
98a4be655f | ||
![]() |
76de8f3d0b | ||
![]() |
6f886d4f7d | ||
![]() |
a753abb8fd | ||
![]() |
452970d2fd | ||
![]() |
e28c38e04f | ||
![]() |
5d9fe01c69 | ||
![]() |
04227912b0 | ||
![]() |
44dd0805e2 | ||
![]() |
c5c8e527da | ||
![]() |
49f68a8fcc | ||
![]() |
f8a3647308 | ||
![]() |
0a40b1fe0f | ||
![]() |
a1e9434444 | ||
![]() |
d2d96df8be | ||
![]() |
b40f288827 | ||
![]() |
6267cffebe | ||
![]() |
5fe25fb781 | ||
![]() |
d05e979ede | ||
![]() |
1afb126cb5 | ||
![]() |
d52348149a | ||
![]() |
20eac508d3 | ||
![]() |
8ba02a84d3 |
88
.github/workflows/release.yaml
vendored
Normal file
88
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_CONFIGURATION: Release
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
name: Checkout
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-dotnet@v3
|
||||
name: Setup dotnet
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode
|
||||
|
||||
- name: Git Version
|
||||
id: version
|
||||
uses: codacy/git-version@2.7.1
|
||||
|
||||
- name: Build
|
||||
run: dotnet build Torch.Server/Torch.Server.csproj --no-restore -c ${{ env.BUILD_CONFIGURATION }} -p:Version="${{ steps.version.outputs.version }}" -p:AssemblyVersion="${{ steps.version.outputs.version }}"
|
||||
- name: Publish
|
||||
run: dotnet publish Torch.Server/Torch.Server.csproj --no-build --sc -c ${{ env.BUILD_CONFIGURATION }} -o ./publish
|
||||
|
||||
- uses: vimtor/action-zip@v1
|
||||
name: Zip Release
|
||||
with:
|
||||
files: publish/
|
||||
dest: release.zip
|
||||
|
||||
- name: Create release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
release_name: Release v${{ steps.version.outputs.version }}
|
||||
body: ${{ steps.github_release.outputs.changelog }}
|
||||
draft: true
|
||||
prerelease: false
|
||||
|
||||
- name: Upload release asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: release.zip
|
||||
asset_name: torch-server.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- uses: eregon/publish-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
release_id: ${{ steps.create_release.outputs.id }}
|
||||
|
||||
- run: dotnet pack -c Release ./Torch.API/Torch.API.csproj -o pack -p:Version="${{ steps.version.outputs.version }}" -p:AssemblyVersion="${{ steps.version.outputs.version }}" --no-build
|
||||
- run: dotnet pack -c Release ./Torch/Torch.csproj -o pack -p:Version="${{ steps.version.outputs.version }}" -p:AssemblyVersion="${{ steps.version.outputs.version }}" --no-build
|
||||
- run: dotnet pack -c Release ./Torch.Server/Torch.Server.csproj -o pack -p:Version="${{ steps.version.outputs.version }}" -p:AssemblyVersion="${{ steps.version.outputs.version }}" --no-build
|
||||
- run: mkdir blank && sed -i 's/torchVersion/${{ steps.version.outputs.version }}/g' Torch.Server.ReferenceAssemblies.net7.nuspec && nuget pack Torch.Server.ReferenceAssemblies.net7.nuspec -BasePath ./blank -OutputDirectory pack -NonInteractive -NoPackageAnalysis
|
||||
|
||||
- name: Install Sleet
|
||||
run: dotnet tool install -g sleet
|
||||
- name: Push Nuget Package
|
||||
env:
|
||||
SLEET_FEED_TYPE: s3
|
||||
SLEET_FEED_PATH: https://nuget.storage.yandexcloud.net
|
||||
SLEET_FEED_BUCKETNAME: nuget
|
||||
SLEET_FEED_SERVICEURL: https://storage.yandexcloud.net
|
||||
SLEET_FEED_ACCESSKEYID: ${{ secrets.S3_KEY_ID }}
|
||||
SLEET_FEED_SECRETACCESSKEY: ${{ secrets.S3_KEY }}
|
||||
run: sleet push ./pack
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -159,10 +159,6 @@ publish/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
|
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,33 +0,0 @@
|
||||
# Torch 1.1.229.265
|
||||
* Features
|
||||
- Added more lenient version parsing for plugins (v#.# should work)
|
||||
- Added countdown option to restart command (!restart [seconds])
|
||||
* Fixes
|
||||
- General fixes to work with the latest SE version
|
||||
- Fixed config changes not saving
|
||||
- (hopefully) Fixed issue causing crashes on servers using the Windows Classic theme
|
||||
|
||||
# Torch 1.1.207.7
|
||||
* Notes
|
||||
- This release makes significant changes to TorchConfig.xml. It has been renamed to Torch.cfg and has different options.
|
||||
* Features
|
||||
- Plugins, Torch, and the DS can now all update automatically
|
||||
- Changed command prefix to !
|
||||
- Added manual save command (thanks to Maldark)
|
||||
- Added restart command
|
||||
- Improved instance creation: now creates an entire skeleton instance with blank config
|
||||
- Added instance name to console title
|
||||
* Fixes
|
||||
- Optimized UI so it's snappier and freezes less often
|
||||
- Fixed NetworkManager.RaiseEvent overload that had an off-by-one bug
|
||||
- Fixed chat window so it automatically scrolls down
|
||||
|
||||
# Torch 1.0.182.329
|
||||
* Improved logging, logs now to go the Logs folder and aren't deleted on start
|
||||
* Fixed chat tab not enabling with -autostart
|
||||
* Fixed player list
|
||||
* Watchdog time-out is now configurable in TorchConfig.xml
|
||||
* Fixed infinario log spam
|
||||
* Fixed crash when sending empty message from chat tab
|
||||
* Fixed permissions on Torch commands
|
||||
* Changed plugin StoragePath to the current instance path (per-instance configs)
|
8
Directory.Build.props
Normal file
8
Directory.Build.props
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -1,5 +0,0 @@
|
||||
$buildSalt = $Env:BUILD_NUMBER
|
||||
$branchName = $Env:BRANCH_NAME
|
||||
$gitSimpleVersion = git describe --tags --abbrev=0
|
||||
$simpleVersionStandard = echo $gitSimpleVersion | Select-String -Pattern "([0-9]+)\.([0-9]+)\.([0-9]+)" | % {$_.Matches} | %{$_.Groups[1].Value+"."+$_.Groups[2].Value+"."+$_.Groups[3].Value}
|
||||
Write-Host "$simpleVersionStandard.$buildSalt"
|
@@ -1,26 +0,0 @@
|
||||
pushd
|
||||
|
||||
$steamData = "C:/Steam/Data/"
|
||||
$steamCMDPath = "C:/Steam/steamcmd/"
|
||||
$steamCMDZip = "C:/Steam/steamcmd.zip"
|
||||
|
||||
if (!(Test-Path $steamData)) {
|
||||
mkdir "$steamData"
|
||||
}
|
||||
if (!(Test-Path $steamCMDPath)) {
|
||||
if (!(Test-Path $steamCMDZip)) {
|
||||
Invoke-WebRequest -OutFile $steamCMDZip https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
|
||||
}
|
||||
Expand-Archive $steamCMDZip -DestinationPath $steamCMDPath
|
||||
}
|
||||
& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740" "+quit"
|
||||
|
||||
$dataPath = $steamData.Replace("/", "\");
|
||||
$contentPath = "$dataPath\Content";
|
||||
if (Test-Path $contentPath) {
|
||||
Remove-Item -LiteralPath $contentPath -Force -Recurse
|
||||
}
|
||||
|
||||
cmd /S /C mklink /J .\GameBinaries $dataPath\DedicatedServer64
|
||||
|
||||
popd
|
55
Jenkinsfile
vendored
55
Jenkinsfile
vendored
@@ -1,55 +0,0 @@
|
||||
def packageAndArchive(buildMode, packageName) {
|
||||
zipFile = "bin\\${packageName}.zip"
|
||||
packageDir = "publish"
|
||||
|
||||
bat 'powershell -Command { Compress-Archive -Path ${packageDir}\\* -DestinationPath ${zipFile} }'
|
||||
archiveArtifacts artifacts: zipFile, caseSensitive: false, onlyIfSuccessful: true
|
||||
}
|
||||
|
||||
node('windows') {
|
||||
stage('Checkout') {
|
||||
checkout scm
|
||||
bat 'git pull https://github.com/TorchAPI/Torch/ ${env.BRANCH_NAME} --tags'
|
||||
}
|
||||
|
||||
stage('Acquire SE') {
|
||||
bat 'powershell -File Jenkins/jenkins-grab-se.ps1'
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
dotnetVersion = bat(returnStdout: true, script: '@powershell -NonInteractive -NoLogo -NoProfile -File Jenkins/get-version.ps1').trim()
|
||||
infoVersion = "${dotnetVersion}-${env.BRANCH_NAME}"
|
||||
currentBuild.description = infoVersion
|
||||
|
||||
bat 'dotnet publish .\\Torch.Server\\Torch.Server.csproj -p:PackageVersion=${dotnetVersion} -p:InformationalVersion=${infoVersion} --self-contained -f net6-windows -r win-x64 -c Release -o .\\publish\\'
|
||||
}
|
||||
|
||||
stage('Archive') {
|
||||
//archiveArtifacts artifacts: "bin/x64/${buildMode}/Torch*", caseSensitive: false, fingerprint: true, onlyIfSuccessful: true
|
||||
|
||||
packageAndArchive(buildMode, "torch-server")
|
||||
|
||||
/*packageAndArchive(buildMode, "torch-client", "Torch.Server*")*/
|
||||
}
|
||||
|
||||
/* Disabled because they fail builds more often than they detect actual problems
|
||||
stage('Test') {
|
||||
bat 'IF NOT EXIST reports MKDIR reports'
|
||||
bat "\"packages/xunit.runner.console.2.2.0/tools/xunit.console.exe\" \"bin-test/x64/${buildMode}/Torch.Tests.dll\" \"bin-test/x64/${buildMode}/Torch.Server.Tests.dll\" \"bin-test/x64/${buildMode}/Torch.Client.Tests.dll\" -parallel none -xml \"reports/Torch.Tests.xml\""
|
||||
|
||||
step([
|
||||
$class: 'XUnitBuilder',
|
||||
thresholdMode: 1,
|
||||
thresholds: [[$class: 'FailedThreshold', failureThreshold: '1']],
|
||||
tools: [[
|
||||
$class: 'XUnitDotNetTestType',
|
||||
deleteOutputFiles: true,
|
||||
failIfNotNew: true,
|
||||
pattern: 'reports/*.xml',
|
||||
skipNoTestFiles: false,
|
||||
stopProcessingIfError: true
|
||||
]]
|
||||
])
|
||||
}
|
||||
*/
|
||||
}
|
14
README.md
14
README.md
@@ -1,5 +1,3 @@
|
||||
[](https://ci.appveyor.com/project/zznty/torch/branch/master)
|
||||
|
||||
# What is Torch?
|
||||
Torch is the successor to SE Server Extender and gives server admins the tools they need to keep their Space Engineers servers running smoothly. It features a user interface with live management tools and a plugin system so you can run your server exactly how you'd like. Torch is still in early development so there may be bugs and incomplete features.
|
||||
|
||||
@@ -14,7 +12,10 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
|
||||
|
||||
### Fork Difference
|
||||
* .NET 6.0 runtime
|
||||
* Additional options & features
|
||||
* Optimized in-game scripts (also newer compiler & language versions)
|
||||
* Better configuration via cli arguments, environment variables or xml config
|
||||
* Designed to run multiple instance from same install directory without having you to waste disk space
|
||||
* Mostly compatible with original torch's plugins
|
||||
|
||||
### Discord
|
||||
|
||||
@@ -23,10 +24,13 @@ If you have any questions or issues please join our [discord](https://discord.gg
|
||||
### Installation
|
||||
|
||||
* Unzip the Torch release into its own directory and run the executable. It will automatically download the SE DS and generate the other necessary files.
|
||||
- If you already have a DS installed you can unzip the Torch files into the folder that contains the DedicatedServer64 folder.
|
||||
- If you already have a DS installed you can:
|
||||
* Unzip the Torch files into the folder that contains the DedicatedServer64 folder.
|
||||
* Pass path to game files using config parameter `gamePath`
|
||||
|
||||
# Building
|
||||
To build Torch you must first have a complete SE Dedicated installation somewhere. Before you open the solution, run the Setup batch file and enter the path of that installation's DedicatedServer64 folder. The script will make a symlink to that folder so the Torch solution can find the DLL references it needs.
|
||||
|
||||
As a regular dotnet project with cli by running `dotnet build Torch.Server/Torch.Server.csproj`, with VS 2022 or higher, with JB Rider or Fleet.
|
||||
|
||||
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE)
|
||||
|
||||
|
@@ -1,13 +0,0 @@
|
||||
:: This script creates a symlink to the game binaries to account for different installation directories on different systems.
|
||||
|
||||
@echo off
|
||||
set /p path="Please enter the folder location of your SpaceEngineersDedicated.exe: "
|
||||
cd %~dp0
|
||||
mklink /J GameBinaries "%path%"
|
||||
if errorlevel 1 goto Error
|
||||
echo Done! You can now open the Torch solution without issue.
|
||||
goto End
|
||||
:Error
|
||||
echo An error occured creating the symlink.
|
||||
:End
|
||||
pause
|
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.Session;
|
||||
using VRage.Game.ModAPI;
|
||||
@@ -16,30 +17,6 @@ namespace Torch.API
|
||||
/// </summary>
|
||||
public interface ITorchBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Fired when the session begins loading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionLoading;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the session finishes loading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when the session begins unloading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionUnloading;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the session finishes unloading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionUnloaded;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the currently running session instance, or null if none exists.
|
||||
/// </summary>
|
||||
@@ -50,6 +27,11 @@ namespace Torch.API
|
||||
/// </summary>
|
||||
ITorchConfig Config { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Extended Configuration for the current instance.
|
||||
/// </summary>
|
||||
IConfiguration Configuration { get; }
|
||||
|
||||
/// <inheritdoc cref="IPluginManager"/>
|
||||
[Obsolete]
|
||||
IPluginManager Plugins { get; }
|
||||
@@ -68,6 +50,16 @@ namespace Torch.API
|
||||
/// </summary>
|
||||
Version TorchVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Path of the dedicated instance folder.
|
||||
/// </summary>
|
||||
string InstancePath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the dedicated instance.
|
||||
/// </summary>
|
||||
string InstanceName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoke an action on the game thread.
|
||||
/// </summary>
|
||||
@@ -146,16 +138,6 @@ namespace Torch.API
|
||||
/// </summary>
|
||||
ServerState State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Path of the dedicated instance folder.
|
||||
/// </summary>
|
||||
string InstancePath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the dedicated instance.
|
||||
/// </summary>
|
||||
string InstanceName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Raised when the server's Init() method has completed.
|
||||
/// </summary>
|
||||
|
@@ -22,7 +22,6 @@ namespace Torch
|
||||
bool ShouldUpdatePlugins { get; }
|
||||
bool ShouldUpdateTorch { get; }
|
||||
int TickTimeout { get; set; }
|
||||
string WaitForPID { get; set; }
|
||||
string ChatName { get; set; }
|
||||
string ChatColor { get; set; }
|
||||
string TestPlugin { get; set; }
|
||||
@@ -32,6 +31,24 @@ namespace Torch
|
||||
int FontSize { get; set; }
|
||||
UGCServiceType UgcServiceType { get; set; }
|
||||
bool EntityManagerEnabled { get; set; }
|
||||
string LoginToken { get; set; }
|
||||
UpdateSource UpdateSource { get; set; }
|
||||
List<string> Packages { get; set; }
|
||||
|
||||
void Save(string path = null);
|
||||
}
|
||||
|
||||
public class UpdateSource
|
||||
{
|
||||
public UpdateSourceType SourceType { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Repository { get; set; }
|
||||
public string Branch { get; set; }
|
||||
}
|
||||
|
||||
public enum UpdateSourceType
|
||||
{
|
||||
Github,
|
||||
Jenkins
|
||||
}
|
||||
}
|
@@ -14,7 +14,6 @@ public interface IInstanceManager : IManager
|
||||
|
||||
public interface IWorld
|
||||
{
|
||||
string FolderName { get; }
|
||||
string WorldPath { get; }
|
||||
MyObjectBuilder_SessionSettings KeenSessionSettings { get; }
|
||||
MyObjectBuilder_Checkpoint KeenCheckpoint { get; }
|
||||
|
14
Torch.API/Managers/IPackageManager.cs
Normal file
14
Torch.API/Managers/IPackageManager.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using Torch.API.WebAPI.Plugins;
|
||||
|
||||
namespace Torch.API.Managers;
|
||||
|
||||
public interface IPackageManager : IManager
|
||||
{
|
||||
IReadOnlySet<Package> Packages { get; }
|
||||
|
||||
bool TryGetPackageAssemblies(Package package, [MaybeNullWhen(false)] out Assembly[] assemblies);
|
||||
}
|
@@ -14,6 +14,9 @@ namespace Torch.API.Managers
|
||||
/// <summary>
|
||||
/// Fired when plugins are loaded.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fired when plugins are loaded and immediately if subscribed after the plugins are loaded.
|
||||
/// </remarks>
|
||||
event Action<IReadOnlyCollection<ITorchPlugin>> PluginsLoaded;
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,105 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<AssemblyTitle>Torch API</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<OutputPath>..\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<UseWpf>True</UseWpf>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$(Configuration) == 'Release'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="SemanticVersioning" Version="2.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.2" Condition="$(TargetFramework) == 'net48'" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" Condition="$(TargetFramework) == 'net48'" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" Condition="$(TargetFramework) == 'net48'" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HavokWrapper, Version=1.0.6278.22649, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\HavokWrapper.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game, Version=0.1.6305.30774, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics, Version=0.1.6305.30761, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.ObjectBuilders, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage">
|
||||
<HintPath>..\GameBinaries\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Audio, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Audio.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Dedicated">
|
||||
<HintPath>..\GameBinaries\VRage.Dedicated.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library">
|
||||
<HintPath>..\GameBinaries\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render11, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Render11.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Scripting, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Scripting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="NuGet.Commands" Version="6.8.0" />
|
||||
<PackageReference Include="NuGet.DependencyResolver.Core" Version="6.8.0" />
|
||||
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.203.505.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>compile</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,8 +0,0 @@
|
||||
#if NETFRAMEWORK
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
public class IsExternalInit
|
||||
{
|
||||
}
|
||||
#endif
|
@@ -1,88 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Torch.API.Utils;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API.WebAPI
|
||||
{
|
||||
public class JenkinsQuery
|
||||
{
|
||||
private const string BRANCH_QUERY = "http://136.243.80.164:2690/job/Torch/job/{0}/" + API_PATH;
|
||||
private const string ARTIFACT_PATH = "artifact/bin/torch-server.zip";
|
||||
private const string API_PATH = "api/json";
|
||||
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static JenkinsQuery _instance;
|
||||
public static JenkinsQuery Instance => _instance ??= new JenkinsQuery();
|
||||
private HttpClient _client;
|
||||
|
||||
private JenkinsQuery()
|
||||
{
|
||||
_client = new HttpClient();
|
||||
}
|
||||
|
||||
public async Task<Job> GetLatestVersion(string branch)
|
||||
{
|
||||
var h = await _client.GetAsync(string.Format(BRANCH_QUERY, branch));
|
||||
if (!h.IsSuccessStatusCode)
|
||||
{
|
||||
Log.Error($"'{branch}' Branch query failed with code {h.StatusCode}");
|
||||
if(h.StatusCode == HttpStatusCode.NotFound)
|
||||
Log.Error("This likely means you're trying to update a branch that is not public on Jenkins. Sorry :(");
|
||||
return null;
|
||||
}
|
||||
|
||||
var branchResponse = await h.Content.ReadFromJsonAsync<BranchResponse>();
|
||||
|
||||
if (branchResponse is null)
|
||||
{
|
||||
Log.Error("Error reading branch response");
|
||||
return null;
|
||||
}
|
||||
|
||||
h = await _client.GetAsync($"{branchResponse.LastStableBuild.Url}{API_PATH}");
|
||||
if (h.IsSuccessStatusCode)
|
||||
return await h.Content.ReadFromJsonAsync<Job>();
|
||||
|
||||
Log.Error($"Job query failed with code {h.StatusCode}");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadRelease(Job job, string path)
|
||||
{
|
||||
var h = await _client.GetAsync(job.Url + ARTIFACT_PATH);
|
||||
if (!h.IsSuccessStatusCode)
|
||||
{
|
||||
Log.Error($"Job download failed with code {h.StatusCode}");
|
||||
return false;
|
||||
}
|
||||
var s = await h.Content.ReadAsStreamAsync();
|
||||
#if !NETFRAMEWORK
|
||||
await using var fs = new FileStream(path, FileMode.Create);
|
||||
#else
|
||||
using var fs = new FileStream(path, FileMode.Create);
|
||||
#endif
|
||||
await s.CopyToAsync(fs);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public record BranchResponse(string Name, string Url, Build LastBuild, Build LastStableBuild);
|
||||
|
||||
public record Build(int Number, string Url);
|
||||
|
||||
public record Job(int Number, bool Building, string Description, string Result, string Url,
|
||||
[property: JsonConverter(typeof(SemanticVersionConverter))] Version Version);
|
||||
}
|
12
Torch.API/WebAPI/Plugin/IPluginQuery.cs
Normal file
12
Torch.API/WebAPI/Plugin/IPluginQuery.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugin;
|
||||
|
||||
public interface IPluginQuery
|
||||
{
|
||||
Task<PluginsResponse> QueryAll();
|
||||
Task<PluginItem> QueryOne(Guid guid);
|
||||
Task<bool> DownloadPlugin(Guid guid, string path = null);
|
||||
Task<bool> DownloadPlugin(PluginItem item, string path = null);
|
||||
}
|
81
Torch.API/WebAPI/Plugin/LegacyPluginQuery.cs
Normal file
81
Torch.API/WebAPI/Plugin/LegacyPluginQuery.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugin;
|
||||
|
||||
public class LegacyPluginQuery : IPluginQuery
|
||||
{
|
||||
private const string BASE_URL = "https://torchapi.com/";
|
||||
private readonly HttpClient _client;
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private LegacyPluginQuery()
|
||||
{
|
||||
_client = new()
|
||||
{
|
||||
BaseAddress = new(BASE_URL)
|
||||
};
|
||||
}
|
||||
|
||||
public static LegacyPluginQuery Instance { get; } = new();
|
||||
|
||||
public async Task<PluginsResponse> QueryAll()
|
||||
{
|
||||
return await _client.GetFromJsonAsync<PluginsResponse>("/api/plugins/", CancellationToken.None);
|
||||
}
|
||||
|
||||
public async Task<PluginItem> QueryOne(Guid guid)
|
||||
{
|
||||
using var res = await _client.GetAsync($"/api/plugins/search/{guid}");
|
||||
if (!res.IsSuccessStatusCode)
|
||||
return null;
|
||||
return await res.Content.ReadFromJsonAsync<PluginItem>();
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(Guid guid, string path = null)
|
||||
{
|
||||
var item = await QueryOne(guid);
|
||||
if (item is null) return false;
|
||||
return await DownloadPlugin(item, path);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(PluginItem item, string path = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
path ??= Path.Combine(AppContext.BaseDirectory, "Plugins", $"{item.Name}.zip");
|
||||
|
||||
if (item.Versions.Length == 0)
|
||||
{
|
||||
Log.Error($"Selected plugin {item.Name} does not have any versions to download!");
|
||||
return false;
|
||||
}
|
||||
var version = item.Versions.FirstOrDefault(v => v.Version == item.LatestVersion);
|
||||
if (version is null)
|
||||
{
|
||||
Log.Error($"Could not find latest version for selected plugin {item.Name}");
|
||||
return false;
|
||||
}
|
||||
var s = await _client.GetStreamAsync(version.Url);
|
||||
|
||||
if(File.Exists(path))
|
||||
File.Delete(path);
|
||||
|
||||
await using var f = File.Create(path);
|
||||
await s.CopyToAsync(f);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to download plugin!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
11
Torch.API/WebAPI/Plugin/PluginItem.cs
Normal file
11
Torch.API/WebAPI/Plugin/PluginItem.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugin;
|
||||
|
||||
public record PluginItem(Guid Id, string Name, string Author, string Description, string LatestVersion,
|
||||
VersionItem[] Versions)
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool Installed { get; set; }
|
||||
}
|
3
Torch.API/WebAPI/Plugin/PluginsResponse.cs
Normal file
3
Torch.API/WebAPI/Plugin/PluginsResponse.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Torch.API.WebAPI.Plugin;
|
||||
|
||||
public record PluginsResponse(PluginItem[] Plugins);
|
6
Torch.API/WebAPI/Plugin/VersionItem.cs
Normal file
6
Torch.API/WebAPI/Plugin/VersionItem.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugin;
|
||||
|
||||
public record VersionItem(string Version, string Note, [property: JsonPropertyName("is_beta")] bool IsBeta,
|
||||
string Url);
|
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
|
||||
namespace Torch.API.WebAPI
|
||||
{
|
||||
public class PluginQuery
|
||||
{
|
||||
private const string ALL_QUERY = "https://torchapi.com/api/plugins/";
|
||||
private const string PLUGIN_QUERY = "https://torchapi.com/api/plugins/?guid={0}";
|
||||
private readonly HttpClient _client;
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static PluginQuery _instance;
|
||||
public static PluginQuery Instance => _instance ??= new();
|
||||
|
||||
private PluginQuery()
|
||||
{
|
||||
_client = new();
|
||||
}
|
||||
|
||||
public async Task<PluginsResponse> QueryAll()
|
||||
{
|
||||
return (PluginsResponse) await _client.GetFromJsonAsync(ALL_QUERY, typeof(PluginsResponse), CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<PluginItem> QueryOne(Guid guid)
|
||||
{
|
||||
return QueryOne(guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<PluginItem> QueryOne(string guid)
|
||||
{
|
||||
using var res = await _client.GetAsync(string.Format(PLUGIN_QUERY, guid));
|
||||
if (!res.IsSuccessStatusCode)
|
||||
return null;
|
||||
return await res.Content.ReadFromJsonAsync<PluginItem>();
|
||||
}
|
||||
|
||||
public Task<bool> DownloadPlugin(Guid guid, string path = null)
|
||||
{
|
||||
return DownloadPlugin(guid.ToString(), path);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(string guid, string path = null)
|
||||
{
|
||||
var item = await QueryOne(guid);
|
||||
if (item is null) return false;
|
||||
return await DownloadPlugin(item, path);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(PluginItem item, string path = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
path ??= Path.Combine(Directory.GetCurrentDirectory(), "Plugins", $"{item.Name}.zip");
|
||||
|
||||
if (item.Versions.Length == 0)
|
||||
{
|
||||
Log.Error($"Selected plugin {item.Name} does not have any versions to download!");
|
||||
return false;
|
||||
}
|
||||
var version = item.Versions.FirstOrDefault(v => v.Version == item.LatestVersion);
|
||||
if (version is null)
|
||||
{
|
||||
Log.Error($"Could not find latest version for selected plugin {item.Name}");
|
||||
return false;
|
||||
}
|
||||
var s = await _client.GetStreamAsync(version.Url);
|
||||
|
||||
if(File.Exists(path))
|
||||
File.Delete(path);
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using var f = File.Create(path);
|
||||
#else
|
||||
await using var f = File.Create(path);
|
||||
#endif
|
||||
await s.CopyToAsync(f);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to download plugin!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public record PluginsResponse(PluginItem[] Plugins);
|
||||
|
||||
public record PluginItem(Guid Id, string Name, string Author, string Description, string LatestVersion,
|
||||
VersionItem[] Versions)
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool Installed { get; set; }
|
||||
}
|
||||
|
||||
public record VersionItem(string Version, string Note, [property: JsonPropertyName("is_beta")] bool IsBeta,
|
||||
string Url);
|
||||
}
|
11
Torch.API/WebAPI/Plugins/IPackageItem.cs
Normal file
11
Torch.API/WebAPI/Plugins/IPackageItem.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#nullable enable
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public interface IPackageItem
|
||||
{
|
||||
Task<Stream> OpenFileAsync();
|
||||
public string FileName { get; }
|
||||
}
|
12
Torch.API/WebAPI/Plugins/IPackageReader.cs
Normal file
12
Torch.API/WebAPI/Plugins/IPackageReader.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public interface IPackageReader
|
||||
{
|
||||
Task<(IEnumerable<IPackageItem> Root, IReadOnlyDictionary<PackageDependency, IEnumerable<IPackageItem>> Dependencies)> GetItemsAsync();
|
||||
}
|
11
Torch.API/WebAPI/Plugins/IPackageResolver.cs
Normal file
11
Torch.API/WebAPI/Plugins/IPackageResolver.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public interface IPackageResolver
|
||||
{
|
||||
Task<IEnumerable<Package>> ResolvePackagesAsync(IReadOnlyDictionary<string, string> packages);
|
||||
Task<IPackageReader> GetPackageAsync(Package package);
|
||||
}
|
87
Torch.API/WebAPI/Plugins/NLogLogger.cs
Normal file
87
Torch.API/WebAPI/Plugins/NLogLogger.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NuGet.Common;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
internal class NLogLogger : ILogger
|
||||
{
|
||||
private readonly NLog.ILogger _logger;
|
||||
|
||||
public NLogLogger(NLog.ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void LogDebug(string data)
|
||||
{
|
||||
_logger.Debug(data);
|
||||
}
|
||||
|
||||
public void LogVerbose(string data)
|
||||
{
|
||||
_logger.Trace(data);
|
||||
}
|
||||
|
||||
public void LogInformation(string data)
|
||||
{
|
||||
_logger.Info(data);
|
||||
}
|
||||
|
||||
public void LogMinimal(string data)
|
||||
{
|
||||
_logger.Debug(data);
|
||||
}
|
||||
|
||||
public void LogWarning(string data)
|
||||
{
|
||||
_logger.Warn(data);
|
||||
}
|
||||
|
||||
public void LogError(string data)
|
||||
{
|
||||
_logger.Error(data);
|
||||
}
|
||||
|
||||
public void LogInformationSummary(string data)
|
||||
{
|
||||
_logger.Info(data);
|
||||
}
|
||||
|
||||
public void Log(LogLevel level, string data)
|
||||
{
|
||||
_logger.Log(ToNLogLevel(level), data);
|
||||
}
|
||||
|
||||
private static NLog.LogLevel ToNLogLevel(LogLevel level)
|
||||
{
|
||||
return level switch
|
||||
{
|
||||
LogLevel.Debug => NLog.LogLevel.Debug,
|
||||
LogLevel.Verbose => NLog.LogLevel.Trace,
|
||||
LogLevel.Information => NLog.LogLevel.Info,
|
||||
LogLevel.Minimal => NLog.LogLevel.Debug,
|
||||
LogLevel.Warning => NLog.LogLevel.Warn,
|
||||
LogLevel.Error => NLog.LogLevel.Error,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(level), level, null)
|
||||
};
|
||||
}
|
||||
|
||||
public Task LogAsync(LogLevel level, string data)
|
||||
{
|
||||
Log(level, data);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Log(ILogMessage message)
|
||||
{
|
||||
_logger.Log(ToNLogLevel(message.Level), message.FormatWithCode);
|
||||
}
|
||||
|
||||
public Task LogAsync(ILogMessage message)
|
||||
{
|
||||
Log(message);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
10
Torch.API/WebAPI/Plugins/Package.cs
Normal file
10
Torch.API/WebAPI/Plugins/Package.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using NuGet.DependencyResolver;
|
||||
using SemanticVersioning;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public record Package(string Name, Version Version, IReadOnlySet<PackageDependency> Dependencies)
|
||||
{
|
||||
internal GraphItem<RemoteResolveResult> Graph { get; init; }
|
||||
}
|
9
Torch.API/WebAPI/Plugins/PackageDependency.cs
Normal file
9
Torch.API/WebAPI/Plugins/PackageDependency.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using NuGet.DependencyResolver;
|
||||
using SemanticVersioning;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public record PackageDependency(string Name, Version Version, PackageDependencyKind Kind)
|
||||
{
|
||||
internal RemoteMatch Match { get; init; }
|
||||
}
|
8
Torch.API/WebAPI/Plugins/PackageDependencyKind.cs
Normal file
8
Torch.API/WebAPI/Plugins/PackageDependencyKind.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public enum PackageDependencyKind
|
||||
{
|
||||
None,
|
||||
Transitive,
|
||||
Direct
|
||||
}
|
91
Torch.API/WebAPI/Plugins/PackageReader.cs
Normal file
91
Torch.API/WebAPI/Plugins/PackageReader.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NuGet.Common;
|
||||
using NuGet.DependencyResolver;
|
||||
using NuGet.Frameworks;
|
||||
using NuGet.Packaging;
|
||||
using NuGet.Protocol.Core.Types;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public class PackageReader : IPackageReader
|
||||
{
|
||||
private readonly Package _package;
|
||||
private readonly SourceCacheContext _cacheContext;
|
||||
private readonly ILogger _logger;
|
||||
private readonly NuGetFramework _framework;
|
||||
private readonly IFrameworkCompatibilityProvider _compatibilityProvider;
|
||||
private readonly DirectoryInfo _packagesDirectory;
|
||||
|
||||
public PackageReader(Package package, SourceCacheContext cacheContext, ILogger logger, NuGetFramework framework,
|
||||
IFrameworkCompatibilityProvider compatibilityProvider, DirectoryInfo packagesDirectory)
|
||||
{
|
||||
_package = package;
|
||||
_cacheContext = cacheContext;
|
||||
_logger = logger;
|
||||
_framework = framework;
|
||||
_compatibilityProvider = compatibilityProvider;
|
||||
_packagesDirectory = packagesDirectory;
|
||||
}
|
||||
|
||||
public async Task<(IEnumerable<IPackageItem> Root, IReadOnlyDictionary<PackageDependency, IEnumerable<IPackageItem>>
|
||||
Dependencies)>
|
||||
GetItemsAsync()
|
||||
{
|
||||
async Task<IEnumerable<IPackageItem>> GetPackageItemsAsync(string id, NuGetVersion version,
|
||||
IRemoteDependencyProvider provider)
|
||||
{
|
||||
var downloader =
|
||||
await provider.GetPackageDownloaderAsync(new(id, version), _cacheContext, _logger,
|
||||
CancellationToken.None);
|
||||
|
||||
await downloader.CopyNupkgFileToAsync(Path.Combine(_packagesDirectory.FullName, $"{id}.{version}.nupkg"),
|
||||
CancellationToken.None);
|
||||
|
||||
var frameworks = await downloader.ContentReader.GetReferenceItemsAsync(CancellationToken.None);
|
||||
var items = frameworks.Where(b => _compatibilityProvider.IsCompatible(_framework, b.TargetFramework))
|
||||
.MaxBy(b => b.TargetFramework.Version)?.Items;
|
||||
|
||||
return items?.Select(b => new PackageItem(b, downloader)) ?? ImmutableArray<PackageItem>.Empty;
|
||||
}
|
||||
|
||||
var rootIdentity = _package.Graph.Key;
|
||||
return (await GetPackageItemsAsync(rootIdentity.Name, rootIdentity.Version, _package.Graph.Data.Match.Provider),
|
||||
await _package.Dependencies.ToAsyncEnumerable().SelectManyAwait(async b =>
|
||||
(await GetPackageItemsAsync(
|
||||
b.Match.Library.Name,
|
||||
b.Match.Library.Version,
|
||||
b.Match.Provider))
|
||||
.ToAsyncEnumerable()
|
||||
.Select(c => (b, c)))
|
||||
.GroupBy(b => b.b, b => b.c)
|
||||
.ToDictionaryAwaitAsync<IAsyncGrouping<PackageDependency, IPackageItem>, PackageDependency,
|
||||
IEnumerable<IPackageItem>>(b => ValueTask.FromResult(b.Key),
|
||||
async b => await b.ToArrayAsync()));
|
||||
}
|
||||
}
|
||||
|
||||
file class PackageItem : IPackageItem
|
||||
{
|
||||
private readonly string _path;
|
||||
private readonly IPackageDownloader _downloader;
|
||||
|
||||
public string FileName => Path.GetFileName(_path);
|
||||
|
||||
public PackageItem(string path, IPackageDownloader downloader)
|
||||
{
|
||||
_path = path;
|
||||
_downloader = downloader;
|
||||
}
|
||||
|
||||
public Task<Stream> OpenFileAsync()
|
||||
{
|
||||
return _downloader.CoreReader.GetStreamAsync(_path, CancellationToken.None);
|
||||
}
|
||||
}
|
104
Torch.API/WebAPI/Plugins/PackageResolver.cs
Normal file
104
Torch.API/WebAPI/Plugins/PackageResolver.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NuGet.Commands;
|
||||
using NuGet.Configuration;
|
||||
using NuGet.DependencyResolver;
|
||||
using NuGet.Frameworks;
|
||||
using NuGet.LibraryModel;
|
||||
using NuGet.Protocol;
|
||||
using NuGet.Protocol.Core.Types;
|
||||
using NuGet.Versioning;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public class PackageResolver : IPackageResolver
|
||||
{
|
||||
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly NuGetFramework _framework = NuGetFramework.Parse("net7.0-windows7.0");
|
||||
private readonly NLogLogger _logger = new(Log);
|
||||
private readonly SourceCacheContext _sourceCacheContext = new();
|
||||
private readonly RemoteWalkContext _remoteWalkContext;
|
||||
private readonly DirectoryInfo _packagesDirectory;
|
||||
private readonly IFrameworkCompatibilityProvider _compatibilityProvider = DefaultCompatibilityProvider.Instance;
|
||||
|
||||
public PackageResolver(IEnumerable<PackageSource> sources, DirectoryInfo packagesDirectory)
|
||||
{
|
||||
_packagesDirectory = packagesDirectory;
|
||||
IReadOnlySet<PackageSource> packageSources = sources.Where(b => b.Type is PackageSourceType.NuGet).ToImmutableHashSet();
|
||||
|
||||
var mapping = new PackageSourceMapping(packageSources.ToDictionary(b => b.Name, b => b.Patterns));
|
||||
_remoteWalkContext = new RemoteWalkContext(_sourceCacheContext, mapping, _logger);
|
||||
|
||||
foreach (var (name, url, _, _) in packageSources)
|
||||
{
|
||||
var packageSource = new NuGet.Configuration.PackageSource(url, name);
|
||||
var sourceRepository = new SourceRepository(packageSource, new INuGetResourceProvider[]
|
||||
{
|
||||
new DownloadResourceV3Provider(),
|
||||
new DependencyInfoResourceV3Provider(),
|
||||
new ServiceIndexResourceV3Provider(),
|
||||
new RemoteV3FindPackageByIdResourceProvider(),
|
||||
new V3FeedListResourceProvider(),
|
||||
new HttpSourceResourceProvider(),
|
||||
new RegistrationResourceV3Provider(),
|
||||
new HttpHandlerResourceV3Provider()
|
||||
}.Select(b => new Lazy<INuGetResourceProvider>(b)), FeedType.HttpV3);
|
||||
|
||||
_remoteWalkContext.RemoteLibraryProviders.Add(
|
||||
new SourceRepositoryDependencyProvider(sourceRepository, _logger, _sourceCacheContext, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Package>> ResolvePackagesAsync(
|
||||
IReadOnlyDictionary<string, string> packages)
|
||||
{
|
||||
Log.Info("Restoring {0} packages", packages.Count);
|
||||
|
||||
var graphs = await Task.WhenAll(packages.Select(b =>
|
||||
{
|
||||
var (key, versionRange) = b;
|
||||
var libraryRange = new LibraryRange(key, VersionRange.Parse(versionRange), LibraryDependencyTarget.All);
|
||||
return ResolverUtility.FindLibraryEntryAsync(libraryRange, _framework, "win-x64",
|
||||
_remoteWalkContext, CancellationToken.None);
|
||||
}));
|
||||
|
||||
return await graphs.ToAsyncEnumerable().SelectAwait(async graph =>
|
||||
{
|
||||
return new Package(graph.Key.Name, Version.Parse(graph.Key.Version.ToFullString()),
|
||||
await graph.Data.Dependencies
|
||||
.ToAsyncEnumerable()
|
||||
.SelectAwait(async b =>
|
||||
{
|
||||
var match = await ResolverUtility.FindLibraryByVersionAsync(
|
||||
b.LibraryRange, _framework, _remoteWalkContext.RemoteLibraryProviders,
|
||||
_sourceCacheContext, _logger, CancellationToken.None);
|
||||
|
||||
return new PackageDependency(
|
||||
b.Name, Version.Parse(match.Library.Version.ToFullString()),
|
||||
(PackageDependencyKind)b.ReferenceType)
|
||||
{
|
||||
Match = match
|
||||
};
|
||||
})
|
||||
.ToHashSetAsync())
|
||||
{
|
||||
Graph = graph
|
||||
};
|
||||
}).ToArrayAsync();
|
||||
}
|
||||
|
||||
public Task<IPackageReader> GetPackageAsync(Package package)
|
||||
{
|
||||
var reader = new PackageReader(package, _sourceCacheContext, _logger, _framework, _compatibilityProvider, _packagesDirectory);
|
||||
return Task.FromResult<IPackageReader>(reader);
|
||||
}
|
||||
}
|
8
Torch.API/WebAPI/Plugins/PackageSource.cs
Normal file
8
Torch.API/WebAPI/Plugins/PackageSource.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
#nullable enable
|
||||
public record PackageSource
|
||||
#nullable restore
|
||||
(string Name, string Url, IReadOnlyList<string> Patterns, PackageSourceType Type);
|
8
Torch.API/WebAPI/Plugins/PackageSourceType.cs
Normal file
8
Torch.API/WebAPI/Plugins/PackageSourceType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
#nullable enable
|
||||
namespace Torch.API.WebAPI.Plugins;
|
||||
|
||||
public enum PackageSourceType
|
||||
{
|
||||
NuGet,
|
||||
LegacyTorch
|
||||
}
|
127
Torch.API/WebAPI/Update/GithubQuery.cs
Normal file
127
Torch.API/WebAPI/Update/GithubQuery.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API.WebAPI.Update;
|
||||
|
||||
public class GithubQuery : IUpdateQuery
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public GithubQuery(string url)
|
||||
{
|
||||
if (url == null) throw new ArgumentNullException(nameof(url));
|
||||
|
||||
_client = new()
|
||||
{
|
||||
BaseAddress = new(url),
|
||||
DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher,
|
||||
DefaultRequestHeaders =
|
||||
{
|
||||
{"User-Agent", "TorchAPI"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_client?.Dispose();
|
||||
}
|
||||
|
||||
public async Task<UpdateRelease> GetLatestReleaseAsync(string repository, string branch = null)
|
||||
{
|
||||
var response = await _client.GetFromJsonAsync<Release>($"/repos/{repository}/releases/latest", new JsonSerializerOptions(JsonSerializerDefaults.Web)
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
|
||||
});
|
||||
|
||||
if (response is null)
|
||||
throw new($"Unable to get latest release for {repository}");
|
||||
|
||||
return new(Version.Parse(response.TagName), response.Assets.First(b => b.Name == "torch-server.zip").BrowserDownloadUrl);
|
||||
}
|
||||
|
||||
private record Asset(
|
||||
string Url,
|
||||
int Id,
|
||||
string NodeId,
|
||||
string Name,
|
||||
string Label,
|
||||
Uploader Uploader,
|
||||
string ContentType,
|
||||
string State,
|
||||
int Size,
|
||||
int DownloadCount,
|
||||
DateTime CreatedAt,
|
||||
DateTime UpdatedAt,
|
||||
string BrowserDownloadUrl
|
||||
);
|
||||
|
||||
private record Author(
|
||||
string Login,
|
||||
int Id,
|
||||
string NodeId,
|
||||
string AvatarUrl,
|
||||
string GravatarId,
|
||||
string Url,
|
||||
string HtmlUrl,
|
||||
string FollowersUrl,
|
||||
string FollowingUrl,
|
||||
string GistsUrl,
|
||||
string StarredUrl,
|
||||
string SubscriptionsUrl,
|
||||
string OrganizationsUrl,
|
||||
string ReposUrl,
|
||||
string EventsUrl,
|
||||
string ReceivedEventsUrl,
|
||||
string Type,
|
||||
bool SiteAdmin
|
||||
);
|
||||
|
||||
private record Release(
|
||||
string Url,
|
||||
string AssetsUrl,
|
||||
string UploadUrl,
|
||||
string HtmlUrl,
|
||||
int Id,
|
||||
Author Author,
|
||||
string NodeId,
|
||||
string TagName,
|
||||
string TargetCommitish,
|
||||
string Name,
|
||||
bool Draft,
|
||||
bool Prerelease,
|
||||
DateTime CreatedAt,
|
||||
DateTime PublishedAt,
|
||||
IReadOnlyList<Asset> Assets,
|
||||
string TarballUrl,
|
||||
string ZipballUrl,
|
||||
string Body
|
||||
);
|
||||
|
||||
private record Uploader(
|
||||
string Login,
|
||||
int Id,
|
||||
string NodeId,
|
||||
string AvatarUrl,
|
||||
string GravatarId,
|
||||
string Url,
|
||||
string HtmlUrl,
|
||||
string FollowersUrl,
|
||||
string FollowingUrl,
|
||||
string GistsUrl,
|
||||
string StarredUrl,
|
||||
string SubscriptionsUrl,
|
||||
string OrganizationsUrl,
|
||||
string ReposUrl,
|
||||
string EventsUrl,
|
||||
string ReceivedEventsUrl,
|
||||
string Type,
|
||||
bool SiteAdmin
|
||||
);
|
||||
}
|
9
Torch.API/WebAPI/Update/IUpdateQuery.cs
Normal file
9
Torch.API/WebAPI/Update/IUpdateQuery.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.API.WebAPI.Update;
|
||||
|
||||
public interface IUpdateQuery : IDisposable
|
||||
{
|
||||
Task<UpdateRelease> GetLatestReleaseAsync(string repository, string branch = null);
|
||||
}
|
65
Torch.API/WebAPI/Update/JenkinsQuery.cs
Normal file
65
Torch.API/WebAPI/Update/JenkinsQuery.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Torch.API.Utils;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API.WebAPI.Update
|
||||
{
|
||||
public class JenkinsQuery : IUpdateQuery
|
||||
{
|
||||
private const string ApiPath = "api/json";
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public JenkinsQuery(string url)
|
||||
{
|
||||
if (url == null) throw new ArgumentNullException(nameof(url));
|
||||
|
||||
_client = new()
|
||||
{
|
||||
BaseAddress = new(url)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<UpdateRelease> GetLatestReleaseAsync(string repository, string branch = null)
|
||||
{
|
||||
branch ??= "master";
|
||||
|
||||
var response = await _client.GetFromJsonAsync<BranchResponse>($"/job/{repository}/job/{branch}/{ApiPath}");
|
||||
|
||||
if (response is null)
|
||||
throw new($"Unable to get latest release for {repository}");
|
||||
|
||||
var job = await _client.GetFromJsonAsync<Job>(
|
||||
$"/job/{repository}/job/{branch}/{response.LastBuild.Number}/{ApiPath}");
|
||||
|
||||
if (job is null)
|
||||
throw new($"Unable to get latest release for job {repository}/{response.LastBuild.Number}");
|
||||
|
||||
return new(job.Version, job.Url + job.Artifacts.First(b => b.FileName == "torch-server.zip").RelativePath);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_client?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public record BranchResponse(string Name, string Url, Build LastBuild, Build LastStableBuild);
|
||||
|
||||
public record Build(int Number, string Url);
|
||||
|
||||
public record Job(int Number, bool Building, string Description, string Result, string Url,
|
||||
[property: JsonConverter(typeof(SemanticVersionConverter))] Version Version,
|
||||
IReadOnlyList<Artifact> Artifacts);
|
||||
|
||||
public record Artifact(
|
||||
string DisplayPath,
|
||||
string FileName,
|
||||
string RelativePath
|
||||
);
|
||||
}
|
5
Torch.API/WebAPI/Update/UpdateRelease.cs
Normal file
5
Torch.API/WebAPI/Update/UpdateRelease.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using SemanticVersioning;
|
||||
|
||||
namespace Torch.API.WebAPI.Update;
|
||||
|
||||
public record UpdateRelease(Version Version, string ArtifactUrl);
|
233
Torch.API/packages.lock.json
Normal file
233
Torch.API/packages.lock.json
Normal file
@@ -0,0 +1,233 @@
|
||||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net7.0-windows7.0": {
|
||||
"Microsoft.Extensions.Configuration.Binder": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "mBMoXLsr5s1y2zOHWmKsE9veDcx8h1x/c3rz4baEdQKTeDcmQAPNbB54Pi/lhFO3K431eEq6PFbMgLaa6PHFfA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0"
|
||||
}
|
||||
},
|
||||
"NLog": {
|
||||
"type": "Direct",
|
||||
"requested": "[5.2.7, )",
|
||||
"resolved": "5.2.7",
|
||||
"contentHash": "Ww/0b6V1NL8iqpFKtRKVQFFX03LoowNzYeNG6FpVzmhgCfLAkW0h/4lT3+V8mHfyvtHptNoV8Cz0YePLFRUaPA=="
|
||||
},
|
||||
"NuGet.Commands": {
|
||||
"type": "Direct",
|
||||
"requested": "[6.8.0, )",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "jTlbIYNXIiO25s/A2UMBHYhLmNm/lJP+/a/X4OJebejnSKmeKjXeCd9NYH+D9y21JMh3eS0khkCpPnLIgdHsCQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "6.0.0",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "6.0.0",
|
||||
"NuGet.Credentials": "6.8.0",
|
||||
"NuGet.ProjectModel": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.DependencyResolver.Core": {
|
||||
"type": "Direct",
|
||||
"requested": "[6.8.0, )",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "dTdE5VmQnWfZU2tM4glgsO1ZpFZoEqLKUtpDkr11dkVV4nQn5/MqK9Wmvp/SbU1t7AoSEf7yIMAew9SHxganYA==",
|
||||
"dependencies": {
|
||||
"NuGet.Configuration": "6.8.0",
|
||||
"NuGet.LibraryModel": "6.8.0",
|
||||
"NuGet.Protocol": "6.8.0"
|
||||
}
|
||||
},
|
||||
"SemanticVersioning": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.0.2, )",
|
||||
"resolved": "2.0.2",
|
||||
"contentHash": "4EQgYdNZ92SyaO7YFk6olVnebF5V+jrHyMUjvPq89tLeMo8NSfgDF+6Zwq/lgh9j/0yfQp9Lkm0ZA0rUATCZFA=="
|
||||
},
|
||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.203.505.1, )",
|
||||
"resolved": "1.203.505.1",
|
||||
"contentHash": "YokcOxKdIvtJ2fYdkF48/wvbdaDlNl+bbUd11vkdPRdHaprRj5b2F1wUk7faL0J0UIX87lyhgC/HsNn9rHVbJw==",
|
||||
"dependencies": {
|
||||
"protobuf-net": "1.0.0"
|
||||
}
|
||||
},
|
||||
"System.Linq.Async": {
|
||||
"type": "Direct",
|
||||
"requested": "[6.0.1, )",
|
||||
"resolved": "6.0.1",
|
||||
"contentHash": "0YhHcaroWpQ9UCot3Pizah7ryAzQhNvobLMSxeDIGmnXfkQn8u5owvpOH0K6EVB+z9L7u6Cc4W17Br/+jyttEQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Bcl.AsyncInterfaces": "6.0.0"
|
||||
}
|
||||
},
|
||||
"System.Text.Json": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==",
|
||||
"dependencies": {
|
||||
"System.Text.Encodings.Web": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Bcl.AsyncInterfaces": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "3lE/iLSutpgX1CC0NOW70FJoGARRHbyKmG7dc0klnUZ9Dd9hS6N/POPWhKhMLCEuNN5nXEY5agmlFtH562vqhQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "0pd4/fho0gC12rQswaGQxbU34jOS1TPS8lZPpkFCH68ppQjHNHYle9iRuHeev1LhrJ94YPvzcRd8UmIuFk23Qw==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "6.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileSystemGlobbing": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "ip8jnL1aPiaPeKINCqaTEbvBFDmVx9dXQEBZ2HOBRXPD1eabGNqP/bKlsIcp7U2lGxiXd5xIhoFcmY8nM4Hdiw=="
|
||||
},
|
||||
"Microsoft.Extensions.Primitives": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g=="
|
||||
},
|
||||
"Newtonsoft.Json": {
|
||||
"type": "Transitive",
|
||||
"resolved": "13.0.3",
|
||||
"contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ=="
|
||||
},
|
||||
"NuGet.Common": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "voNZyM5L5s0CCDPU//vXKQke0M8y6kGvG+0Ll6gc/xV7Jh1C3/5OhHRzvekxBS6a9DO/lsFhTZtyCkL6n9lHEw==",
|
||||
"dependencies": {
|
||||
"NuGet.Frameworks": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Configuration": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "FFEoY1L9G+C74HfSYt6epHTIuS5xJ8D+d9LZ5nnqhujMoBlQgHphaCTfRlul+e/bNIkAp1fDObzsGlPmu3CKAg==",
|
||||
"dependencies": {
|
||||
"NuGet.Common": "6.8.0",
|
||||
"System.Security.Cryptography.ProtectedData": "4.4.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Credentials": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "0Cp5iSgmweBKjDbywqNVVlVFCtjmt4z7ol5ED3hjMGNQp1HgthOZ+PSVD2xa+5rf4/in2Nt2/4W938KqreigJg==",
|
||||
"dependencies": {
|
||||
"NuGet.Protocol": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Frameworks": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "cN9NyahKgYYScioH4CKn+TYj1eSODxd0RECFnQt6ZmzT6z7PfXlbYpVzbiPsxNgY23iNDMOVkSmOqNZyYxNlQA=="
|
||||
},
|
||||
"NuGet.LibraryModel": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "qdNqSa1E/VgpY95XJuLtJrSA74XpWCn5iGf/9r7FMa5smSZt7nClHcMrxOalfzilMKl4prUkE7AVw2AvKZ39Mg==",
|
||||
"dependencies": {
|
||||
"NuGet.Common": "6.8.0",
|
||||
"NuGet.Versioning": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Packaging": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "lyDnMCAWtoHNsNKGexIl6yHtyxuvn2j3rpKMrYYf86KwTV+JVY9eFIixNdwEPjBXBzWHQGpDKj9Im8v02t9AQQ==",
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "13.0.3",
|
||||
"NuGet.Configuration": "6.8.0",
|
||||
"NuGet.Versioning": "6.8.0",
|
||||
"System.Security.Cryptography.Pkcs": "6.0.4"
|
||||
}
|
||||
},
|
||||
"NuGet.ProjectModel": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "4lXoQxLn2fAN+Yu9SHLRcjPCXNVj039FMXE9vUm14ZjCk889dGCEbUWtF3PUqqRpMGnp6IckDd8zubvXI4H1cw==",
|
||||
"dependencies": {
|
||||
"NuGet.DependencyResolver.Core": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Protocol": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "Nfvij7QlEevDbuRCXkhCrHk1oJN+mYkmeVzNvS9hxNTmwdtHqB+zhUIMFBlbye3MUicgc4bbtLAwoF+EKjUvcg==",
|
||||
"dependencies": {
|
||||
"NuGet.Packaging": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Versioning": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "WBu15cdv1lqKkPKXDQOEmEzwKemwrczKYlc2jtuZgRYiZ8TG8F4QzPYiE0Q9eVIpMSk8Aky7mUephf19HjBPOw=="
|
||||
},
|
||||
"protobuf-net": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0",
|
||||
"contentHash": "kTGOK0E87473sOImOjgZOnz3kTC2aMLffoRWQLYNuBLJnwNNmjanF9IkevZ9Q7yYLeABQfcF3BpeepuMntMVNw=="
|
||||
},
|
||||
"System.Formats.Asn1": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "T6fD00dQ3NTbPDy31m4eQUwKW84s03z0N2C8HpOklyeaDgaJPa/TexP4/SkORMSOwc7WhKifnA6Ya33AkzmafA=="
|
||||
},
|
||||
"System.Security.Cryptography.Pkcs": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.4",
|
||||
"contentHash": "LGbXi1oUJ9QgCNGXRO9ndzBL/GZgANcsURpMhNR8uO+rca47SZmciS3RSQUvlQRwK3QHZSHNOXzoMUASKA+Anw==",
|
||||
"dependencies": {
|
||||
"System.Formats.Asn1": "6.0.0"
|
||||
}
|
||||
},
|
||||
"System.Security.Cryptography.ProtectedData": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.4.0",
|
||||
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
|
||||
},
|
||||
"System.Text.Encodings.Web": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
|
||||
}
|
||||
},
|
||||
"net7.0-windows7.0/win-x64": {
|
||||
"System.Security.Cryptography.Pkcs": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.4",
|
||||
"contentHash": "LGbXi1oUJ9QgCNGXRO9ndzBL/GZgANcsURpMhNR8uO+rca47SZmciS3RSQUvlQRwK3QHZSHNOXzoMUASKA+Anw==",
|
||||
"dependencies": {
|
||||
"System.Formats.Asn1": "6.0.0"
|
||||
}
|
||||
},
|
||||
"System.Security.Cryptography.ProtectedData": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.4.0",
|
||||
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
|
||||
},
|
||||
"System.Text.Encodings.Web": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("Torch Client Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Torch")]
|
||||
[assembly: AssemblyCopyright("Copyright © Torch API 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
#if DEBUG
|
||||
[assembly: AssemblyConfiguration("Debug")]
|
||||
#else
|
||||
[assembly: AssemblyConfiguration("Release")]
|
||||
#endif
|
@@ -1,51 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<NoWarn>1591,0649</NoWarn>
|
||||
<AssemblyTitle>Torch Client Tests</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<OutputPath>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\Torch.Client.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.TextTransform" Version="1.0.0" />
|
||||
<PackageReference Include="NLog" Version="4.4.12" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.1" />
|
||||
<PackageReference Include="xunit.assert" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.core" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.2.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties\AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch.Client\Torch.Client.csproj" />
|
||||
<ProjectReference Include="..\Torch.Tests\Torch.Tests.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="obj\x64\Debug\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
<Compile Remove="obj\x64\Release\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Torch.Client;
|
||||
using Torch.Tests;
|
||||
using Torch.Utils;
|
||||
using Xunit;
|
||||
|
||||
namespace Torch.Client.Tests
|
||||
{
|
||||
public class TorchClientReflectionTest
|
||||
{
|
||||
static TorchClientReflectionTest()
|
||||
{
|
||||
TestUtils.Init();
|
||||
}
|
||||
|
||||
private static ReflectionTestManager _manager;
|
||||
|
||||
private static ReflectionTestManager Manager()
|
||||
{
|
||||
if (_manager != null)
|
||||
return _manager;
|
||||
|
||||
return _manager = new ReflectionTestManager().Init(typeof(TorchClient).Assembly);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Getters => Manager().Getters;
|
||||
|
||||
public static IEnumerable<object[]> Setters => Manager().Setters;
|
||||
|
||||
public static IEnumerable<object[]> Invokers => Manager().Invokers;
|
||||
|
||||
public static IEnumerable<object[]> MemberInfo => Manager().MemberInfo;
|
||||
|
||||
public static IEnumerable<object[]> Events => Manager().Events;
|
||||
|
||||
#region Binding
|
||||
[Theory]
|
||||
[MemberData(nameof(Getters))]
|
||||
public void TestBindingGetter(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
if (field.Field == null)
|
||||
return;
|
||||
Assert.True(ReflectedManager.Process(field.Field));
|
||||
if (field.Field.IsStatic)
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Setters))]
|
||||
public void TestBindingSetter(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
if (field.Field == null)
|
||||
return;
|
||||
Assert.True(ReflectedManager.Process(field.Field));
|
||||
if (field.Field.IsStatic)
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Invokers))]
|
||||
public void TestBindingInvoker(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
if (field.Field == null)
|
||||
return;
|
||||
Assert.True(ReflectedManager.Process(field.Field));
|
||||
if (field.Field.IsStatic)
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(MemberInfo))]
|
||||
public void TestBindingMemberInfo(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
if (field.Field == null)
|
||||
return;
|
||||
Assert.True(ReflectedManager.Process(field.Field));
|
||||
if (field.Field.IsStatic)
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Events))]
|
||||
public void TestBindingEvents(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
if (field.Field == null)
|
||||
return;
|
||||
Assert.True(ReflectedManager.Process(field.Field));
|
||||
if (field.Field.IsStatic)
|
||||
((Func<ReflectedEventReplacer>)field.Field.GetValue(null)).Invoke();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers;
|
||||
|
||||
namespace Torch.Client.Manager
|
||||
{
|
||||
public class MultiplayerManagerClient : MultiplayerManagerBase, IMultiplayerManagerClient
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public MultiplayerManagerClient(ITorchBase torch) : base(torch) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Attach()
|
||||
{
|
||||
base.Attach();
|
||||
MyMultiplayer.Static.ClientJoined += RaiseClientJoined;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Detach()
|
||||
{
|
||||
MyMultiplayer.Static.ClientJoined -= RaiseClientJoined;
|
||||
base.Detach();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers;
|
||||
using VRage.Game.ModAPI;
|
||||
|
||||
namespace Torch.Client.Manager
|
||||
{
|
||||
public class MultiplayerManagerLobby : MultiplayerManagerBase, IMultiplayerManagerServer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<ulong> BannedPlayers => new List<ulong>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public MultiplayerManagerLobby(ITorchBase torch) : base(torch) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void KickPlayer(ulong steamId) => Torch.Invoke(() => MyMultiplayer.Static.KickClient(steamId));
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BanPlayer(ulong steamId, bool banned = true) => Torch.Invoke(() => MyMultiplayer.Static.BanClient(steamId, banned));
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PromoteUser(ulong steamId)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
var p = MySession.Static.GetUserPromoteLevel(steamId);
|
||||
if (p < MyPromoteLevel.Admin) //cannot promote to owner by design
|
||||
MySession.Static.SetUserPromoteLevel(steamId, p + 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void DemoteUser(ulong steamId)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
var p = MySession.Static.GetUserPromoteLevel(steamId);
|
||||
if (p > MyPromoteLevel.None && p < MyPromoteLevel.Owner) //owner cannot be demoted by design
|
||||
MySession.Static.SetUserPromoteLevel(steamId, p - 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public MyPromoteLevel GetUserPromoteLevel(ulong steamId)
|
||||
{
|
||||
return MySession.Static.GetUserPromoteLevel(steamId);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsBanned(ulong steamId) => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong> PlayerKicked
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong, bool> PlayerBanned
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong, MyPromoteLevel> PlayerPromoted
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Attach()
|
||||
{
|
||||
base.Attach();
|
||||
MyMultiplayer.Static.ClientJoined += RaiseClientJoined;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Detach()
|
||||
{
|
||||
MyMultiplayer.Static.ClientJoined -= RaiseClientJoined;
|
||||
base.Detach();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,194 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using NLog;
|
||||
using Torch.Utils;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Torch.Client
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public const string SpaceEngineersBinaries = "Bin64";
|
||||
private static string _spaceEngInstallAlias = null;
|
||||
|
||||
public static string SpaceEngineersInstallAlias
|
||||
{
|
||||
get
|
||||
{
|
||||
// ReSharper disable once ConvertIfStatementToNullCoalescingExpression
|
||||
if (_spaceEngInstallAlias == null)
|
||||
{
|
||||
// ReSharper disable once AssignNullToNotNullAttribute
|
||||
_spaceEngInstallAlias = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location),
|
||||
"SpaceEngineersAlias");
|
||||
}
|
||||
return _spaceEngInstallAlias;
|
||||
}
|
||||
}
|
||||
|
||||
private const string _steamSpaceEngineersDirectory = @"steamapps\common\SpaceEngineers\";
|
||||
private const string _spaceEngineersVerifyFile = SpaceEngineersBinaries + @"\SpaceEngineers.exe";
|
||||
|
||||
public const string ConfigName = "Torch.cfg";
|
||||
|
||||
private static Logger _log = LogManager.GetLogger("Torch");
|
||||
|
||||
#if DEBUG
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern void AllocConsole();
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern void FreeConsole();
|
||||
#endif
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
try
|
||||
{
|
||||
AllocConsole();
|
||||
#endif
|
||||
if (!TorchLauncher.IsTorchWrapped())
|
||||
{
|
||||
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
|
||||
}
|
||||
finally
|
||||
{
|
||||
FreeConsole();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void SetupSpaceEngInstallAlias()
|
||||
{
|
||||
string spaceEngineersDirectory = null;
|
||||
|
||||
// TODO look at Steam/config/Config.VDF? Has alternate directories.
|
||||
var steamDir =
|
||||
Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Valve\\Steam", "SteamPath",
|
||||
null) as string;
|
||||
if (steamDir != null)
|
||||
{
|
||||
spaceEngineersDirectory = Path.Combine(steamDir, _steamSpaceEngineersDirectory);
|
||||
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
|
||||
if (File.Exists(Path.Combine(spaceEngineersDirectory, _spaceEngineersVerifyFile)))
|
||||
_log.Debug("Found Space Engineers in {0}", spaceEngineersDirectory);
|
||||
else
|
||||
{
|
||||
_log.Debug("Couldn't find Space Engineers in {0}", spaceEngineersDirectory);
|
||||
spaceEngineersDirectory = null;
|
||||
}
|
||||
}
|
||||
if (spaceEngineersDirectory == null)
|
||||
{
|
||||
var dialog = new System.Windows.Forms.FolderBrowserDialog
|
||||
{
|
||||
Description = "Please select the SpaceEngineers installation folder"
|
||||
};
|
||||
do
|
||||
{
|
||||
if (dialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
var ex = new FileNotFoundException(
|
||||
"Unable to find the Space Engineers install directory, aborting");
|
||||
_log.Fatal(ex);
|
||||
LogManager.Flush();
|
||||
throw ex;
|
||||
}
|
||||
spaceEngineersDirectory = dialog.SelectedPath;
|
||||
if (File.Exists(Path.Combine(spaceEngineersDirectory, _spaceEngineersVerifyFile)))
|
||||
break;
|
||||
if (MessageBox.Show(
|
||||
$"Unable to find {0} in {1}. Are you sure it's the Space Engineers install directory?",
|
||||
"Invalid Space Engineers Directory", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
break;
|
||||
} while (true); // Repeat until they confirm.
|
||||
}
|
||||
if (!JunctionLink(SpaceEngineersInstallAlias, spaceEngineersDirectory))
|
||||
{
|
||||
var ex = new IOException(
|
||||
$"Failed to create junction link {SpaceEngineersInstallAlias} => {spaceEngineersDirectory}. Aborting.");
|
||||
_log.Fatal(ex);
|
||||
LogManager.Flush();
|
||||
throw ex;
|
||||
}
|
||||
string junctionVerify = Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile);
|
||||
if (!File.Exists(junctionVerify))
|
||||
{
|
||||
var ex = new FileNotFoundException(
|
||||
$"Junction link is not working. File {junctionVerify} does not exist");
|
||||
_log.Fatal(ex);
|
||||
LogManager.Flush();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool JunctionLink(string linkName, string targetDir)
|
||||
{
|
||||
var junctionLinkProc = new ProcessStartInfo("cmd.exe", $"/c mklink /J \"{linkName}\" \"{targetDir}\"")
|
||||
{
|
||||
WorkingDirectory = Directory.GetCurrentDirectory(),
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
StandardOutputEncoding = Encoding.ASCII
|
||||
};
|
||||
Process cmd = Process.Start(junctionLinkProc);
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
while (!cmd.HasExited)
|
||||
{
|
||||
string line = cmd.StandardOutput.ReadLine();
|
||||
if (!string.IsNullOrWhiteSpace(line))
|
||||
_log.Info(line);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
if (cmd.ExitCode != 0)
|
||||
_log.Error("Unable to create junction link {0} => {1}", linkName, targetDir);
|
||||
return cmd.ExitCode == 0;
|
||||
}
|
||||
|
||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
var ex = (Exception) e.ExceptionObject;
|
||||
_log.Error(ex);
|
||||
LogManager.Flush();
|
||||
MessageBox.Show(ex.StackTrace, ex.Message);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static void RunClient()
|
||||
{
|
||||
var client = new TorchClient();
|
||||
|
||||
try
|
||||
{
|
||||
client.Init();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Fatal("Torch encountered an error trying to initialize the game.");
|
||||
_log.Fatal(e);
|
||||
return;
|
||||
}
|
||||
|
||||
client.Start();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("Torch Client")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Torch")]
|
||||
[assembly: AssemblyCopyright("Copyright © Torch API 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
#if DEBUG
|
||||
[assembly: AssemblyConfiguration("Debug")]
|
||||
#else
|
||||
[assembly: AssemblyConfiguration("Release")]
|
||||
#endif
|
63
Torch.Client/Properties/Resources.Designer.cs
generated
63
Torch.Client/Properties/Resources.Designer.cs
generated
@@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Torch.Client.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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.Client.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
26
Torch.Client/Properties/Settings.Designer.cs
generated
26
Torch.Client/Properties/Settings.Designer.cs
generated
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Torch.Client.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
@@ -1,122 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<AssemblyTitle>Torch Client</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<OutputPath>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseWPF>true</UseWPF>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DocumentationFile>$(SolutionDir)\bin\$(Platform)\$(Configuration)\Torch.Client.xml</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>torchicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.TextTransform" Version="1.0.0" />
|
||||
<PackageReference Include="NLog" Version="4.4.12" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game">
|
||||
<HintPath>..\GameBinaries\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics, Version=0.1.6108.20417, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game">
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="VRage">
|
||||
<HintPath>..\GameBinaries\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game">
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game.XmlSerializers">
|
||||
<HintPath>..\GameBinaries\VRage.Game.XmlSerializers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library">
|
||||
<HintPath>..\GameBinaries\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render">
|
||||
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render11">
|
||||
<HintPath>..\GameBinaries\VRage.Render11.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Steam">
|
||||
<HintPath>..\GameBinaries\VRage.Steam.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties\AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="torchicon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="obj\x64\Debug\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
<Compile Remove="obj\x64\Release\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Engine.Platform;
|
||||
using Sandbox.Game;
|
||||
using SpaceEngineers.Game;
|
||||
using VRage.Steam;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.Session;
|
||||
using Torch.Client.Manager;
|
||||
using Torch.Client.UI;
|
||||
using Torch.Session;
|
||||
using VRage;
|
||||
using VRage.FileSystem;
|
||||
using VRage.GameServices;
|
||||
using VRageRender;
|
||||
using VRageRender.ExternalApp;
|
||||
|
||||
namespace Torch.Client
|
||||
{
|
||||
public class TorchClient : TorchBase, ITorchClient
|
||||
{
|
||||
protected override uint SteamAppId => 244850;
|
||||
protected override string SteamAppName => "SpaceEngineers";
|
||||
|
||||
public TorchClient()
|
||||
{
|
||||
Config = new TorchClientConfig();
|
||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerLobby
|
||||
? new MultiplayerManagerLobby(this)
|
||||
: null);
|
||||
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerClientBase
|
||||
? new MultiplayerManagerClient(this)
|
||||
: null);
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
|
||||
MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
|
||||
Log.Info("Initializing Torch Client");
|
||||
Config.InstancePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
SteamAppName);
|
||||
base.Init();
|
||||
OverrideMenus();
|
||||
SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}");
|
||||
}
|
||||
|
||||
private void OverrideMenus()
|
||||
{
|
||||
var credits = new MyCreditsDepartment("Torch Developed By")
|
||||
{
|
||||
Persons = new List<MyCreditsPerson>
|
||||
{
|
||||
new MyCreditsPerson("THE TORCH TEAM"),
|
||||
new MyCreditsPerson("http://github.com/TorchSE"),
|
||||
}
|
||||
};
|
||||
MyPerGameSettings.Credits.Departments.Insert(0, credits);
|
||||
|
||||
MyPerGameSettings.GUI.MainMenu = typeof(TorchMainMenuScreen);
|
||||
}
|
||||
|
||||
private void SetRenderWindowTitle(string title)
|
||||
{
|
||||
MyRenderThread renderThread = MySandboxGame.Static?.GameRenderComponent?.RenderThread;
|
||||
if (renderThread == null)
|
||||
return;
|
||||
FieldInfo renderWindowField = typeof(MyRenderThread).GetField("m_renderWindow",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (renderWindowField == null)
|
||||
return;
|
||||
var window =
|
||||
renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as
|
||||
System.Windows.Forms.Form;
|
||||
if (window != null)
|
||||
renderThread.Invoke(() => { window.Text = title; });
|
||||
}
|
||||
|
||||
public override void Restart()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.Client
|
||||
{
|
||||
public class TorchClientConfig : ITorchConfig
|
||||
{
|
||||
// How do we want to handle client side config? It's radically different than the server.
|
||||
public bool GetPluginUpdates { get; set; } = false;
|
||||
public bool GetTorchUpdates { get; set; } = false;
|
||||
public string InstanceName { get; set; } = "TorchClient";
|
||||
public string InstancePath { get; set; }
|
||||
public bool NoUpdate { get; set; } = true;
|
||||
public List<string> Plugins { get; set; }
|
||||
public bool ShouldUpdatePlugins { get; } = false;
|
||||
public bool ShouldUpdateTorch { get; } = false;
|
||||
public int TickTimeout { get; set; }
|
||||
public bool Autostart { get; set; } = false;
|
||||
public bool ForceUpdate { get; set; } = false;
|
||||
public bool NoGui { get; set; } = false;
|
||||
public bool RestartOnCrash { get; set; } = false;
|
||||
public string WaitForPID { get; set; } = null;
|
||||
public string ChatName { get; set; }
|
||||
public string ChatColor { get; set; }
|
||||
|
||||
public bool Save(string path = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Sandbox.Graphics;
|
||||
using Sandbox.Graphics.GUI;
|
||||
using Sandbox.Gui;
|
||||
using VRage.Utils;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.Client
|
||||
{
|
||||
public class TorchConsoleScreen : MyGuiScreenBase
|
||||
{
|
||||
private MyGuiControlTextbox _textBox;
|
||||
|
||||
public override string GetFriendlyName()
|
||||
{
|
||||
return "Torch Console";
|
||||
}
|
||||
|
||||
public TorchConsoleScreen() : base(isTopMostScreen: true)
|
||||
{
|
||||
BackgroundColor = new Vector4(0, 0, 0, 0.5f);
|
||||
Size = new Vector2(0.5f);
|
||||
RecreateControls(true);
|
||||
}
|
||||
|
||||
public sealed override void RecreateControls(bool constructor)
|
||||
{
|
||||
Elements.Clear();
|
||||
Elements.Add(new MyGuiControlLabel
|
||||
{
|
||||
Text = "Torch Console",
|
||||
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
|
||||
Position = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)
|
||||
});
|
||||
|
||||
Controls.Clear();
|
||||
_textBox = new MyGuiControlTextbox
|
||||
{
|
||||
BorderEnabled = false,
|
||||
Enabled = true,
|
||||
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
|
||||
Position = new Vector2(-0.5f)
|
||||
};
|
||||
Controls.Add(_textBox);
|
||||
|
||||
var pistonBtn = new MyGuiControlImageButton
|
||||
{
|
||||
Name = "TorchButton",
|
||||
Text = "Torch",
|
||||
HighlightType = MyGuiControlHighlightType.WHEN_CURSOR_OVER,
|
||||
Visible = true,
|
||||
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
|
||||
};
|
||||
|
||||
Controls.Add(pistonBtn);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Graphics;
|
||||
using Sandbox.Graphics.GUI;
|
||||
using VRage.Utils;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.Client
|
||||
{
|
||||
public class TorchSettingsScreen : MyGuiScreenBase
|
||||
{
|
||||
public override string GetFriendlyName() => "Torch Settings";
|
||||
|
||||
public TorchSettingsScreen() : base(new Vector2(0.5f), null, Vector2.One, true)
|
||||
{
|
||||
RecreateControls(true);
|
||||
}
|
||||
|
||||
public sealed override void RecreateControls(bool constructor)
|
||||
{
|
||||
base.RecreateControls(constructor);
|
||||
AddCaption(MyStringId.GetOrCompute("Torch Settings"), null, new Vector2(0, 0), 1.2f);
|
||||
var pluginList = new MyGuiControlListbox
|
||||
{
|
||||
VisibleRowsCount = 10,
|
||||
};
|
||||
|
||||
foreach (var plugin in TorchBase.Instance.Plugins)
|
||||
{
|
||||
pluginList.Items.Add(new MyGuiControlListbox.Item(new StringBuilder(plugin.Name)));
|
||||
}
|
||||
Controls.Add(pluginList);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
#pragma warning disable 618
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Sandbox.Game;
|
||||
using Sandbox.Game.Gui;
|
||||
using Sandbox.Graphics;
|
||||
using Sandbox.Graphics.GUI;
|
||||
using Sandbox.Gui;
|
||||
using SpaceEngineers.Game.GUI;
|
||||
using Torch.Utils;
|
||||
using VRage.Game;
|
||||
using VRage.Utils;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.Client.UI
|
||||
{
|
||||
public class TorchMainMenuScreen : MyGuiScreenMainMenu
|
||||
{
|
||||
#pragma warning disable 169
|
||||
[ReflectedGetter(Name = "m_elementGroup")]
|
||||
private static Func<MyGuiScreenMainMenu, MyGuiControlElementGroup> _elementsGroup;
|
||||
#pragma warning restore 169
|
||||
|
||||
public TorchMainMenuScreen() : this(false)
|
||||
{
|
||||
}
|
||||
|
||||
public TorchMainMenuScreen(bool pauseGame)
|
||||
: base(pauseGame)
|
||||
{
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override void RecreateControls(bool constructor)
|
||||
{
|
||||
base.RecreateControls(constructor);
|
||||
|
||||
Vector2 minSizeGui = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
|
||||
Vector2 value = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, 54, 54) + new Vector2(minSizeGui.X / 2f, 0f) + new Vector2(15f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
|
||||
|
||||
MyGuiControlButton myGuiControlButton = MakeButton(value - 9 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
|
||||
MyStringId.GetOrCompute("Torch"), TorchButtonClicked, MyCommonTexts.ToolTipExitToWindows);
|
||||
Controls.Add(myGuiControlButton);
|
||||
_elementsGroup.Invoke(this).Add(myGuiControlButton);
|
||||
}
|
||||
|
||||
private void TorchButtonClicked(MyGuiControlButton obj)
|
||||
{
|
||||
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen<TorchNavScreen>());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
using Sandbox;
|
||||
using Sandbox.Game.Gui;
|
||||
using Sandbox.Graphics.GUI;
|
||||
using VRage;
|
||||
using VRage.Game;
|
||||
using VRage.Utils;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.Client.UI
|
||||
{
|
||||
public class TorchNavScreen : MyGuiScreenBase
|
||||
{
|
||||
private MyGuiControlElementGroup _elementGroup;
|
||||
|
||||
public TorchNavScreen() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.35875f, 0.558333337f))
|
||||
{
|
||||
EnabledBackgroundFade = true;
|
||||
RecreateControls(true);
|
||||
}
|
||||
|
||||
public override void RecreateControls(bool constructor)
|
||||
{
|
||||
base.RecreateControls(constructor);
|
||||
_elementGroup = new MyGuiControlElementGroup();
|
||||
_elementGroup.HighlightChanged += ElementGroupHighlightChanged;
|
||||
AddCaption(MyCommonTexts.ScreenCaptionOptions, null, null);
|
||||
var value = new Vector2(0f, -m_size.Value.Y / 2f + 0.146f);
|
||||
var num = 0;
|
||||
var myGuiControlButton = new MyGuiControlButton(value + num++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenOptionsButtonGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, delegate(MyGuiControlButton sender)
|
||||
{
|
||||
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen<TorchSettingsScreen>());
|
||||
}, GuiSounds.MouseClick, 1f, null);
|
||||
Controls.Add(myGuiControlButton);
|
||||
_elementGroup.Add(myGuiControlButton);
|
||||
CloseButtonEnabled = true;
|
||||
}
|
||||
|
||||
private void ElementGroupHighlightChanged(MyGuiControlElementGroup obj)
|
||||
{
|
||||
foreach (MyGuiControlBase current in _elementGroup)
|
||||
if (current.HasFocus && obj.SelectedElement != current)
|
||||
FocusedControl = obj.SelectedElement;
|
||||
}
|
||||
|
||||
public override string GetFriendlyName() => "Torch";
|
||||
|
||||
public void OnBackClick(MyGuiControlButton sender) => CloseScreen();
|
||||
}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Graphics.GUI;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.Client.UI
|
||||
{
|
||||
public class TorchSettingsScreen : MyGuiScreenBase
|
||||
{
|
||||
public TorchSettingsScreen() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR,
|
||||
new Vector2(0.35875f, 0.558333337f))
|
||||
{
|
||||
EnabledBackgroundFade = true;
|
||||
RecreateControls(true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string GetFriendlyName() => "Torch Settings";
|
||||
|
||||
public void OnBackClick(MyGuiControlButton sender) => CloseScreen();
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
/// <summary>
|
||||
/// shim to store incoming message data
|
||||
/// </summary>
|
||||
internal class IncomingMessage : MessageBase
|
||||
{
|
||||
public IncomingMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public override void ProcessServer()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,11 +32,6 @@ namespace Torch.Mod.Messages
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
if (TorchModCore.Debug)
|
||||
{
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Joining server {Address} with delay {Delay}");
|
||||
}
|
||||
|
||||
if (Delay <= 0)
|
||||
{
|
||||
MyAPIGateway.Multiplayer.JoinServer(Address);
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProtoBuf;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
@@ -17,36 +12,9 @@ namespace Torch.Mod.Messages
|
||||
[ProtoContract]
|
||||
public abstract class MessageBase
|
||||
{
|
||||
[ProtoMember(101)]
|
||||
public ulong SenderId;
|
||||
|
||||
public abstract void ProcessClient();
|
||||
public abstract void ProcessServer();
|
||||
|
||||
//members below not serialized, they're just metadata about the intended target(s) of this message
|
||||
internal MessageTarget TargetType;
|
||||
internal ulong Target;
|
||||
internal ulong[] Ignore;
|
||||
internal byte[] CompressedData;
|
||||
}
|
||||
|
||||
public enum MessageTarget
|
||||
{
|
||||
/// <summary>
|
||||
/// Send to Target
|
||||
/// </summary>
|
||||
Single,
|
||||
/// <summary>
|
||||
/// Send to Server
|
||||
/// </summary>
|
||||
Server,
|
||||
/// <summary>
|
||||
/// Send to all Clients (only valid from server)
|
||||
/// </summary>
|
||||
AllClients,
|
||||
/// <summary>
|
||||
/// Send to all except those steam ID listed in Ignore
|
||||
/// </summary>
|
||||
AllExcept,
|
||||
}
|
||||
}
|
||||
|
@@ -1,161 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.ModAPI;
|
||||
using Torch.Mod.Messages;
|
||||
using VRage;
|
||||
using VRage.Collections;
|
||||
using VRage.Game.Components;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.Network;
|
||||
using VRage.Utils;
|
||||
using Task = ParallelTasks.Task;
|
||||
#if TORCH
|
||||
using Torch.Utils;
|
||||
using VRage.Library.Collections;
|
||||
using System.Reflection;
|
||||
#endif
|
||||
|
||||
namespace Torch.Mod
|
||||
{
|
||||
public static class ModCommunication
|
||||
[MySessionComponentDescriptor(MyUpdateOrder.AfterSimulation)]
|
||||
public class ModCommunication : MySessionComponentBase
|
||||
{
|
||||
public const ushort NET_ID = 4352;
|
||||
private static bool _closing = false;
|
||||
private static BlockingCollection<MessageBase> _processing;
|
||||
private static MyConcurrentPool<IncomingMessage> _messagePool;
|
||||
private static List<IMyPlayer> _playerCache;
|
||||
public const ulong MOD_ID = 2915950488;
|
||||
private const ushort CHANNEL = 7654;
|
||||
|
||||
public static void Register()
|
||||
public override void BeforeStart()
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: Registering mod communication.");
|
||||
_processing = new BlockingCollection<MessageBase>(new ConcurrentQueue<MessageBase>());
|
||||
_playerCache = new List<IMyPlayer>();
|
||||
_messagePool = new MyConcurrentPool<IncomingMessage>(8);
|
||||
|
||||
MyAPIGateway.Multiplayer.RegisterMessageHandler(NET_ID, MessageHandler);
|
||||
//background thread to handle de/compression and processing
|
||||
_closing = false;
|
||||
MyAPIGateway.Parallel.StartBackground(DoProcessing);
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: Mod communication registered successfully.");
|
||||
base.BeforeStart();
|
||||
MyAPIGateway.Multiplayer.RegisterSecureMessageHandler(CHANNEL, MessageHandler);
|
||||
}
|
||||
|
||||
public static void Unregister()
|
||||
private void MessageHandler(ushort channel, byte[] data, ulong sender, bool fromServer)
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: Unregistering mod communication.");
|
||||
MyAPIGateway.Multiplayer?.UnregisterMessageHandler(NET_ID, MessageHandler);
|
||||
_processing?.CompleteAdding();
|
||||
_closing = true;
|
||||
//_task.Wait();
|
||||
if (!fromServer)
|
||||
return;
|
||||
|
||||
var message = MyAPIGateway.Utilities.SerializeFromBinary<MessageBase>(data);
|
||||
message.SenderId = sender;
|
||||
|
||||
if (MyAPIGateway.Multiplayer.IsServer) message.ProcessServer();
|
||||
else message.ProcessClient();
|
||||
}
|
||||
|
||||
private static void MessageHandler(byte[] bytes)
|
||||
{
|
||||
var m = _messagePool.Get();
|
||||
m.CompressedData = bytes;
|
||||
#if TORCH
|
||||
m.SenderId = MyEventContext.Current.Sender.Value;
|
||||
#endif
|
||||
[ReflectedMethodInfo(typeof(MyAPIUtilities), "VRage.Game.ModAPI.IMyUtilities.SerializeToBinary")]
|
||||
private static MethodInfo _serializeMethod = null!;
|
||||
|
||||
_processing.Add(m);
|
||||
}
|
||||
private static readonly CacheList<IMyPlayer> Players = new();
|
||||
|
||||
public static void DoProcessing()
|
||||
private static byte[] Serialize(MessageBase message)
|
||||
{
|
||||
while (!_closing)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageBase m;
|
||||
try
|
||||
{
|
||||
m = _processing.Take();
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MyLog.Default.WriteLineAndConsole($"Processing message: {m.GetType().Name}");
|
||||
|
||||
if (m is IncomingMessage) //process incoming messages
|
||||
{
|
||||
MessageBase i;
|
||||
try
|
||||
{
|
||||
var o = MyCompression.Decompress(m.CompressedData);
|
||||
m.CompressedData = null;
|
||||
_messagePool.Return((IncomingMessage)m);
|
||||
i = MyAPIGateway.Utilities.SerializeFromBinary<MessageBase>(o);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole($"TORCH MOD: Failed to deserialize message! {ex}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TorchModCore.Debug)
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Received message of type {i.GetType().Name}");
|
||||
|
||||
if (MyAPIGateway.Multiplayer.IsServer)
|
||||
i.ProcessServer();
|
||||
else
|
||||
i.ProcessClient();
|
||||
}
|
||||
else //process outgoing messages
|
||||
{
|
||||
if (TorchModCore.Debug)
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Sending message of type {m.GetType().Name}");
|
||||
|
||||
var b = MyAPIGateway.Utilities.SerializeToBinary(m);
|
||||
m.CompressedData = MyCompression.Compress(b);
|
||||
|
||||
switch (m.TargetType)
|
||||
{
|
||||
case MessageTarget.Single:
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, m.Target);
|
||||
break;
|
||||
case MessageTarget.Server:
|
||||
MyAPIGateway.Multiplayer.SendMessageToServer(NET_ID, m.CompressedData);
|
||||
break;
|
||||
case MessageTarget.AllClients:
|
||||
MyAPIGateway.Players.GetPlayers(_playerCache);
|
||||
foreach (var p in _playerCache)
|
||||
{
|
||||
if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId)
|
||||
continue;
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
|
||||
}
|
||||
|
||||
break;
|
||||
case MessageTarget.AllExcept:
|
||||
MyAPIGateway.Players.GetPlayers(_playerCache);
|
||||
foreach (var p in _playerCache)
|
||||
{
|
||||
if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId || m.Ignore.Contains(p.SteamUserId))
|
||||
continue;
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
_playerCache.Clear();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole($"TORCH MOD: Exception occurred in communication thread! {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: INFO: Communication thread shut down successfully! THIS IS NOT AN ERROR");
|
||||
//exit signal received. Clean everything and GTFO
|
||||
_processing?.Dispose();
|
||||
_processing = null;
|
||||
_messagePool?.Clean();
|
||||
_messagePool = null;
|
||||
_playerCache = null;
|
||||
return (byte[])_serializeMethod.MakeGenericMethod(message.GetType())
|
||||
.Invoke(MyAPIGateway.Utilities, new object[] { message });
|
||||
}
|
||||
|
||||
public static void SendMessageTo(MessageBase message, ulong target)
|
||||
@@ -163,12 +52,7 @@ namespace Torch.Mod
|
||||
if (!MyAPIGateway.Multiplayer.IsServer)
|
||||
throw new Exception("Only server can send targeted messages");
|
||||
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.Target = target;
|
||||
message.TargetType = MessageTarget.Single;
|
||||
_processing.Add(message);
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(CHANNEL, Serialize(message), target);
|
||||
}
|
||||
|
||||
public static void SendMessageToClients(MessageBase message)
|
||||
@@ -176,11 +60,7 @@ namespace Torch.Mod
|
||||
if (!MyAPIGateway.Multiplayer.IsServer)
|
||||
throw new Exception("Only server can send targeted messages");
|
||||
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.TargetType = MessageTarget.AllClients;
|
||||
_processing.Add(message);
|
||||
MyAPIGateway.Multiplayer.SendMessageToOthers(CHANNEL, Serialize(message));
|
||||
}
|
||||
|
||||
public static void SendMessageExcept(MessageBase message, params ulong[] ignoredUsers)
|
||||
@@ -188,21 +68,20 @@ namespace Torch.Mod
|
||||
if (!MyAPIGateway.Multiplayer.IsServer)
|
||||
throw new Exception("Only server can send targeted messages");
|
||||
|
||||
if (_closing)
|
||||
return;
|
||||
using var players = Players;
|
||||
MyAPIGateway.Multiplayer.Players.GetPlayers(players, player => !ignoredUsers.Contains(player.SteamUserId));
|
||||
|
||||
message.TargetType = MessageTarget.AllExcept;
|
||||
message.Ignore = ignoredUsers;
|
||||
_processing.Add(message);
|
||||
var data = Serialize(message);
|
||||
foreach (var player in players)
|
||||
{
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(CHANNEL, data, player.SteamUserId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendMessageToServer(MessageBase message)
|
||||
{
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.TargetType = MessageTarget.Server;
|
||||
_processing.Add(message);
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -9,13 +9,11 @@
|
||||
<Import_RootNamespace>Torch.Mod</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\IncomingMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\JoinServerMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\NotificationMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\DialogMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\MessageBase.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\VoxelResetMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ModCommunication.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)TorchModCore.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.ModAPI;
|
||||
using VRage.Game.Components;
|
||||
|
||||
namespace Torch.Mod
|
||||
{
|
||||
[MySessionComponentDescriptor(MyUpdateOrder.AfterSimulation)]
|
||||
public class TorchModCore : MySessionComponentBase
|
||||
{
|
||||
public const ulong MOD_ID = 2722000298;
|
||||
private static bool _init;
|
||||
public static bool Debug;
|
||||
|
||||
public override void UpdateAfterSimulation()
|
||||
{
|
||||
if (_init)
|
||||
return;
|
||||
|
||||
_init = true;
|
||||
ModCommunication.Register();
|
||||
MyAPIGateway.Utilities.MessageEntered += Utilities_MessageEntered;
|
||||
}
|
||||
|
||||
private void Utilities_MessageEntered(string messageText, ref bool sendToOthers)
|
||||
{
|
||||
if (messageText == "@!debug")
|
||||
{
|
||||
Debug = !Debug;
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Debug: {Debug}");
|
||||
sendToOthers = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UnloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
MyAPIGateway.Utilities.MessageEntered -= Utilities_MessageEntered;
|
||||
ModCommunication.Unregister();
|
||||
}
|
||||
catch
|
||||
{
|
||||
//session unloading, don't care
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
Torch.Server.ReferenceAssemblies.net7.nuspec
Normal file
24
Torch.Server.ReferenceAssemblies.net7.nuspec
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Torch.Server.ReferenceAssemblies.net7</id>
|
||||
<version>torchVersion</version>
|
||||
<title>Torch Server Reference Assemblies</title>
|
||||
<authors>zznty</authors>
|
||||
<owners>zznty</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Torch Server Reference Assemblies (.NET 7 edition)</description>
|
||||
<repository type="git" url="https://github.com/PveTeam/Torch" />
|
||||
<dependencies>
|
||||
<group targetFramework="net7.0-windows7.0">
|
||||
<dependency id="SpaceEngineersDedicated.ReferenceAssemblies" version="1.203.22.3" />
|
||||
<dependency id="Torch.Server" version="torchVersion" />
|
||||
</group>
|
||||
</dependencies>
|
||||
<frameworkReferences>
|
||||
<group targetFramework="net7.0-windows7.0">
|
||||
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
|
||||
</group>
|
||||
</frameworkReferences>
|
||||
</metadata>
|
||||
</package>
|
@@ -1,7 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<NoWarn>1591,0649</NoWarn>
|
||||
<AssemblyTitle>Torch Server Tests</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
@@ -9,24 +7,15 @@
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<OutputPath>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(Configuration) == 'Release'">
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\Torch.Server.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="xunit" Version="2.6.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
|
2446
Torch.Server.Tests/packages.lock.json
Normal file
2446
Torch.Server.Tests/packages.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,9 +12,11 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using Sandbox.Engine.Utils;
|
||||
using SpaceEngineers.Game;
|
||||
using Torch.Utils;
|
||||
using VRage.FileSystem;
|
||||
|
||||
@@ -26,10 +28,10 @@ namespace Torch.Server
|
||||
|
||||
private static readonly Logger Log = LogManager.GetLogger(nameof(Initializer));
|
||||
private bool _init;
|
||||
private const string STEAMCMD_DIR = "steamcmd";
|
||||
private const string STEAMCMD_ZIP = "temp.zip";
|
||||
private static readonly string STEAMCMD_EXE = "steamcmd.exe";
|
||||
private const string STEAMCMD_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
|
||||
private const string TOOL_DIR = "tool";
|
||||
private const string TOOL_ZIP = "temp.zip";
|
||||
private static readonly string TOOL_EXE = "steamcmd.exe";
|
||||
private const string TOOL_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
|
||||
private TorchServer _server;
|
||||
|
||||
internal Persistent<TorchConfig> ConfigPersistent { get; }
|
||||
@@ -42,7 +44,7 @@ namespace Torch.Server
|
||||
ConfigPersistent = torchConfig;
|
||||
}
|
||||
|
||||
public bool Initialize(string[] args)
|
||||
public bool Initialize(IConfiguration configuration)
|
||||
{
|
||||
if (_init)
|
||||
return false;
|
||||
@@ -55,18 +57,17 @@ namespace Torch.Server
|
||||
Log.Debug("Debug logging enabled.");
|
||||
#endif
|
||||
|
||||
// This is what happens when Keen is bad and puts extensions into the System namespace.
|
||||
if (!Enumerable.Contains(args, "-noupdate"))
|
||||
RunSteamCmd();
|
||||
if (configuration.GetValue("getGameUpdates", true) && !configuration.GetValue("noupdate", false))
|
||||
RunSteamCmdAsync(configuration).Wait();
|
||||
|
||||
if (!string.IsNullOrEmpty(Config.WaitForPID))
|
||||
var processPid = configuration.GetValue<int>("waitForPid");
|
||||
if (processPid != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pid = int.Parse(Config.WaitForPID);
|
||||
var waitProc = Process.GetProcessById(pid);
|
||||
var waitProc = Process.GetProcessById(processPid);
|
||||
Log.Info("Continuing in 5 seconds.");
|
||||
Log.Warn($"Waiting for process {pid} to close");
|
||||
Log.Warn($"Waiting for process {processPid} to close");
|
||||
while (!waitProc.HasExited)
|
||||
{
|
||||
Console.Write(".");
|
||||
@@ -83,9 +84,9 @@ namespace Torch.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
public void Run(IConfiguration configuration)
|
||||
{
|
||||
_server = new TorchServer(Config, ApplicationContext.Current.InstanceDirectory.FullName, ApplicationContext.Current.InstanceName);
|
||||
_server = new TorchServer(Config, ApplicationContext.Current.InstanceDirectory.FullName, ApplicationContext.Current.InstanceName, configuration);
|
||||
|
||||
if (ApplicationContext.Current.IsService || Config.NoGui)
|
||||
{
|
||||
@@ -102,51 +103,56 @@ namespace Torch.Server
|
||||
}
|
||||
#endif
|
||||
|
||||
var gameThread = new Thread(() =>
|
||||
{
|
||||
_server.Init();
|
||||
_server.Init();
|
||||
|
||||
if (Config.Autostart || Config.TempAutostart)
|
||||
{
|
||||
Config.TempAutostart = false;
|
||||
_server.Start();
|
||||
}
|
||||
var uiThread = new Thread(() =>
|
||||
{
|
||||
var ui = new TorchUI(_server);
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
|
||||
|
||||
ui.ShowDialog();
|
||||
});
|
||||
|
||||
gameThread.Start();
|
||||
uiThread.SetApartmentState(ApartmentState.STA);
|
||||
uiThread.Start();
|
||||
|
||||
var ui = new TorchUI(_server);
|
||||
if (Config.Autostart || Config.TempAutostart)
|
||||
{
|
||||
Config.TempAutostart = false;
|
||||
_server.Start();
|
||||
}
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
|
||||
|
||||
ui.ShowDialog();
|
||||
uiThread.Join();
|
||||
}
|
||||
}
|
||||
|
||||
public static void RunSteamCmd()
|
||||
public static async Task RunSteamCmdAsync(IConfiguration configuration)
|
||||
{
|
||||
var log = LogManager.GetLogger("SteamCMD");
|
||||
|
||||
var path = Environment.GetEnvironmentVariable("TORCH_STEAMCMD") ?? Path.GetFullPath(STEAMCMD_DIR);
|
||||
var path = configuration.GetValue<string>("steamToolPath") ?? ApplicationContext.Current.TorchDirectory
|
||||
.CreateSubdirectory(TOOL_DIR).FullName;
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
var steamCmdExePath = Path.Combine(path, STEAMCMD_EXE);
|
||||
if (!File.Exists(steamCmdExePath))
|
||||
var toolExe = Path.Combine(path, TOOL_EXE);
|
||||
if (!File.Exists(toolExe))
|
||||
{
|
||||
try
|
||||
{
|
||||
log.Info("Downloading SteamCMD.");
|
||||
using (var client = new HttpClient())
|
||||
using (var file = File.Create(STEAMCMD_ZIP))
|
||||
client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip").Result.CopyTo(file);
|
||||
await using (var file = File.Create(TOOL_ZIP))
|
||||
await using (var stream = await client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"))
|
||||
await stream.CopyToAsync(file);
|
||||
|
||||
ZipFile.ExtractToDirectory(STEAMCMD_ZIP, path);
|
||||
File.Delete(STEAMCMD_ZIP);
|
||||
ZipFile.ExtractToDirectory(TOOL_ZIP, path);
|
||||
File.Delete(TOOL_ZIP);
|
||||
log.Info("SteamCMD downloaded successfully!");
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -157,21 +163,18 @@ namespace Torch.Server
|
||||
}
|
||||
|
||||
log.Info("Checking for DS updates.");
|
||||
var steamCmdProc = new ProcessStartInfo(steamCmdExePath)
|
||||
var steamCmdProc = new ProcessStartInfo(toolExe)
|
||||
{
|
||||
Arguments = string.Format(STEAMCMD_ARGS, Environment.GetEnvironmentVariable("TORCH_GAME_PATH") ?? "../"),
|
||||
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../")),
|
||||
WorkingDirectory = path,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
StandardOutputEncoding = Encoding.ASCII
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
var cmd = Process.Start(steamCmdProc);
|
||||
var cmd = Process.Start(steamCmdProc)!;
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
while (!cmd.HasExited)
|
||||
{
|
||||
log.Info(cmd.StandardOutput.ReadLine());
|
||||
Thread.Sleep(100);
|
||||
if (await cmd.StandardOutput.ReadLineAsync() is { } line)
|
||||
log.Info(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,13 +40,7 @@ namespace Torch.Server.Managers
|
||||
|
||||
protected abstract EntityControlViewModel Create(EntityViewModel evm);
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[ReflectedGetter(Name = "Keys")]
|
||||
private static readonly Func<ConditionalWeakTable<EntityViewModel, EntityControlViewModel>, ICollection<EntityViewModel>> WeakTableKeys = null!;
|
||||
internal IEnumerable<EntityViewModel> Keys => WeakTableKeys(_models);
|
||||
#else
|
||||
internal IEnumerable<EntityViewModel> Keys => _models.Select(b => b.Key);
|
||||
#endif
|
||||
|
||||
internal EntityControlViewModel GetOrCreate(EntityViewModel evm)
|
||||
{
|
||||
|
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Havok;
|
||||
using NLog;
|
||||
@@ -27,6 +28,7 @@ using VRage.FileSystem;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ObjectBuilder;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.ObjectBuilders.Private;
|
||||
using VRage.Plugins;
|
||||
|
||||
namespace Torch.Server.Managers
|
||||
@@ -35,7 +37,45 @@ namespace Torch.Server.Managers
|
||||
{
|
||||
private const string CONFIG_NAME = "SpaceEngineers-Dedicated.cfg";
|
||||
|
||||
public event Action<ConfigDedicatedViewModel> InstanceLoaded;
|
||||
private Action<ConfigDedicatedViewModel> _instanceLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the instance loaded event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Called when the instance is loaded and immediately if subscribed after the instance is loaded.
|
||||
/// </remarks>
|
||||
public event Action<ConfigDedicatedViewModel> InstanceLoaded
|
||||
{
|
||||
add
|
||||
{
|
||||
var action = _instanceLoaded;
|
||||
Action<ConfigDedicatedViewModel> action2;
|
||||
do
|
||||
{
|
||||
action2 = action;
|
||||
var action3 = (Action<ConfigDedicatedViewModel>)Delegate.Combine(action2, value);
|
||||
action = Interlocked.CompareExchange(ref _instanceLoaded, action3, action2);
|
||||
}
|
||||
while (action != action2);
|
||||
|
||||
if (DedicatedConfig is not null)
|
||||
value(DedicatedConfig);
|
||||
}
|
||||
remove
|
||||
{
|
||||
var action = _instanceLoaded;
|
||||
Action<ConfigDedicatedViewModel> action2;
|
||||
do
|
||||
{
|
||||
action2 = action;
|
||||
var action3 = (Action<ConfigDedicatedViewModel>)Delegate.Remove(action2, value);
|
||||
action = Interlocked.CompareExchange(ref _instanceLoaded, action3, action2);
|
||||
}
|
||||
while (action != action2);
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigDedicatedViewModel DedicatedConfig { get; set; }
|
||||
private static readonly Logger Log = LogManager.GetLogger(nameof(InstanceManager));
|
||||
[Dependency]
|
||||
@@ -90,8 +130,7 @@ namespace Torch.Server.Managers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Failed to load world at path: " + f);
|
||||
continue;
|
||||
Log.Error(ex, "Failed to load world at path: " + f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +142,7 @@ namespace Torch.Server.Managers
|
||||
|
||||
SelectWorld(DedicatedConfig.LoadWorld ?? DedicatedConfig.Worlds.First().WorldPath, false);
|
||||
|
||||
InstanceLoaded?.Invoke(DedicatedConfig);
|
||||
_instanceLoaded?.Invoke(DedicatedConfig);
|
||||
}
|
||||
|
||||
public void SelectCreatedWorld(string worldPath)
|
||||
@@ -137,7 +176,7 @@ namespace Torch.Server.Managers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Failed to load world at path: " + worldPath);
|
||||
Log.Error(ex, "Failed to load world at path: " + worldPath);
|
||||
DedicatedConfig.LoadWorld = null;
|
||||
return;
|
||||
}
|
||||
@@ -147,7 +186,7 @@ namespace Torch.Server.Managers
|
||||
{
|
||||
DedicatedConfig.Mods.Clear();
|
||||
//remove the Torch mod to avoid running multiple copies of it
|
||||
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
|
||||
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == ModCommunication.MOD_ID);
|
||||
foreach (var m in DedicatedConfig.SelectedWorld.WorldConfiguration.Mods)
|
||||
DedicatedConfig.Mods.Add(new ModItemInfo(m));
|
||||
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
|
||||
@@ -162,7 +201,7 @@ namespace Torch.Server.Managers
|
||||
{
|
||||
DedicatedConfig.Mods.Clear();
|
||||
//remove the Torch mod to avoid running multiple copies of it
|
||||
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
|
||||
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == ModCommunication.MOD_ID);
|
||||
foreach (var m in DedicatedConfig.SelectedWorld.WorldConfiguration.Mods)
|
||||
DedicatedConfig.Mods.Add(new ModItemInfo(m));
|
||||
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
|
||||
@@ -236,9 +275,9 @@ namespace Torch.Server.Managers
|
||||
{
|
||||
var world = DedicatedConfig.SelectedWorld;
|
||||
|
||||
world.Checkpoint.SessionName = string.IsNullOrEmpty(DedicatedConfig.WorldName)
|
||||
world.Checkpoint.SessionName = string.IsNullOrEmpty(world.Checkpoint.SessionName)
|
||||
? Path.GetDirectoryName(DedicatedConfig.LoadWorld)
|
||||
: DedicatedConfig.WorldName;
|
||||
: world.Checkpoint.SessionName;
|
||||
world.WorldConfiguration.Settings = DedicatedConfig.SessionSettings;
|
||||
world.WorldConfiguration.Mods.Clear();
|
||||
|
||||
@@ -284,7 +323,6 @@ namespace Torch.Server.Managers
|
||||
{
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public string FolderName { get; set; }
|
||||
public string WorldPath { get; }
|
||||
public MyObjectBuilder_SessionSettings KeenSessionSettings => WorldConfiguration.Settings;
|
||||
public MyObjectBuilder_Checkpoint KeenCheckpoint => Checkpoint;
|
||||
@@ -313,7 +351,6 @@ namespace Torch.Server.Managers
|
||||
WorldSizeKB = new DirectoryInfo(worldPath).GetFiles().Sum(x => x.Length) / 1024;
|
||||
_checkpointPath = Path.Combine(WorldPath, "Sandbox.sbc");
|
||||
_worldConfigPath = Path.Combine(WorldPath, "Sandbox_config.sbc");
|
||||
FolderName = Path.GetFileName(worldPath);
|
||||
if (loadFiles)
|
||||
LoadSandbox();
|
||||
}
|
||||
@@ -327,10 +364,10 @@ namespace Torch.Server.Managers
|
||||
public void SaveSandbox()
|
||||
{
|
||||
using (var f = File.Open(_checkpointPath, FileMode.Create))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, Checkpoint);
|
||||
MyObjectBuilderSerializerKeen.SerializeXML(f, Checkpoint);
|
||||
|
||||
using (var f = File.Open(_worldConfigPath, FileMode.Create))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, WorldConfiguration);
|
||||
MyObjectBuilderSerializerKeen.SerializeXML(f, WorldConfiguration);
|
||||
}
|
||||
|
||||
public void LoadSandbox()
|
||||
|
@@ -12,7 +12,6 @@ using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Game.Gui;
|
||||
using Sandbox.Game.World;
|
||||
using Steamworks;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers;
|
||||
|
@@ -32,7 +32,7 @@ namespace Torch.Server.Managers
|
||||
{
|
||||
if (newstate == TorchGameState.Loading && MySandboxGame.ConfigDedicated.RemoteApiEnabled && !string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.RemoteSecurityKey))
|
||||
{
|
||||
var myRemoteServer = new MyRemoteServer(MySandboxGame.ConfigDedicated.RemoteApiPort, MySandboxGame.ConfigDedicated.RemoteSecurityKey);
|
||||
var myRemoteServer = new MyRemoteServer(MySandboxGame.ConfigDedicated.RemoteApiIP, MySandboxGame.ConfigDedicated.RemoteApiPort, MySandboxGame.ConfigDedicated.RemoteSecurityKey);
|
||||
LogManager.GetCurrentClassLogger().Info($"Remote API started on port {myRemoteServer.Port}");
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ using NLog;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Server;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
using VRage.Game;
|
||||
@@ -25,6 +26,9 @@ public static class CheckpointLoadPatch
|
||||
private static bool Prefix(ref MyObjectBuilder_Checkpoint __result)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
if (!((TorchServer)TorchBase.Instance).HasRun)
|
||||
return true;
|
||||
|
||||
var world = TorchBase.Instance.Managers.GetManager<InstanceManager>().DedicatedConfig.SelectedWorld;
|
||||
#pragma warning restore CS0618
|
||||
if (world is null)
|
||||
|
35
Torch.Server/Patches/SteamLoginPatch.cs
Normal file
35
Torch.Server/Patches/SteamLoginPatch.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using Steamworks;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Utils;
|
||||
|
||||
namespace Torch.Patches;
|
||||
|
||||
[PatchShim]
|
||||
public static class SteamLoginPatch
|
||||
{
|
||||
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[ReflectedMethodInfo(null, "LogOnAnonymous", TypeName = "VRage.Steam.MySteamGameServer, VRage.Steam")]
|
||||
private static MethodInfo LoginMethod = null!;
|
||||
|
||||
public static void Patch(PatchContext context)
|
||||
{
|
||||
context.GetPattern(LoginMethod).AddPrefix();
|
||||
}
|
||||
|
||||
private static bool Prefix()
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
var token = TorchBase.Instance.Config.LoginToken;
|
||||
#pragma warning restore CS0618
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return true;
|
||||
|
||||
Log.Info("Logging in to Steam with GSLT");
|
||||
SteamGameServer.LogOn(token);
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration.Xml;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
@@ -10,34 +12,24 @@ namespace Torch.Server
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
[MTAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var context = CreateApplicationContext();
|
||||
var configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables("TORCH")
|
||||
.AddCommandLine(args);
|
||||
var configuration = configurationBuilder.Build();
|
||||
|
||||
SetupLogging();
|
||||
var context = CreateApplicationContext(configuration);
|
||||
|
||||
var oldTorchCfg = Path.Combine(context.TorchDirectory.FullName, "Torch.cfg");
|
||||
var torchCfg = Path.Combine(context.InstanceDirectory.FullName, "Torch.cfg");
|
||||
|
||||
if (File.Exists(oldTorchCfg))
|
||||
File.Move(oldTorchCfg, torchCfg);
|
||||
|
||||
var config = Persistent<TorchConfig>.Load(torchCfg);
|
||||
config.Data.InstanceName = context.InstanceName;
|
||||
config.Data.InstancePath = context.InstanceDirectory.FullName;
|
||||
|
||||
if (!config.Data.Parse(args))
|
||||
{
|
||||
Console.WriteLine("Invalid arguments");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
SetupLogging(context, configuration);
|
||||
var config = SetupConfiguration(context, configurationBuilder, out configuration);
|
||||
|
||||
var handler = new UnhandledExceptionHandler(config.Data);
|
||||
AppDomain.CurrentDomain.UnhandledException += handler.OnUnhandledException;
|
||||
|
||||
var initializer = new Initializer(config);
|
||||
if (!initializer.Initialize(args))
|
||||
if (!initializer.Initialize(configuration))
|
||||
Environment.Exit(1);
|
||||
|
||||
#if DEBUG
|
||||
@@ -47,86 +39,58 @@ namespace Torch.Server
|
||||
context.GameBinariesDirectory.FullName);
|
||||
#endif
|
||||
|
||||
CopyNative();
|
||||
|
||||
initializer.Run();
|
||||
initializer.Run(configuration);
|
||||
}
|
||||
|
||||
private static void CopyNative()
|
||||
private static void SetupLogging(IApplicationContext context, IConfiguration configuration)
|
||||
{
|
||||
var log = LogManager.GetLogger("TorchLauncher");
|
||||
|
||||
if (ApplicationContext.Current.GameFilesDirectory.Attributes.HasFlag(FileAttributes.ReadOnly))
|
||||
{
|
||||
log.Warn("Torch directory is readonly. You should copy steam_api64.dll, Havok.dll from bin manually");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var apiSource = Path.Combine(ApplicationContext.Current.GameBinariesDirectory.FullName, "steam_api64.dll");
|
||||
var apiTarget = Path.Combine(ApplicationContext.Current.GameFilesDirectory.FullName, "steam_api64.dll");
|
||||
if (!File.Exists(apiTarget))
|
||||
{
|
||||
File.Copy(apiSource, apiTarget);
|
||||
}
|
||||
else if (File.GetLastWriteTime(apiTarget) < ApplicationContext.Current.GameBinariesDirectory.LastWriteTime)
|
||||
{
|
||||
File.Delete(apiTarget);
|
||||
File.Copy(apiSource, apiTarget);
|
||||
}
|
||||
|
||||
var havokSource = Path.Combine(ApplicationContext.Current.GameBinariesDirectory.FullName, "Havok.dll");
|
||||
var havokTarget = Path.Combine(ApplicationContext.Current.GameFilesDirectory.FullName, "Havok.dll");
|
||||
|
||||
if (!File.Exists(havokTarget))
|
||||
{
|
||||
File.Copy(havokSource, havokTarget);
|
||||
}
|
||||
else if (File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
|
||||
{
|
||||
File.Delete(havokTarget);
|
||||
File.Copy(havokSource, havokTarget);
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// file is being used by another process, probably previous torch has not been closed yet
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetupLogging()
|
||||
{
|
||||
var oldNlog = Path.Combine(ApplicationContext.Current.TorchDirectory.FullName, "NLog.config");
|
||||
var newNlog = Path.Combine(ApplicationContext.Current.InstanceDirectory.FullName, "NLog.config");
|
||||
var oldNlog = Path.Combine(context.TorchDirectory.FullName, "NLog.config");
|
||||
var newNlog = configuration.GetValue("loggingConfigPath", Path.Combine(context.InstanceDirectory.FullName, "NLog.config"));
|
||||
if (File.Exists(oldNlog) && !File.ReadAllText(oldNlog).Contains("FlowDocument"))
|
||||
File.Move(oldNlog, newNlog);
|
||||
else if (!File.Exists(newNlog))
|
||||
using (var f = File.Create(newNlog))
|
||||
using (var f = File.Create(newNlog!))
|
||||
typeof(Program).Assembly.GetManifestResourceStream("Torch.Server.NLog.config")!.CopyTo(f);
|
||||
|
||||
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
||||
TorchLogManager.RegisterTargets(Environment.GetEnvironmentVariable("TORCH_LOG_EXTENSIONS_PATH") ??
|
||||
Path.Combine(ApplicationContext.Current.InstanceDirectory.FullName, "LoggingExtensions"));
|
||||
TorchLogManager.RegisterTargets(configuration.GetValue("loggingExtensionsPath",
|
||||
Path.Combine(
|
||||
context.InstanceDirectory.FullName,
|
||||
"LoggingExtensions")));
|
||||
|
||||
TorchLogManager.SetConfiguration(new XmlLoggingConfiguration(newNlog));
|
||||
}
|
||||
|
||||
private static IApplicationContext CreateApplicationContext()
|
||||
private static Persistent<TorchConfig> SetupConfiguration(IApplicationContext context,
|
||||
IConfigurationBuilder builder,
|
||||
out IConfigurationRoot configuration)
|
||||
{
|
||||
var isService = Environment.GetEnvironmentVariable("TORCH_SERVICE")
|
||||
?.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase) ?? false;
|
||||
var oldTorchCfg = Path.Combine(context.TorchDirectory.FullName, "Torch.cfg");
|
||||
var torchCfg = Path.Combine(context.InstanceDirectory.FullName, "Torch.cfg");
|
||||
|
||||
if (File.Exists(oldTorchCfg))
|
||||
File.Move(oldTorchCfg, torchCfg);
|
||||
|
||||
builder.AddXmlFile(torchCfg, true, true);
|
||||
|
||||
configuration = builder.Build();
|
||||
|
||||
var config = new Persistent<TorchConfig>(torchCfg, configuration.Get<TorchConfig>() ?? new());
|
||||
config.Data.InstanceName = context.InstanceName;
|
||||
config.Data.InstancePath = context.InstanceDirectory.FullName;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private static IApplicationContext CreateApplicationContext(IConfiguration configuration)
|
||||
{
|
||||
var isService = configuration.GetValue("service", false);
|
||||
|
||||
var workingDir = AppContext.BaseDirectory;
|
||||
var gamePath = Environment.GetEnvironmentVariable("TORCH_GAME_PATH") ?? workingDir;
|
||||
var gamePath = configuration.GetValue("gamePath", workingDir);
|
||||
var binDir = Path.Combine(gamePath, "DedicatedServer64");
|
||||
Directory.SetCurrentDirectory(gamePath);
|
||||
|
||||
var instanceName = Environment.GetEnvironmentVariable("TORCH_INSTANCE") ?? "Instance";
|
||||
var instanceName = configuration.GetValue("instanceName", "Instance");
|
||||
string instancePath;
|
||||
|
||||
if (Path.IsPathRooted(instanceName))
|
||||
@@ -136,9 +100,11 @@ namespace Torch.Server
|
||||
}
|
||||
else
|
||||
{
|
||||
instancePath = Directory.CreateDirectory(instanceName).FullName;
|
||||
instancePath = Directory.CreateDirectory(instanceName!).FullName;
|
||||
}
|
||||
|
||||
Directory.SetCurrentDirectory(gamePath);
|
||||
|
||||
return new ApplicationContext(new(workingDir), new(gamePath), new(binDir),
|
||||
new(instancePath), instanceName, isService);
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
"profiles": {
|
||||
"Torch.Server": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "-noupdate",
|
||||
"commandLineArgs": "--noupdate true --gamepath \"C:\\Program Files (x86)\\Steam\\steamapps\\common\\SpaceEngineersDedicatedServer\"",
|
||||
"use64Bit": true,
|
||||
"hotReloadEnabled": false
|
||||
}
|
||||
|
@@ -1,159 +1,73 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<AssemblyTitle>Torch Server</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<OutputPath>..\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<UseWPF>true</UseWPF>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<IsPackable>false</IsPackable>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
<TieredPGO>true</TieredPGO>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<BeautyLibsDir>torch64</BeautyLibsDir>
|
||||
<NoBeautyFlag>True</NoBeautyFlag>
|
||||
<ForceBeauty>True</ForceBeauty>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<StartupObject>Torch.Server.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>torchicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoCompleteTextBox" Version="1.3.0" />
|
||||
<PackageReference Include="AutoCompleteTextBox" Version="1.7.2" />
|
||||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
|
||||
<PackageReference Include="ControlzEx" Version="5.0.1" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
|
||||
<PackageReference Include="MdXaml" Version="1.12.0" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="2.0.226801" />
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="all" />
|
||||
<PackageReference Include="ControlzEx" Version="5.0.2" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
|
||||
<PackageReference Include="MdXaml" Version="1.22.0" />
|
||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="3.1.456101" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Steamworks.NET" Version="20.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>compile</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.Management" Version="6.0.0" />
|
||||
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HavokWrapper, Version=1.0.6051.28726, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\HavokWrapper.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game, Version=0.1.6305.30774, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics, Version=0.1.6305.30761, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Steamworks.NET">
|
||||
<HintPath>..\GameBinaries\Steamworks.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="VRage, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Audio, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Audio.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Dedicated, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Dedicated.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Platform.Windows, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\GameBinaries\VRage.Platform.Windows.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render11, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Render11.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Scripting, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\GameBinaries\VRage.Scripting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Steam">
|
||||
<HintPath>..\GameBinaries\VRage.Steam.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.5" />
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.203.505.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>compile</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="ServerManager.cs" />
|
||||
<Compile Remove="ViewModels\SessionSettingsViewModel1.cs" />
|
||||
<Compile Remove="Views\WorldSelectControl.xaml.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="torchicon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Remove="Views\WorldSelectControl.xaml" />
|
||||
<EmbeddedResource Include="..\NLog.config" Visible="false" />
|
||||
|
@@ -1,171 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.Serialization;
|
||||
using NLog;
|
||||
using Torch.API;
|
||||
using Torch.Views;
|
||||
|
||||
namespace Torch.Server
|
||||
namespace Torch.Server;
|
||||
|
||||
public class TorchConfig : ViewModel, ITorchConfig
|
||||
{
|
||||
// TODO: redesign this gerbage
|
||||
public class TorchConfig : CommandLine, ITorchConfig, INotifyPropertyChanged
|
||||
public bool ShouldUpdatePlugins => (GetPluginUpdates && !NoUpdate) || ForceUpdate;
|
||||
public bool ShouldUpdateTorch => (GetTorchUpdates && !NoUpdate) || ForceUpdate;
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore]
|
||||
public bool NoUpdate { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore]
|
||||
public bool ForceUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Permanent flag to ALWAYS automatically start the server
|
||||
/// </summary>
|
||||
[Display(Name = "Auto Start", Description = "Permanent flag to ALWAYS automatically start the server.", GroupName = "Server")]
|
||||
public bool Autostart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Temporary flag to automatically start the server only on the next run
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public bool TempAutostart { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Restart On Crash", Description = "Automatically restart the server if it crashes.", GroupName = "Server")]
|
||||
public bool RestartOnCrash { get; set; }
|
||||
|
||||
public string InstancePath { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "No GUI", Description = "Do not show the Torch UI.", GroupName = "Window")]
|
||||
public bool NoGui { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Update Torch", Description = "Check every start for new versions of torch.",
|
||||
GroupName = "Server")]
|
||||
public bool GetTorchUpdates { get; set; } = true;
|
||||
|
||||
public string InstanceName { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Update Plugins", Description = "Check every start for new versions of plugins.",
|
||||
GroupName = "Server")]
|
||||
public bool GetPluginUpdates { get; set; } = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Watchdog Timeout", Description = "Watchdog timeout (in seconds).", GroupName = "Server")]
|
||||
public int TickTimeout { get; set; } = 60;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Guid> Plugins { get; set; } = new();
|
||||
|
||||
[Display(Name = "Local Plugins", Description = "Loads all pluhins from disk, ignores the plugins defined in config.", GroupName = "In-Game")]
|
||||
public bool LocalPlugins { get; set; }
|
||||
|
||||
[Display(Name = "Auto Disconnect", Description = "When server restarts, all clients are rejected to main menu to prevent auto rejoin.", GroupName = "In-Game")]
|
||||
public bool DisconnectOnRestart { get; set; }
|
||||
|
||||
[Display(Name = "Chat Name", Description = "Default name for chat from gui, broadcasts etc..",
|
||||
GroupName = "In-Game")]
|
||||
public string ChatName { get; set; } = "Server";
|
||||
|
||||
[Display(Name = "Chat Color",
|
||||
Description = "Default color for chat from gui, broadcasts etc.. (Red, Blue, White, Green)",
|
||||
GroupName = "In-Game")]
|
||||
public string ChatColor { get; set; } = "Red";
|
||||
|
||||
[Display(Name = "Enable Whitelist", Description = "Enable Whitelist to prevent random players join while maintance, tests or other.", GroupName = "In-Game")]
|
||||
public bool EnableWhitelist { get; set; }
|
||||
|
||||
[Display(Name = "Whitelist", Description = "Collection of whitelisted steam ids.", GroupName = "In-Game")]
|
||||
public List<ulong> Whitelist { get; set; } = new();
|
||||
|
||||
[Display(Name = "Width", Description = "Default window width.", GroupName = "Window")]
|
||||
public int WindowWidth { get; set; } = 980;
|
||||
|
||||
[Display(Name = "Height", Description = "Default window height", GroupName = "Window")]
|
||||
public int WindowHeight { get; set; } = 588;
|
||||
|
||||
[Display(Name = "Font Size", Description = "Font size for logging text box. (default is 16)",
|
||||
GroupName = "Window")]
|
||||
public int FontSize { get; set; } = 16;
|
||||
|
||||
[Display(Name = "UGC Service Type", Description = "Service for downloading mods", GroupName = "Server")]
|
||||
public UGCServiceType UgcServiceType { get; set; } = UGCServiceType.Steam;
|
||||
|
||||
public string LastUsedTheme { get; set; } = "Torch Theme";
|
||||
|
||||
[Display(Name = "Independent Console", Description = "Keeps a separate console window open after the main UI loads.", GroupName = "Window")]
|
||||
public bool IndependentConsole { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public string TestPlugin { get; set; }
|
||||
|
||||
[Display(Name = "Enable Asserts", Description = "Enable Keen's assert logging.", GroupName = "Server")]
|
||||
public bool EnableAsserts { get; set; }
|
||||
|
||||
[Display(Name = "Enable Entity Manager", Description = "Enable Entity Manager tab. (can affect performance)",
|
||||
GroupName = "Server")]
|
||||
public bool EntityManagerEnabled { get; set; } = true;
|
||||
|
||||
[Display(Name = "Login Token", Description = "Steam GSLT (can be used if you have dynamic ip)", GroupName = "Server")]
|
||||
public string LoginToken { get; set; }
|
||||
|
||||
public UpdateSource UpdateSource { get; set; } = new()
|
||||
{
|
||||
private static Logger _log = LogManager.GetLogger("Config");
|
||||
Repository = "PveTeam/Torch",
|
||||
Url = "https://api.github.com",
|
||||
SourceType = UpdateSourceType.Github
|
||||
};
|
||||
|
||||
public bool ShouldUpdatePlugins => (GetPluginUpdates && !NoUpdate) || ForceUpdate;
|
||||
public bool ShouldUpdateTorch => (GetTorchUpdates && !NoUpdate) || ForceUpdate;
|
||||
[Display(Name = "Packages", Description = "Packages to install and use.", GroupName = "Server")]
|
||||
public List<string> Packages { get; set; } = new();
|
||||
|
||||
private bool _autostart;
|
||||
private bool _restartOnCrash;
|
||||
private bool _noGui;
|
||||
private bool _getPluginUpdates = true;
|
||||
private bool _getTorchUpdates = true;
|
||||
private int _tickTimeout = 60;
|
||||
private bool _localPlugins;
|
||||
private bool _disconnectOnRestart;
|
||||
private string _chatName = "Server";
|
||||
private string _chatColor = "Red";
|
||||
private bool _enableWhitelist = false;
|
||||
private List<ulong> _whitelist = new List<ulong>();
|
||||
private int _windowWidth = 980;
|
||||
private int _windowHeight = 588;
|
||||
private bool _independentConsole = false;
|
||||
private bool _enableAsserts = false;
|
||||
private int _fontSize = 16;
|
||||
private UGCServiceType _ugcServiceType = UGCServiceType.Steam;
|
||||
private bool _entityManagerEnabled = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore, Arg("noupdate", "Disable automatically downloading game and plugin updates.")]
|
||||
public bool NoUpdate { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore, Arg("forceupdate", "Manually check for and install updates.")]
|
||||
public bool ForceUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Permanent flag to ALWAYS automatically start the server
|
||||
/// </summary>
|
||||
[Display(Name = "Auto Start", Description = "Permanent flag to ALWAYS automatically start the server.", GroupName = "Server")]
|
||||
public bool Autostart { get => _autostart; set => Set(value, ref _autostart); }
|
||||
|
||||
/// <summary>
|
||||
/// Temporary flag to automatically start the server only on the next run
|
||||
/// </summary>
|
||||
[Arg("autostart", "Start the server immediately.")]
|
||||
[XmlIgnore]
|
||||
public bool TempAutostart { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("restartoncrash", "Automatically restart the server if it crashes.")]
|
||||
[Display(Name = "Restart On Crash", Description = "Automatically restart the server if it crashes.", GroupName = "Server")]
|
||||
public bool RestartOnCrash { get => _restartOnCrash; set => Set(value, ref _restartOnCrash); }
|
||||
|
||||
public string InstancePath { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("nogui", "Do not show the Torch UI.")]
|
||||
[Display(Name = "No GUI", Description = "Do not show the Torch UI.", GroupName = "Window")]
|
||||
public bool NoGui { get => _noGui; set => Set(value, ref _noGui); }
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore, Arg("waitforpid", "Makes Torch wait for another process to exit.")]
|
||||
public string WaitForPID { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Update Torch", Description = "Check every start for new versions of torch.", GroupName = "Server")]
|
||||
public bool GetTorchUpdates { get => _getTorchUpdates; set => Set(value, ref _getTorchUpdates); }
|
||||
|
||||
public string InstanceName { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Update Plugins", Description = "Check every start for new versions of plugins.", GroupName = "Server")]
|
||||
public bool GetPluginUpdates { get => _getPluginUpdates; set => Set(value, ref _getPluginUpdates); }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Display(Name = "Watchdog Timeout", Description = "Watchdog timeout (in seconds).", GroupName = "Server")]
|
||||
public int TickTimeout { get => _tickTimeout; set => Set(value, ref _tickTimeout); }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("plugins", "Starts Torch with the given plugin GUIDs (space delimited).")]
|
||||
public List<Guid> Plugins { get; set; } = new List<Guid>();
|
||||
|
||||
[Arg("localplugins", "Loads all pluhins from disk, ignores the plugins defined in config.")]
|
||||
[Display(Name = "Local Plugins", Description = "Loads all pluhins from disk, ignores the plugins defined in config.", GroupName = "In-Game")]
|
||||
public bool LocalPlugins { get => _localPlugins; set => Set(value, ref _localPlugins); }
|
||||
|
||||
[Arg("disconnect", "When server restarts, all clients are rejected to main menu to prevent auto rejoin.")]
|
||||
[Display(Name = "Auto Disconnect", Description = "When server restarts, all clients are rejected to main menu to prevent auto rejoin.", GroupName = "In-Game")]
|
||||
public bool DisconnectOnRestart { get => _disconnectOnRestart; set => Set(value, ref _disconnectOnRestart); }
|
||||
|
||||
[Display(Name = "Chat Name", Description = "Default name for chat from gui, broadcasts etc..", GroupName = "In-Game")]
|
||||
public string ChatName { get => _chatName; set => Set(value, ref _chatName); }
|
||||
|
||||
[Display(Name = "Chat Color", Description = "Default color for chat from gui, broadcasts etc.. (Red, Blue, White, Green)", GroupName = "In-Game")]
|
||||
public string ChatColor { get => _chatColor; set => Set(value, ref _chatColor); }
|
||||
|
||||
[Display(Name = "Enable Whitelist", Description = "Enable Whitelist to prevent random players join while maintance, tests or other.", GroupName = "In-Game")]
|
||||
public bool EnableWhitelist { get => _enableWhitelist; set => Set(value, ref _enableWhitelist); }
|
||||
|
||||
[Display(Name = "Whitelist", Description = "Collection of whitelisted steam ids.", GroupName = "In-Game")]
|
||||
public List<ulong> Whitelist { get => _whitelist; set => Set(value, ref _whitelist); }
|
||||
|
||||
[Display(Name = "Width", Description = "Default window width.", GroupName = "Window")]
|
||||
public int WindowWidth { get => _windowWidth; set => Set(value, ref _windowWidth); }
|
||||
|
||||
[Display(Name = "Height", Description = "Default window height", GroupName = "Window")]
|
||||
public int WindowHeight { get => _windowHeight; set => Set(value, ref _windowHeight); }
|
||||
|
||||
[Display(Name = "Font Size", Description = "Font size for logging text box. (default is 16)", GroupName = "Window")]
|
||||
public int FontSize { get => _fontSize; set => Set(value, ref _fontSize); }
|
||||
|
||||
[Display(Name = "UGC Service Type", Description = "Service for downloading mods", GroupName = "Server")]
|
||||
public UGCServiceType UgcServiceType
|
||||
{
|
||||
get => _ugcServiceType;
|
||||
set => Set(value, ref _ugcServiceType);
|
||||
}
|
||||
|
||||
public string LastUsedTheme { get; set; } = "Torch Theme";
|
||||
|
||||
//Prevent reserved players being written to disk, but allow it to be read
|
||||
//remove this when ReservedPlayers is removed
|
||||
private bool ShouldSerializeReservedPlayers() => false;
|
||||
|
||||
[Arg("console", "Keeps a separate console window open after the main UI loads.")]
|
||||
[Display(Name = "Independent Console", Description = "Keeps a separate console window open after the main UI loads.", GroupName = "Window")]
|
||||
public bool IndependentConsole { get => _independentConsole; set => Set(value, ref _independentConsole); }
|
||||
|
||||
[XmlIgnore]
|
||||
[Arg("testplugin", "Path to a plugin to debug. For development use only.")]
|
||||
public string TestPlugin { get; set; }
|
||||
|
||||
[Arg("asserts", "Enable Keen's assert logging.")]
|
||||
[Display(Name = "Enable Asserts", Description = "Enable Keen's assert logging.", GroupName = "Server")]
|
||||
public bool EnableAsserts { get => _enableAsserts; set => Set(value, ref _enableAsserts); }
|
||||
|
||||
[Display(Name = "Enable Entity Manager", Description = "Enable Entity Manager tab. (can affect performance)",
|
||||
GroupName = "Server")]
|
||||
public bool EntityManagerEnabled
|
||||
{
|
||||
get => _entityManagerEnabled;
|
||||
set => Set(value, ref _entityManagerEnabled);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public TorchConfig() { }
|
||||
|
||||
protected void Set<T>(T value, ref T field, [CallerMemberName] string callerName = default)
|
||||
{
|
||||
field = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(callerName));
|
||||
}
|
||||
|
||||
// for backward compatibility
|
||||
public void Save(string path = null) => Initializer.Instance?.ConfigPersistent?.Save(path);
|
||||
}
|
||||
// for backward compatibility
|
||||
public void Save(string path = null) => Initializer.Instance?.ConfigPersistent?.Save(path);
|
||||
}
|
@@ -3,12 +3,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Diagnostics.Runtime;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using PropertyChanged;
|
||||
using Sandbox;
|
||||
@@ -21,8 +21,6 @@ using Torch.API.Session;
|
||||
using Torch.Commands;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Mod;
|
||||
using Torch.Mod.Messages;
|
||||
using Torch.Patches;
|
||||
using Torch.Server.Commands;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
@@ -37,15 +35,9 @@ namespace Torch.Server
|
||||
{
|
||||
public class TorchServer : TorchBase, ITorchServer
|
||||
{
|
||||
private bool _hasRun;
|
||||
private bool _canRun;
|
||||
private TimeSpan _elapsedPlayTime;
|
||||
private bool _isRunning;
|
||||
private float _simRatio;
|
||||
private ServerState _state;
|
||||
private Stopwatch _uptime;
|
||||
private Timer _watchdog;
|
||||
private int _players;
|
||||
private MultiplayerManagerDedicated _multiplayerManagerDedicated;
|
||||
|
||||
internal bool FatalException { get; set; }
|
||||
@@ -55,8 +47,9 @@ namespace Torch.Server
|
||||
|
||||
//Here to trigger rebuild
|
||||
/// <inheritdoc />
|
||||
public TorchServer(ITorchConfig config, string instancePath, string instanceName) : base(config)
|
||||
public TorchServer(ITorchConfig config, string instancePath, string instanceName, IConfiguration configuration) : base(config)
|
||||
{
|
||||
Configuration = configuration;
|
||||
InstancePath = instancePath;
|
||||
InstanceName = instanceName;
|
||||
DedicatedInstance = new InstanceManager(this);
|
||||
@@ -66,14 +59,24 @@ namespace Torch.Server
|
||||
AddManager(new RemoteAPIManager(this));
|
||||
|
||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||
sessionManager.AddFactory(x => new MultiplayerManagerDedicated(this));
|
||||
sessionManager.AddFactory(_ => new MultiplayerManagerDedicated(this));
|
||||
sessionManager.SessionStateChanged += OnSessionStateChanged;
|
||||
|
||||
// Needs to be done at some point after MyVRageWindows.Init
|
||||
// where the debug listeners are registered
|
||||
if (!((TorchConfig)Config).EnableAsserts)
|
||||
MyDebug.Listeners.Clear();
|
||||
|
||||
_simUpdateTimer.Elapsed += SimUpdateElapsed;
|
||||
_simUpdateTimer.Start();
|
||||
|
||||
Console.CancelKeyPress += (_, _) =>
|
||||
{
|
||||
if (State == ServerState.Running)
|
||||
Stop();
|
||||
|
||||
Environment.Exit(0);
|
||||
};
|
||||
}
|
||||
|
||||
private void SimUpdateElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
@@ -85,7 +88,7 @@ namespace Torch.Server
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasRun { get => _hasRun; set => SetValue(ref _hasRun, value); }
|
||||
public bool HasRun { get; set; }
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -104,22 +107,19 @@ namespace Torch.Server
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public TimeSpan ElapsedPlayTime { get => _elapsedPlayTime; set => SetValue(ref _elapsedPlayTime, value); }
|
||||
public TimeSpan ElapsedPlayTime { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Thread GameThread => MySandboxGame.Static?.UpdateThread;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsRunning { get => _isRunning; set => SetValue(ref _isRunning, value); }
|
||||
public bool IsRunning { get; set; }
|
||||
|
||||
public bool CanRun { get => _canRun; set => SetValue(ref _canRun, value); }
|
||||
public bool CanRun { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public InstanceManager DedicatedInstance { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string InstanceName { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override uint SteamAppId => 244850;
|
||||
|
||||
@@ -127,28 +127,56 @@ namespace Torch.Server
|
||||
protected override string SteamAppName => "SpaceEngineersDedicated";
|
||||
|
||||
/// <inheritdoc />
|
||||
public ServerState State { get => _state; private set => SetValue(ref _state, value); }
|
||||
public ServerState State { get; private set; }
|
||||
|
||||
public event Action<ITorchServer> Initialized;
|
||||
private Action<ITorchServer> _initializedEvent;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string InstancePath { get; }
|
||||
public event Action<ITorchServer> Initialized
|
||||
{
|
||||
add
|
||||
{
|
||||
var action = _initializedEvent;
|
||||
Action<ITorchServer> action2;
|
||||
do
|
||||
{
|
||||
action2 = action;
|
||||
var action3 = (Action<ITorchServer>)Delegate.Combine(action2, value);
|
||||
action = Interlocked.CompareExchange(ref _initializedEvent, action3, action2);
|
||||
}
|
||||
while (action != action2);
|
||||
|
||||
public int OnlinePlayers { get => _players; private set => SetValue(ref _players, value); }
|
||||
if (GetManager<InstanceManager>().DedicatedConfig != null)
|
||||
value(this); //if already initialized
|
||||
}
|
||||
remove
|
||||
{
|
||||
var action = _initializedEvent;
|
||||
Action<ITorchServer> action2;
|
||||
do
|
||||
{
|
||||
action2 = action;
|
||||
var action3 = (Action<ITorchServer>)Delegate.Remove(action2, value);
|
||||
action = Interlocked.CompareExchange(ref _initializedEvent, action3, action2);
|
||||
}
|
||||
while (action != action2);
|
||||
}
|
||||
}
|
||||
|
||||
public int OnlinePlayers { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Init()
|
||||
{
|
||||
Log.Info("Initializing server");
|
||||
MySandboxGame.IsDedicated = true;
|
||||
base.Init();
|
||||
Managers.GetManager<ITorchSessionManager>().SessionStateChanged += OnSessionStateChanged;
|
||||
GetManager<InstanceManager>().LoadInstance(InstancePath);
|
||||
CanRun = true;
|
||||
Initialized?.Invoke(this);
|
||||
_initializedEvent?.Invoke(this);
|
||||
Log.Info($"Initialized server '{InstanceName}' at '{InstancePath}'");
|
||||
}
|
||||
|
||||
public override IConfiguration Configuration { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Start()
|
||||
{
|
||||
@@ -217,17 +245,35 @@ namespace Torch.Server
|
||||
new Thread(() =>
|
||||
{
|
||||
StopInternal();
|
||||
var config = (TorchConfig)Config;
|
||||
LogManager.Flush();
|
||||
|
||||
string exe = Assembly.GetExecutingAssembly().Location.Replace("dll", "exe");
|
||||
#if NETFRAMEWORK
|
||||
config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
|
||||
#else
|
||||
config.WaitForPID = Environment.ProcessId.ToString();
|
||||
if (
|
||||
#if DEBUG
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
true ||
|
||||
#endif
|
||||
config.TempAutostart = true;
|
||||
Process.Start(exe, config.ToString());
|
||||
ApplicationContext.Current.IsService
|
||||
)
|
||||
Environment.Exit(0);
|
||||
|
||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (args[i].Contains(' '))
|
||||
args[i] = $"\"{args[i]}\"";
|
||||
|
||||
if (!args[i].Contains("--tempAutostart", StringComparison.InvariantCultureIgnoreCase) &&
|
||||
!args[i].Contains("--waitForPid", StringComparison.InvariantCultureIgnoreCase))
|
||||
continue;
|
||||
|
||||
args[i] = string.Empty;
|
||||
args[++i] = string.Empty;
|
||||
}
|
||||
|
||||
Process.Start(exe, $"--waitForPid {Environment.ProcessId} --tempAutostart true {string.Join(" ", args)}");
|
||||
|
||||
Environment.Exit(0);
|
||||
})
|
||||
@@ -239,21 +285,25 @@ namespace Torch.Server
|
||||
[SuppressPropertyChangedWarnings]
|
||||
private void OnSessionStateChanged(ITorchSession session, TorchSessionState newState)
|
||||
{
|
||||
if (newState == TorchSessionState.Unloading || newState == TorchSessionState.Unloaded)
|
||||
switch (newState)
|
||||
{
|
||||
_watchdog?.Dispose();
|
||||
_watchdog = null;
|
||||
ModCommunication.Unregister();
|
||||
case TorchSessionState.Unloading:
|
||||
_watchdog?.Dispose();
|
||||
_watchdog = null;
|
||||
break;
|
||||
case TorchSessionState.Loaded:
|
||||
_multiplayerManagerDedicated = CurrentSession.Managers.GetManager<MultiplayerManagerDedicated>();
|
||||
_multiplayerManagerDedicated.PlayerJoined += MultiplayerManagerDedicatedOnPlayerJoined;
|
||||
_multiplayerManagerDedicated.PlayerLeft += MultiplayerManagerDedicatedOnPlayerLeft;
|
||||
CurrentSession.Managers.GetManager<CommandManager>().RegisterCommandModule(typeof(WhitelistCommands));
|
||||
break;
|
||||
case TorchSessionState.Loading:
|
||||
case TorchSessionState.Unloaded:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(newState), newState, null);
|
||||
}
|
||||
|
||||
if (newState == TorchSessionState.Loaded)
|
||||
{
|
||||
_multiplayerManagerDedicated = CurrentSession.Managers.GetManager<MultiplayerManagerDedicated>();
|
||||
_multiplayerManagerDedicated.PlayerJoined += MultiplayerManagerDedicatedOnPlayerJoined;
|
||||
_multiplayerManagerDedicated.PlayerLeft += MultiplayerManagerDedicatedOnPlayerLeft;
|
||||
CurrentSession.Managers.GetManager<CommandManager>().RegisterCommandModule(typeof(WhitelistCommands));
|
||||
ModCommunication.Register();
|
||||
}
|
||||
}
|
||||
|
||||
private void MultiplayerManagerDedicatedOnPlayerLeft(IPlayer player)
|
||||
@@ -374,11 +424,8 @@ namespace Torch.Server
|
||||
// return stack.ToString();
|
||||
|
||||
// Modified from https://www.examplefiles.net/cs/579311
|
||||
#if NETFRAMEWORK
|
||||
using var target = DataTarget.CreateSnapshotAndAttach(Process.GetCurrentProcess().Id);
|
||||
#else
|
||||
using var target = DataTarget.CreateSnapshotAndAttach(Environment.ProcessId);
|
||||
#endif
|
||||
|
||||
var runtime = target.ClrVersions[0].CreateRuntime();
|
||||
|
||||
var clrThread = runtime.Threads.First(b => b.ManagedThreadId == thread.ManagedThreadId);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using VRage;
|
||||
@@ -31,13 +32,25 @@ internal class UnhandledExceptionHandler
|
||||
{
|
||||
Console.WriteLine("Restarting in 5 seconds.");
|
||||
Thread.Sleep(5000);
|
||||
var exe = typeof(Program).Assembly.Location;
|
||||
#if NETFRAMEWORK
|
||||
_config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
|
||||
#else
|
||||
_config.WaitForPID = Environment.ProcessId.ToString();
|
||||
#endif
|
||||
Process.Start(exe, _config.ToString());
|
||||
|
||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (args[i].Contains(' '))
|
||||
args[i] = $"\"{args[i]}\"";
|
||||
|
||||
if (!args[i].Contains("--tempAutostart", StringComparison.InvariantCultureIgnoreCase) &&
|
||||
!args[i].Contains("--waitForPid", StringComparison.InvariantCultureIgnoreCase))
|
||||
continue;
|
||||
|
||||
args[i] = string.Empty;
|
||||
args[++i] = string.Empty;
|
||||
}
|
||||
|
||||
Process.Start(exe, $"--waitForPid {Environment.ProcessId} --tempAutostart true {string.Join(" ", args)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Steamworks;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
public class SteamUserViewModel : ViewModel
|
||||
{
|
||||
public string Name { get; }
|
||||
public ulong SteamId { get; }
|
||||
|
||||
public SteamUserViewModel(ulong id)
|
||||
{
|
||||
SteamId = id;
|
||||
Name = SteamFriends.GetFriendPersonaName(new CSteamID(id));
|
||||
}
|
||||
|
||||
public SteamUserViewModel() : this(0) { }
|
||||
}
|
||||
}
|
@@ -15,7 +15,8 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<ScrollViewer CanContentScroll="True" ScrollChanged="ScrollViewer_OnScrollChanged" Loaded="ScrollViewer_OnLoaded" Unloaded="ScrollViewer_OnUnloaded">
|
||||
<ScrollViewer CanContentScroll="True" ScrollChanged="ScrollViewer_OnScrollChanged"
|
||||
Loaded="ScrollViewer_OnLoaded" Unloaded="ScrollViewer_OnUnloaded">
|
||||
<ItemsPresenter />
|
||||
</ScrollViewer>
|
||||
</ControlTemplate>
|
||||
@@ -31,10 +32,6 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type TextBlock}" x:Key="TextBlockBaseStyle">
|
||||
<Setter Property="FontFamily" Value="Consolas" />
|
||||
</Style>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewModels:LogEntry}">
|
||||
<Grid IsSharedSizeScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -43,10 +40,16 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Timestamp, StringFormat=HH:mm:ss.fff}" Grid.Column="0"
|
||||
FontWeight="Bold" Style="{StaticResource TextBlockBaseStyle}" Foreground="{Binding Color}" Margin="5,0,5,0" />
|
||||
FontWeight="Bold" FontFamily="Consolas" Foreground="{Binding Color}" Margin="5,0,5,0" />
|
||||
|
||||
<TextBlock Text="{Binding Message}" Grid.Column="1"
|
||||
TextWrapping="Wrap" Style="{StaticResource TextBlockBaseStyle}" Foreground="{Binding Color}" />
|
||||
<TextBox Grid.Column="1"
|
||||
Text="{Binding Message, Mode=OneWay}"
|
||||
TextWrapping="Wrap"
|
||||
FontFamily="Consolas"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Color}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
|
@@ -22,6 +22,8 @@ using Torch.Collections;
|
||||
using Torch.Server.Annotations;
|
||||
using Torch.Managers;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.Plugins;
|
||||
using Torch.API.WebAPI.Plugin;
|
||||
|
||||
namespace Torch.Server.Views
|
||||
{
|
||||
@@ -55,39 +57,38 @@ namespace Torch.Server.Views
|
||||
InitializeComponent();
|
||||
|
||||
var installedPlugins = pluginManager.Plugins;
|
||||
BindingOperations.EnableCollectionSynchronization(Plugins, _syncLock);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = await PluginQuery.Instance.QueryAll();
|
||||
foreach (var item in res.Plugins.OrderBy(i => i.Name)) {
|
||||
lock (_syncLock)
|
||||
{
|
||||
var pluginItem = item with
|
||||
{
|
||||
Description = item.Description.Replace("<", "<").Replace(">", ">"),
|
||||
Installed = installedPlugins.Keys.Contains(item.Id)
|
||||
};
|
||||
Plugins.Add(pluginItem);
|
||||
PluginsSource.Add(pluginItem);
|
||||
}
|
||||
}
|
||||
|
||||
Dispatcher.Invoke(() => PluginsList.SelectedIndex = 0);
|
||||
CurrentDescription = "Please select a plugin...";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), "An Error Occurred", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Close();
|
||||
throw;
|
||||
}
|
||||
});
|
||||
LoadAsync(installedPlugins);
|
||||
|
||||
MarkdownFlow.CommandBindings.Add(new CommandBinding(NavigationCommands.GoToPage, (sender, e) => OpenUri((string)e.Parameter)));
|
||||
}
|
||||
|
||||
private async void LoadAsync(IReadOnlyDictionary<Guid, ITorchPlugin> installedPlugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = await LegacyPluginQuery.Instance.QueryAll();
|
||||
foreach (var item in res.Plugins.OrderBy(i => i.Name))
|
||||
{
|
||||
var pluginItem = item with
|
||||
{
|
||||
Description = item.Description?.Replace("<", "<").Replace(">", ">") ?? string.Empty,
|
||||
Installed = installedPlugins.Keys.Contains(item.Id)
|
||||
};
|
||||
Plugins.Add(pluginItem);
|
||||
PluginsSource.Add(pluginItem);
|
||||
}
|
||||
|
||||
PluginsList.SelectedIndex = 0;
|
||||
CurrentDescription = "Please select a plugin...";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), "An Error Occurred", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Close();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsValidUri(string uri)
|
||||
{
|
||||
if (!Uri.IsWellFormedUriString(uri, UriKind.Absolute))
|
||||
|
@@ -14,6 +14,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.ComponentModel;
|
||||
using Torch.API.WebAPI.Plugin;
|
||||
|
||||
namespace Torch.Server.Views
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace Torch.Server.Views
|
||||
var PercentChangeOnDownload = 100 / PluginsToDownload.Count;
|
||||
|
||||
foreach (PluginItem PluginItem in PluginsToDownload) {
|
||||
if (!Task.Run(async () => await PluginQuery.Instance.DownloadPlugin(PluginItem.Id)).Result) {
|
||||
if (!LegacyPluginQuery.Instance.DownloadPlugin(PluginItem.Id).Result) {
|
||||
failedDownloads++;
|
||||
DownloadProgress += PercentChangeOnDownload;
|
||||
(sender as BackgroundWorker).ReportProgress(DownloadProgress);
|
||||
|
@@ -71,7 +71,7 @@ namespace Torch.Server.Views
|
||||
private void OpenFolder_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_plugins?.PluginDir != null)
|
||||
Process.Start(_plugins.PluginDir);
|
||||
Process.Start("explorer", _plugins.PluginDir);
|
||||
}
|
||||
|
||||
private void BrowsPlugins_OnClick(object sender, RoutedEventArgs e)
|
||||
|
@@ -116,7 +116,7 @@ namespace Torch.Server
|
||||
if (_server?.State == ServerState.Running)
|
||||
_server.Stop();
|
||||
|
||||
Process.GetCurrentProcess().Kill();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
638
Torch.Server/packages.lock.json
Normal file
638
Torch.Server/packages.lock.json
Normal file
@@ -0,0 +1,638 @@
|
||||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net7.0-windows7.0": {
|
||||
"AutoCompleteTextBox": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.7.2, )",
|
||||
"resolved": "1.7.2",
|
||||
"contentHash": "rslnIhQRK++Ty7epprYj861F8bo2N11TCUOgRs1r9mJ6w9HrhnQnE4zvUVm7xUsq8u5DCxR7cQtbAZ1txS2/Aw=="
|
||||
},
|
||||
"Ben.Demystifier": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.4.1, )",
|
||||
"resolved": "0.4.1",
|
||||
"contentHash": "axFeEMfmEORy3ipAzOXG/lE+KcNptRbei3F0C4kQCdeiQtW+qJW90K5iIovITGrdLt8AjhNCwk5qLSX9/rFpoA==",
|
||||
"dependencies": {
|
||||
"System.Reflection.Metadata": "5.0.0"
|
||||
}
|
||||
},
|
||||
"ControlzEx": {
|
||||
"type": "Direct",
|
||||
"requested": "[5.0.2, )",
|
||||
"resolved": "5.0.2",
|
||||
"contentHash": "f724LoDJ36LxaLR62G4ek9ZAJI8BiiYRJJ04furC/qjXSeIwU0qmHFIe19xB1/FwxyZjevdFguEr9ZUjf3dZgw==",
|
||||
"dependencies": {
|
||||
"Microsoft.Xaml.Behaviors.Wpf": "1.1.31",
|
||||
"System.Text.Json": "5.0.1"
|
||||
}
|
||||
},
|
||||
"MahApps.Metro": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.4.10, )",
|
||||
"resolved": "2.4.10",
|
||||
"contentHash": "45exHKJCVYaD1/rNr3ekZPECEBM4uHOt6aYp6yNaJbliFMUo+d3z8Gi1xG+qEkbiHKITX+dlz+BW1FOsjAbl/w==",
|
||||
"dependencies": {
|
||||
"ControlzEx": "[4.4.0, 6.0.0)"
|
||||
}
|
||||
},
|
||||
"MdXaml": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.22.0, )",
|
||||
"resolved": "1.22.0",
|
||||
"contentHash": "wrt+KlEgAA6XoSLPH7KDFk1efcNGCSfZfbI5XcpR14/VpKaDy/vlnELsZrWQjkUahFpt01jleDHclEsXNvQoCQ==",
|
||||
"dependencies": {
|
||||
"AvalonEdit": "6.0.0",
|
||||
"MdXaml.Plugins": "1.22.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Bcl.AsyncInterfaces": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "3WA9q9yVqJp222P3x1wYIGDAkpjAku0TMUaaQV22g6L67AI0LdOIrVS7Ht2vJfLHGSPVuqN94vIr15qn+HEkHw=="
|
||||
},
|
||||
"Microsoft.Diagnostics.Runtime": {
|
||||
"type": "Direct",
|
||||
"requested": "[3.1.456101, )",
|
||||
"resolved": "3.1.456101",
|
||||
"contentHash": "q9qVj69yeSTVmCsYB9DdIdh6zmYTQoE30wekkyAblijyQQau1P66qJ+KCZiC1mokBSRq2BXfz7PdRkZ+7cEbmQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Diagnostics.NETCore.Client": "0.2.410101",
|
||||
"System.Collections.Immutable": "6.0.0",
|
||||
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.CommandLine": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "NZuZMz3Q8Z780nKX3ifV1fE7lS+6pynDHK71OfU4OZ1ItgvDOhyOC7E6z+JMZrAj63zRpwbdldYFk499t3+1dQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "8.0.0",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "plvZ0ZIpq+97gdPNNvhwvrEZ92kNml9hd1pe3idMA7svR0PztdzVLkoWLcRFgySYXUJc3kSM3Xw3mNFMo/bxRA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "8.0.0",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Xml": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "0iRltfE/Xbh6gs9DHiBMShrxhcpJLtF/+2OqW1OpUh1QLQuAvMy4cGElSeJx1/hF6IbsxYhakVgfCNU0Hsmcwg==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "8.0.0",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "8.0.0",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "8.0.0",
|
||||
"System.Security.Cryptography.Xml": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Logging": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection": "8.0.0",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.Options": "8.0.0"
|
||||
}
|
||||
},
|
||||
"NLog": {
|
||||
"type": "Direct",
|
||||
"requested": "[5.2.7, )",
|
||||
"resolved": "5.2.7",
|
||||
"contentHash": "Ww/0b6V1NL8iqpFKtRKVQFFX03LoowNzYeNG6FpVzmhgCfLAkW0h/4lT3+V8mHfyvtHptNoV8Cz0YePLFRUaPA=="
|
||||
},
|
||||
"nulastudio.NetCoreBeauty": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.2.9.5, )",
|
||||
"resolved": "1.2.9.5",
|
||||
"contentHash": "0w2QtE3ir6z9J4fZpW1s3/V93dnceUmVm/E1ADhbt0WJ8z1Q3UhYe0Z7rXCy7Pl3y+zRQwERSV9N0aBuGABLjw=="
|
||||
},
|
||||
"PropertyChanged.Fody": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.1.0, )",
|
||||
"resolved": "4.1.0",
|
||||
"contentHash": "6v+f9cI8YjnZH2WBHuOqWEAo8DFFNGFIdU8xD3AsL6fhV6Y8oAmVWd7XKk49t8DpeUBwhR/X+97+6Epvek0Y3A==",
|
||||
"dependencies": {
|
||||
"Fody": "6.6.4"
|
||||
}
|
||||
},
|
||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.203.505.1, )",
|
||||
"resolved": "1.203.505.1",
|
||||
"contentHash": "YokcOxKdIvtJ2fYdkF48/wvbdaDlNl+bbUd11vkdPRdHaprRj5b2F1wUk7faL0J0UIX87lyhgC/HsNn9rHVbJw==",
|
||||
"dependencies": {
|
||||
"protobuf-net": "1.0.0"
|
||||
}
|
||||
},
|
||||
"Steamworks.NET": {
|
||||
"type": "Direct",
|
||||
"requested": "[20.1.0, )",
|
||||
"resolved": "20.1.0",
|
||||
"contentHash": "+GntwnyJ5tCNvUIaQxv2+ehDvZJzGUqlSB5xRBk1hTj1qqBJ6s4vK/OfGD/jae7aTmXiGSm8wpJORosNtQevJQ=="
|
||||
},
|
||||
"System.ComponentModel.Annotations": {
|
||||
"type": "Direct",
|
||||
"requested": "[5.0.0, )",
|
||||
"resolved": "5.0.0",
|
||||
"contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg=="
|
||||
},
|
||||
"System.Management": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "jrK22i5LRzxZCfGb+tGmke2VH7oE0DvcDlJ1HAKYU8cPmD8XnpUT0bYn2Gy98GEhGjtfbR/sxKTVb+dE770pfA==",
|
||||
"dependencies": {
|
||||
"System.CodeDom": "8.0.0"
|
||||
}
|
||||
},
|
||||
"AvalonEdit": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "QMbyJrlhOuWzLRPqvW724ly9XbSEkp8Xg2mQY7tvsh1se1pDEJnmDjS6c6OuqDe2Q37uCnXwKdV8tJUx2iLUnw=="
|
||||
},
|
||||
"Fody": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.6.4",
|
||||
"contentHash": "vLZS+oa+ndUHYPlx/8n9bBTT3dHkCF0riml4paKq4D663+cZd47x1uagQo32D/gKFZ/sfmV1oqKaLmH0elxq4A=="
|
||||
},
|
||||
"HarmonyX": {
|
||||
"type": "Transitive",
|
||||
"resolved": "2.10.2-prerelease.6",
|
||||
"contentHash": "CPCUR/t5AQ5DDs40bTJ5OwUVTCoZONaJGbWKKjAOwg7c7Ct4KEbfybH6T+KvRGVjf5eN1oyGY5BN7EfWxUh9Xg==",
|
||||
"dependencies": {
|
||||
"MonoMod.RuntimeDetour": "25.0.0"
|
||||
}
|
||||
},
|
||||
"MdXaml.Plugins": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.22.0",
|
||||
"contentHash": "asC2GP5AsGQZboc1DKSfgQpk1pkvGF8brfdQtLEAweRGcTgbbuzuonVTal4Bhmje4IJWeMF8QBai5lOLEUmUVQ=="
|
||||
},
|
||||
"Microsoft.CodeAnalysis.Analyzers": {
|
||||
"type": "Transitive",
|
||||
"resolved": "3.3.4",
|
||||
"contentHash": "AxkxcPR+rheX0SmvpLVIGLhOUXAKG56a64kV9VQZ4y9gR9ZmPXnqZvHJnmwLSwzrEP6junUF11vuc+aqo5r68g=="
|
||||
},
|
||||
"Microsoft.CodeAnalysis.Common": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.8.0",
|
||||
"contentHash": "/jR+e/9aT+BApoQJABlVCKnnggGQbvGh7BKq2/wI1LamxC+LbzhcLj4Vj7gXCofl1n4E521YfF9w0WcASGg/KA==",
|
||||
"dependencies": {
|
||||
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
|
||||
"System.Collections.Immutable": "7.0.0",
|
||||
"System.Reflection.Metadata": "7.0.0",
|
||||
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.CodeAnalysis.CSharp": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.8.0",
|
||||
"contentHash": "+3+qfdb/aaGD8PZRCrsdobbzGs1m9u119SkkJt8e/mk3xLJz/udLtS2T6nY27OTXxBBw10HzAbC8Z9w08VyP/g==",
|
||||
"dependencies": {
|
||||
"Microsoft.CodeAnalysis.Common": "[4.8.0]"
|
||||
}
|
||||
},
|
||||
"Microsoft.Diagnostics.NETCore.Client": {
|
||||
"type": "Transitive",
|
||||
"resolved": "0.2.410101",
|
||||
"contentHash": "I4hMjlbPcM5R+M4ThD2Zt1z58M8uZnWkDbFLXHntOOAajajEucrw4XYNSaoi5rgoqksgxQ3g388Vof4QzUNwdQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Bcl.AsyncInterfaces": "1.1.0",
|
||||
"Microsoft.Extensions.Logging": "2.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "0J/9YNXTMWSZP2p2+nvl8p71zpSwokZXZuJW+VjdErkegAnFdO1XlqtA62SJtgVYHdKu3uPxJHcMR/r35HwFBA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "3lE/iLSutpgX1CC0NOW70FJoGARRHbyKmG7dc0klnUZ9Dd9hS6N/POPWhKhMLCEuNN5nXEY5agmlFtH562vqhQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Binder": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "mBMoXLsr5s1y2zOHWmKsE9veDcx8h1x/c3rz4baEdQKTeDcmQAPNbB54Pi/lhFO3K431eEq6PFbMgLaa6PHFfA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "McP+Lz/EKwvtCv48z0YImw+L1gi1gy5rHhNaNIY2CrjloV+XY8gydT8DjMR6zWeL13AFK+DioVpppwAuO1Gi1w==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "8.0.0",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.FileProviders.Physical": "8.0.0",
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg=="
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "ZbaMlhJlpisjuWbvXr4LdAst/1XxH3vZ6A0BsgTphZ2L4PGuxRLz7Jr/S7mkAAnOn78Vu0fKhEgNF5JO3zfjqQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Physical": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "UboiXxpPUpwulHvIAVE36Knq0VSHaAmfrFkegLyBZeaADuKezJ/AIXYAW8F5GBlGk/VaibN2k/Zn1ca8YAfVdA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "8.0.0",
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileSystemGlobbing": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "OK+670i7esqlQrPjdIKRbsyMCe9g5kSLpRRQGSr4Q58AOYEe/hCnfLZprh7viNisSUUQZmMrbbuDaIrP+V1ebQ=="
|
||||
},
|
||||
"Microsoft.Extensions.Logging.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Options": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0",
|
||||
"Microsoft.Extensions.Primitives": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Primitives": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g=="
|
||||
},
|
||||
"Microsoft.Xaml.Behaviors.Wpf": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.31",
|
||||
"contentHash": "LZpuf82ACZWldmfMuv3CTUMDh3o0xo0uHUaybR5HgqVLDBJJ9RZLykplQ/bTJd0/VDt3EhD4iDgUgbdIUAM+Kg=="
|
||||
},
|
||||
"Mono.Cecil": {
|
||||
"type": "Transitive",
|
||||
"resolved": "0.11.4",
|
||||
"contentHash": "IC1h5g0NeJGHIUgzM1P82ld57knhP0IcQfrYITDPXlNpMYGUrsG5TxuaWTjaeqDNQMBDNZkB8L0rBnwsY6JHuQ=="
|
||||
},
|
||||
"MonoMod.Backports": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.1",
|
||||
"contentHash": "LWIzLvkkmXlucCWL9gg17WBHhmw9hBpMjiFFBfVKJ4Cova6BLoLqjT+yjZM7RW70ezXJ/ry7zsicvvTV67Hxnw==",
|
||||
"dependencies": {
|
||||
"MonoMod.ILHelpers": "1.0.0"
|
||||
}
|
||||
},
|
||||
"MonoMod.Core": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.1",
|
||||
"contentHash": "VL7d4L+/JU9LR1eXe+Wo2NquCzPExeMorBe23S/7Rn8cydb4Ex+wMpFhnlUfwT9jbLV/TiNbaVGJtR73fBwVCw==",
|
||||
"dependencies": {
|
||||
"Mono.Cecil": "0.11.4",
|
||||
"MonoMod.Backports": "1.0.1",
|
||||
"MonoMod.ILHelpers": "1.0.0",
|
||||
"MonoMod.Utils": "25.0.3"
|
||||
}
|
||||
},
|
||||
"MonoMod.ILHelpers": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0",
|
||||
"contentHash": "dTjGA+dYl7W5yQ0oG/Wr57tsa+ueoFUrwPtz9MZF9iheun4n70u7lge52F8UJi9i0zMHRfS2mAY6+nPuRZHQyQ=="
|
||||
},
|
||||
"MonoMod.RuntimeDetour": {
|
||||
"type": "Transitive",
|
||||
"resolved": "25.0.2",
|
||||
"contentHash": "7HuQGIMMtu9q0PEnJYl7xztT14TmGSP56B4unBYWuZvPgWCZWX9hGOmTm7zDYhwMsjUQcCTl9iiqOlI1+NHVLg==",
|
||||
"dependencies": {
|
||||
"Mono.Cecil": "0.11.4",
|
||||
"MonoMod.Backports": "1.0.1",
|
||||
"MonoMod.Core": "1.0.1",
|
||||
"MonoMod.ILHelpers": "1.0.0",
|
||||
"MonoMod.Utils": "25.0.3"
|
||||
}
|
||||
},
|
||||
"MonoMod.Utils": {
|
||||
"type": "Transitive",
|
||||
"resolved": "25.0.3",
|
||||
"contentHash": "+/lFnYwNB728wnqAzkzCny88Ik++dueJiDAE+mRuMQf8NYHvWhNgLyZQ1VTN4x8iTelQGL1SzaY0I2bBPNNAog==",
|
||||
"dependencies": {
|
||||
"Mono.Cecil": "0.11.4",
|
||||
"MonoMod.Backports": "1.0.1",
|
||||
"MonoMod.ILHelpers": "1.0.0"
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json": {
|
||||
"type": "Transitive",
|
||||
"resolved": "13.0.3",
|
||||
"contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ=="
|
||||
},
|
||||
"NuGet.Commands": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "jTlbIYNXIiO25s/A2UMBHYhLmNm/lJP+/a/X4OJebejnSKmeKjXeCd9NYH+D9y21JMh3eS0khkCpPnLIgdHsCQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "6.0.0",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "6.0.0",
|
||||
"NuGet.Credentials": "6.8.0",
|
||||
"NuGet.ProjectModel": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Common": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "voNZyM5L5s0CCDPU//vXKQke0M8y6kGvG+0Ll6gc/xV7Jh1C3/5OhHRzvekxBS6a9DO/lsFhTZtyCkL6n9lHEw==",
|
||||
"dependencies": {
|
||||
"NuGet.Frameworks": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Configuration": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "FFEoY1L9G+C74HfSYt6epHTIuS5xJ8D+d9LZ5nnqhujMoBlQgHphaCTfRlul+e/bNIkAp1fDObzsGlPmu3CKAg==",
|
||||
"dependencies": {
|
||||
"NuGet.Common": "6.8.0",
|
||||
"System.Security.Cryptography.ProtectedData": "4.4.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Credentials": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "0Cp5iSgmweBKjDbywqNVVlVFCtjmt4z7ol5ED3hjMGNQp1HgthOZ+PSVD2xa+5rf4/in2Nt2/4W938KqreigJg==",
|
||||
"dependencies": {
|
||||
"NuGet.Protocol": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.DependencyResolver.Core": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "dTdE5VmQnWfZU2tM4glgsO1ZpFZoEqLKUtpDkr11dkVV4nQn5/MqK9Wmvp/SbU1t7AoSEf7yIMAew9SHxganYA==",
|
||||
"dependencies": {
|
||||
"NuGet.Configuration": "6.8.0",
|
||||
"NuGet.LibraryModel": "6.8.0",
|
||||
"NuGet.Protocol": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Frameworks": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "cN9NyahKgYYScioH4CKn+TYj1eSODxd0RECFnQt6ZmzT6z7PfXlbYpVzbiPsxNgY23iNDMOVkSmOqNZyYxNlQA=="
|
||||
},
|
||||
"NuGet.LibraryModel": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "qdNqSa1E/VgpY95XJuLtJrSA74XpWCn5iGf/9r7FMa5smSZt7nClHcMrxOalfzilMKl4prUkE7AVw2AvKZ39Mg==",
|
||||
"dependencies": {
|
||||
"NuGet.Common": "6.8.0",
|
||||
"NuGet.Versioning": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Packaging": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "lyDnMCAWtoHNsNKGexIl6yHtyxuvn2j3rpKMrYYf86KwTV+JVY9eFIixNdwEPjBXBzWHQGpDKj9Im8v02t9AQQ==",
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "13.0.3",
|
||||
"NuGet.Configuration": "6.8.0",
|
||||
"NuGet.Versioning": "6.8.0",
|
||||
"System.Security.Cryptography.Pkcs": "6.0.4"
|
||||
}
|
||||
},
|
||||
"NuGet.ProjectModel": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "4lXoQxLn2fAN+Yu9SHLRcjPCXNVj039FMXE9vUm14ZjCk889dGCEbUWtF3PUqqRpMGnp6IckDd8zubvXI4H1cw==",
|
||||
"dependencies": {
|
||||
"NuGet.DependencyResolver.Core": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Protocol": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "Nfvij7QlEevDbuRCXkhCrHk1oJN+mYkmeVzNvS9hxNTmwdtHqB+zhUIMFBlbye3MUicgc4bbtLAwoF+EKjUvcg==",
|
||||
"dependencies": {
|
||||
"NuGet.Packaging": "6.8.0"
|
||||
}
|
||||
},
|
||||
"NuGet.Versioning": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.8.0",
|
||||
"contentHash": "WBu15cdv1lqKkPKXDQOEmEzwKemwrczKYlc2jtuZgRYiZ8TG8F4QzPYiE0Q9eVIpMSk8Aky7mUephf19HjBPOw=="
|
||||
},
|
||||
"protobuf-net": {
|
||||
"type": "Transitive",
|
||||
"resolved": "3.2.30",
|
||||
"contentHash": "C/UTlmxEJHAHpqm8xQK1UyJKaIynVCSNG4mVrbLgnZ7ccH28nN49O8iMJvKEodTgVbnimvy+3mIiAdW6mATwnw==",
|
||||
"dependencies": {
|
||||
"protobuf-net.Core": "3.2.30"
|
||||
}
|
||||
},
|
||||
"protobuf-net.Core": {
|
||||
"type": "Transitive",
|
||||
"resolved": "3.2.30",
|
||||
"contentHash": "v2ZxxYrz+X212ukSx+uqkLuPu414bvmSAnTyf+PBUKR9ENJxO4P/csorA/27456MCp1JNoMssDj/f91RDiwBfQ==",
|
||||
"dependencies": {
|
||||
"System.Collections.Immutable": "7.0.0"
|
||||
}
|
||||
},
|
||||
"SemanticVersioning": {
|
||||
"type": "Transitive",
|
||||
"resolved": "2.0.2",
|
||||
"contentHash": "4EQgYdNZ92SyaO7YFk6olVnebF5V+jrHyMUjvPq89tLeMo8NSfgDF+6Zwq/lgh9j/0yfQp9Lkm0ZA0rUATCZFA=="
|
||||
},
|
||||
"SixLabors.Core": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0-beta0007",
|
||||
"contentHash": "s9aPl6yxwcvoKRD0u0zjkCISZCCifbUi9/XVFjdvlx5Pt7vRYmGV0anq1EEftUjIEHbEu5aNBipbUSBIV2CE7w==",
|
||||
"dependencies": {
|
||||
"System.Runtime.CompilerServices.Unsafe": "4.5.1"
|
||||
}
|
||||
},
|
||||
"System.CodeDom": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "WTlRjL6KWIMr/pAaq3rYqh0TJlzpouaQ/W1eelssHgtlwHAH25jXTkUphTYx9HaIIf7XA6qs/0+YhtLEQRkJ+Q=="
|
||||
},
|
||||
"System.Collections.Immutable": {
|
||||
"type": "Transitive",
|
||||
"resolved": "7.0.0",
|
||||
"contentHash": "dQPcs0U1IKnBdRDBkrCTi1FoajSTBzLcVTpjO4MBCMC7f4pDOIPzgBoX8JjG7X6uZRJ8EBxsi8+DR1JuwjnzOQ=="
|
||||
},
|
||||
"System.Formats.Asn1": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "AJukBuLoe3QeAF+mfaRKQb2dgyrvt340iMBHYv+VdBzCUM06IxGlvl0o/uPOS7lHnXPN6u8fFRHSHudx5aTi8w=="
|
||||
},
|
||||
"System.Linq.Async": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.1",
|
||||
"contentHash": "0YhHcaroWpQ9UCot3Pizah7ryAzQhNvobLMSxeDIGmnXfkQn8u5owvpOH0K6EVB+z9L7u6Cc4W17Br/+jyttEQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Bcl.AsyncInterfaces": "6.0.0"
|
||||
}
|
||||
},
|
||||
"System.Reflection.Metadata": {
|
||||
"type": "Transitive",
|
||||
"resolved": "7.0.0",
|
||||
"contentHash": "MclTG61lsD9sYdpNz9xsKBzjsmsfCtcMZYXz/IUr2zlhaTaABonlr1ESeompTgM+Xk+IwtGYU7/voh3YWB/fWw==",
|
||||
"dependencies": {
|
||||
"System.Collections.Immutable": "7.0.0"
|
||||
}
|
||||
},
|
||||
"System.Runtime.CompilerServices.Unsafe": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
|
||||
},
|
||||
"System.Security.Cryptography.Pkcs": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "ULmp3xoOwNYjOYp4JZ2NK/6NdTgiN1GQXzVVN1njQ7LOZ0d0B9vyMnhyqbIi9Qw4JXj1JgCsitkTShboHRx7Eg==",
|
||||
"dependencies": {
|
||||
"System.Formats.Asn1": "8.0.0"
|
||||
}
|
||||
},
|
||||
"System.Security.Cryptography.ProtectedData": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.4.0",
|
||||
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
|
||||
},
|
||||
"System.Security.Cryptography.Xml": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "HQSFbakswZ1OXFz2Bt3AJlC6ENDqWeVpgqhf213xqQUMDifzydOHIKVb1RV4prayobvR3ETIScMaQdDF2hwGZA==",
|
||||
"dependencies": {
|
||||
"System.Security.Cryptography.Pkcs": "8.0.0"
|
||||
}
|
||||
},
|
||||
"System.Text.Encodings.Web": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
|
||||
},
|
||||
"System.Text.Json": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==",
|
||||
"dependencies": {
|
||||
"System.Text.Encodings.Web": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Torch.SixLabors.ImageSharp": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0-beta6",
|
||||
"contentHash": "WJ7ocT79HgmuKi0+ltpvXTiMI80UcI3DeS8XSfYwJtTB1tcQws6zLPGuUwra6qe6qRrFfpABeDP3xvHV1rJgfg==",
|
||||
"dependencies": {
|
||||
"SixLabors.Core": "1.0.0-beta0007",
|
||||
"System.Runtime.CompilerServices.Unsafe": "4.5.1"
|
||||
}
|
||||
},
|
||||
"torch": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"ControlzEx": "[5.0.2, )",
|
||||
"HarmonyX": "[2.10.2-prerelease.6, )",
|
||||
"MahApps.Metro": "[2.4.10, )",
|
||||
"Microsoft.CodeAnalysis.CSharp": "[4.8.0, )",
|
||||
"Microsoft.CodeAnalysis.Common": "[4.8.0, )",
|
||||
"MonoMod.RuntimeDetour": "[25.0.2, )",
|
||||
"NLog": "[5.2.7, )",
|
||||
"System.ComponentModel.Annotations": "[5.0.0, )",
|
||||
"Torch.API": "[1.0.0, )",
|
||||
"Torch.SixLabors.ImageSharp": "[1.0.0-beta6, )",
|
||||
"protobuf-net": "[3.2.30, )"
|
||||
}
|
||||
},
|
||||
"torch.api": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration.Binder": "[8.0.0, )",
|
||||
"NLog": "[5.2.7, )",
|
||||
"NuGet.Commands": "[6.8.0, )",
|
||||
"NuGet.DependencyResolver.Core": "[6.8.0, )",
|
||||
"SemanticVersioning": "[2.0.2, )",
|
||||
"System.Linq.Async": "[6.0.1, )",
|
||||
"System.Text.Json": "[8.0.0, )"
|
||||
}
|
||||
}
|
||||
},
|
||||
"net7.0-windows7.0/win-x64": {
|
||||
"Steamworks.NET": {
|
||||
"type": "Direct",
|
||||
"requested": "[20.1.0, )",
|
||||
"resolved": "20.1.0",
|
||||
"contentHash": "+GntwnyJ5tCNvUIaQxv2+ehDvZJzGUqlSB5xRBk1hTj1qqBJ6s4vK/OfGD/jae7aTmXiGSm8wpJORosNtQevJQ=="
|
||||
},
|
||||
"System.Management": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "jrK22i5LRzxZCfGb+tGmke2VH7oE0DvcDlJ1HAKYU8cPmD8XnpUT0bYn2Gy98GEhGjtfbR/sxKTVb+dE770pfA==",
|
||||
"dependencies": {
|
||||
"System.CodeDom": "8.0.0"
|
||||
}
|
||||
},
|
||||
"System.Security.Cryptography.Pkcs": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "ULmp3xoOwNYjOYp4JZ2NK/6NdTgiN1GQXzVVN1njQ7LOZ0d0B9vyMnhyqbIi9Qw4JXj1JgCsitkTShboHRx7Eg==",
|
||||
"dependencies": {
|
||||
"System.Formats.Asn1": "8.0.0"
|
||||
}
|
||||
},
|
||||
"System.Security.Cryptography.ProtectedData": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.4.0",
|
||||
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
|
||||
},
|
||||
"System.Text.Encodings.Web": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<NoWarn>1591,0649</NoWarn>
|
||||
<AssemblyTitle>Torch Tests</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
@@ -9,23 +7,15 @@
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<OutputPath>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(Configuration) == 'Release'">
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\Torch.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="xunit" Version="2.6.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
|
2228
Torch.Tests/packages.lock.json
Normal file
2228
Torch.Tests/packages.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,6 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7AD02A71-1D4C-48F9-A8C1-789A5512424F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
NLog.config = NLog.config
|
||||
Jenkinsfile = Jenkinsfile
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Tests", "Torch.Tests\Torch.Tests.csproj", "{C3C8B671-6AD1-44AA-A8DA-E0C0DC0FEDF5}"
|
||||
@@ -21,6 +20,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Server.Tests", "Torch
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Torch.Mod", "Torch.Mod\Torch.Mod.shproj", "{3CE4D2E9-B461-4F19-8233-F87E0DFDDD74}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI/CD workflows", "CI/CD workflows", "{DFC9AB6D-BD21-4748-8CE8-57097DC673AF}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\workflows\release.yaml = .github\workflows\release.yaml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
Torch.Mod\Torch.Mod.projitems*{3ce4d2e9-b461-4f19-8233-f87e0dfddd74}*SharedItemsImports = 13
|
||||
@@ -52,6 +56,7 @@ Global
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{DFC9AB6D-BD21-4748-8CE8-57097DC673AF} = {7AD02A71-1D4C-48F9-A8C1-789A5512424F}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BB51D91F-958D-4B63-A897-3C40642ACD3E}
|
||||
|
@@ -1,138 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
|
||||
namespace Torch
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class that adds tools for setting type properties through the command line.
|
||||
/// </summary>
|
||||
public abstract class CommandLine
|
||||
{
|
||||
private readonly string _argPrefix;
|
||||
private readonly Dictionary<ArgAttribute, PropertyInfo> _args = new Dictionary<ArgAttribute, PropertyInfo>();
|
||||
private readonly Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected CommandLine(string argPrefix = "-")
|
||||
{
|
||||
_argPrefix = argPrefix;
|
||||
foreach (var prop in GetType().GetProperties())
|
||||
{
|
||||
var attr = prop.GetCustomAttribute<ArgAttribute>();
|
||||
if (attr == null)
|
||||
continue;
|
||||
_args.Add(attr, prop);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHelp()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
foreach (var property in _args)
|
||||
{
|
||||
var attr = property.Key;
|
||||
sb.AppendLine($"{_argPrefix}{attr.Name.PadRight(24)}{attr.Description}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var args = new List<string>();
|
||||
foreach (var prop in _args)
|
||||
{
|
||||
var attr = prop.Key;
|
||||
if (prop.Value.PropertyType == typeof(bool) && (bool)prop.Value.GetValue(this))
|
||||
{
|
||||
args.Add($"{_argPrefix}{attr.Name}");
|
||||
}
|
||||
else if (prop.Value.PropertyType == typeof(string))
|
||||
{
|
||||
var str = (string)prop.Value.GetValue(this);
|
||||
if (string.IsNullOrEmpty(str))
|
||||
continue;
|
||||
args.Add($"{_argPrefix}{attr.Name} \"{str}\"");
|
||||
}
|
||||
}
|
||||
|
||||
return string.Join(" ", args);
|
||||
}
|
||||
|
||||
public bool Parse(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
return true;
|
||||
|
||||
if (args[0] == $"{_argPrefix}help")
|
||||
{
|
||||
Console.WriteLine(GetHelp());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (!args[i].StartsWith(_argPrefix))
|
||||
continue;
|
||||
|
||||
foreach (var property in _args)
|
||||
{
|
||||
var argName = property.Key.Name;
|
||||
if (argName == null)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
if (string.Compare(argName, 0, args[i], 1, argName.Length, StringComparison.InvariantCultureIgnoreCase) == 0)
|
||||
{
|
||||
if (property.Value.PropertyType == typeof(bool))
|
||||
property.Value.SetValue(this, true);
|
||||
|
||||
if (property.Value.PropertyType == typeof(string))
|
||||
property.Value.SetValue(this, args[++i]);
|
||||
|
||||
if (property.Value.PropertyType == typeof(List<Guid>))
|
||||
{
|
||||
i++;
|
||||
var l = new List<Guid>(16);
|
||||
while (i < args.Length && !args[i].StartsWith(_argPrefix))
|
||||
{
|
||||
if (Guid.TryParse(args[i], out Guid g))
|
||||
{
|
||||
l.Add(g);
|
||||
_log.Info($"added plugin {g}");
|
||||
}
|
||||
else
|
||||
_log.Warn($"Failed to parse GUID {args[i]}");
|
||||
i++;
|
||||
}
|
||||
property.Value.SetValue(this, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"Error parsing arg {argName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public class ArgAttribute : Attribute
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public ArgAttribute(string name, string description)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,7 +11,6 @@ using System.Timers;
|
||||
using NLog;
|
||||
using Sandbox.Game.Multiplayer;
|
||||
using Sandbox.ModAPI;
|
||||
using Steamworks;
|
||||
using Torch;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
|
@@ -27,6 +27,7 @@ using VRage.Game.ModAPI;
|
||||
using VRage.Groups;
|
||||
using VRage.ModAPI;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.ObjectBuilders.Private;
|
||||
using VRage.Sync;
|
||||
using VRageMath;
|
||||
|
||||
@@ -45,14 +46,14 @@ namespace Torch.Managers
|
||||
{
|
||||
var ob = grid.GetObjectBuilder(true);
|
||||
using (var f = File.Open(path, FileMode.CreateNew))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, ob);
|
||||
MyObjectBuilderSerializerKeen.SerializeXML(f, ob);
|
||||
}
|
||||
|
||||
public void ImportGrid(string path, Vector3D position)
|
||||
{
|
||||
MyObjectBuilder_EntityBase gridOb;
|
||||
using (var f = File.OpenRead(path))
|
||||
MyObjectBuilderSerializer.DeserializeXML(f, out gridOb);
|
||||
MyObjectBuilderSerializerKeen.DeserializeXML(f, out gridOb);
|
||||
|
||||
var grid = MyEntities.CreateFromObjectBuilderParallel(gridOb);
|
||||
grid.PositionComp.SetPosition(position);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
@@ -9,7 +10,7 @@ using Torch.API;
|
||||
|
||||
namespace Torch.Managers
|
||||
{
|
||||
public class FilesystemManager : Manager
|
||||
public partial class FilesystemManager : Manager
|
||||
{
|
||||
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
||||
/// <summary>
|
||||
@@ -51,19 +52,31 @@ namespace Torch.Managers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the given file (if it exists) to a temporary directory that will be cleared the next time the application starts.
|
||||
/// </summary>
|
||||
public void SoftDelete(string path, string file)
|
||||
{
|
||||
string source = Path.Combine(path, file);
|
||||
var source = Path.Combine(path, file);
|
||||
if (!File.Exists(source))
|
||||
return;
|
||||
var rand = Path.GetRandomFileName();
|
||||
var dest = Path.Combine(TempDirectory, rand);
|
||||
File.Move(source, rand);
|
||||
string rsource = Path.Combine(path, rand);
|
||||
File.Move(rsource, dest);
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(source);
|
||||
}
|
||||
catch (Exception e) when (e is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
var tempFilePath = Path.Combine(path, file + ".old");
|
||||
if (File.Exists(tempFilePath))
|
||||
File.Delete(tempFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
File.Move(source, tempFilePath);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,46 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using MonoMod.Cil;
|
||||
using MonoMod.RuntimeDetour;
|
||||
using HarmonyLib;
|
||||
using MonoMod.Utils;
|
||||
using MonoMod.Utils.Cil;
|
||||
using NLog;
|
||||
using Torch.Managers.PatchManager.MSIL;
|
||||
using Torch.Managers.PatchManager.Transpile;
|
||||
using Torch.Utils;
|
||||
|
||||
namespace Torch.Managers.PatchManager
|
||||
{
|
||||
internal class DecoratedMethod : MethodRewritePattern
|
||||
{
|
||||
private static Action<ILHook, bool> IsAppliedSetter;
|
||||
|
||||
[ReflectedMethodInfo(typeof(MethodBase), nameof(MethodBase.GetMethodFromHandle), Parameters = new[] {typeof(RuntimeMethodHandle)})]
|
||||
private static MethodInfo _getMethodFromHandle = null!;
|
||||
|
||||
[ReflectedMethodInfo(typeof(MethodBase), nameof(MethodBase.GetMethodFromHandle), Parameters = new[] {typeof(RuntimeMethodHandle), typeof(RuntimeTypeHandle)})]
|
||||
private static MethodInfo _getMethodFromHandleGeneric = null!;
|
||||
private static readonly ConcurrentDictionary<MethodBase, DecoratedMethod> Methods = new();
|
||||
|
||||
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
||||
private readonly MethodBase _method;
|
||||
private readonly Harmony _harmony;
|
||||
|
||||
private ILHook _hook;
|
||||
private readonly PatchProcessor _processor;
|
||||
private bool _hasRan;
|
||||
|
||||
internal DecoratedMethod(MethodBase method) : base(null)
|
||||
internal DecoratedMethod(MethodBase method, Harmony harmony) : base(null)
|
||||
{
|
||||
_method = method;
|
||||
if (IsAppliedSetter == null)
|
||||
{
|
||||
IsAppliedSetter = typeof(ILHook).GetProperty(nameof(ILHook.IsApplied)).CreateSetter<ILHook, bool>();
|
||||
}
|
||||
_harmony = harmony;
|
||||
_processor = harmony.CreateProcessor(method);
|
||||
Methods[method] = this;
|
||||
}
|
||||
|
||||
internal bool HasChanged()
|
||||
@@ -62,31 +50,25 @@ namespace Torch.Managers.PatchManager
|
||||
_log.Log(PrintMode != 0 ? LogLevel.Info : LogLevel.Debug,
|
||||
$"Begin patching {_method.DeclaringType?.FullName}#{_method.Name}({string.Join(", ", _method.GetParameters().Select(x => x.ParameterType.Name))})");
|
||||
|
||||
if (_hook == null)
|
||||
_hook = new ILHook(_method, Manipulator, new ILHookConfig {ManualApply = true});
|
||||
IsAppliedSetter(_hook, false);
|
||||
try
|
||||
foreach (var prefix in Prefixes)
|
||||
{
|
||||
_hook.Apply();
|
||||
_processor.AddPrefix(prefix);
|
||||
}
|
||||
catch (InvalidProgramException e)
|
||||
{
|
||||
IsAppliedSetter(_hook, false);
|
||||
PrintMode = PrintModeEnum.Emitted | PrintModeEnum.Original;
|
||||
try
|
||||
{
|
||||
_hook.Apply();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore, we are already know there is an error in IL
|
||||
}
|
||||
|
||||
throw;
|
||||
foreach (var suffix in Suffixes)
|
||||
{
|
||||
_processor.AddPostfix(suffix);
|
||||
}
|
||||
|
||||
if (Transpilers.Any() || PostTranspilers.Any())
|
||||
_processor.AddTranspiler(SymbolExtensions.GetMethodInfo(() => TranspilerProxy(null, null, null)));
|
||||
|
||||
_processor.Patch();
|
||||
|
||||
_log.Log(PrintMode != 0 ? LogLevel.Info : LogLevel.Debug,
|
||||
$"Done patching {_method.GetID()})");
|
||||
|
||||
_hasRan = true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -95,332 +77,40 @@ namespace Torch.Managers.PatchManager
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<CodeInstruction> TranspilerProxy(IEnumerable<CodeInstruction> instructions,
|
||||
MethodBase __originalMethod,
|
||||
ILGenerator generator)
|
||||
{
|
||||
if (!Methods.TryGetValue(__originalMethod, out var decoratedMethod))
|
||||
throw new Exception($"Unknown method {__originalMethod.GetID()}");
|
||||
|
||||
var loggingGenerator = new LoggingIlGenerator(generator, decoratedMethod.PrintMode != 0 ? LogLevel.Info : LogLevel.Debug);
|
||||
|
||||
MsilLocal LocalFactory(Type type) => new(loggingGenerator.DeclareLocal(type));
|
||||
|
||||
foreach (var transpiler in decoratedMethod.Transpilers.Concat(decoratedMethod.PostTranspilers))
|
||||
{
|
||||
var ins = (IEnumerable<MsilInstruction>) transpiler.Invoke(null, transpiler.GetParameters().Select<ParameterInfo, object>(b => b switch
|
||||
{
|
||||
_ when b.ParameterType.IsAssignableTo(typeof(MethodBase)) => __originalMethod,
|
||||
_ when b.ParameterType.IsAssignableTo(typeof(IEnumerable<MsilInstruction>)) => instructions.Select(c => new MsilInstruction(c)),
|
||||
_ when b.ParameterType.IsAssignableTo(typeof(Func<Type, MsilLocal>)) => new Func<Type, MsilLocal>(LocalFactory),
|
||||
_ => null
|
||||
}).ToArray());
|
||||
|
||||
instructions = ins!.Select(b => b.ToCodeIns(loggingGenerator)).ToList();
|
||||
}
|
||||
|
||||
return instructions;
|
||||
}
|
||||
|
||||
internal void Revert()
|
||||
{
|
||||
if (_hook == null)
|
||||
if (!_hasRan)
|
||||
return;
|
||||
|
||||
_log.Debug($"Revert {_method.GetID()}");
|
||||
_hook.Dispose();
|
||||
_hook = null;
|
||||
_processor.Unpatch(HarmonyPatchType.All, _harmony.Id);
|
||||
}
|
||||
|
||||
#region Create
|
||||
|
||||
public const string INSTANCE_PARAMETER = "__instance";
|
||||
public const string RESULT_PARAMETER = "__result";
|
||||
public const string PREFIX_SKIPPED_PARAMETER = "__prefixSkipped";
|
||||
public const string ORIGINAL_PARAMETER = "__original";
|
||||
public const string LOCAL_PARAMETER = "__local";
|
||||
|
||||
private void SavePatchedMethod(string target)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
// var asmBuilder =
|
||||
// AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("SomeName"), AssemblyBuilderAccess.RunAndSave, Path.GetDirectoryName(target));
|
||||
// var moduleBuilder = asmBuilder.DefineDynamicModule(Path.GetFileNameWithoutExtension(target), Path.GetFileName(target));
|
||||
// var typeBuilder = moduleBuilder.DefineType("Test", TypeAttributes.Public);
|
||||
//
|
||||
//
|
||||
// var methodName = _method.Name + $"_{_patchSalt}";
|
||||
// var returnType = _method is MethodInfo meth ? meth.ReturnType : typeof(void);
|
||||
// var parameters = _method.GetParameters();
|
||||
// var parameterTypes = (_method.IsStatic ? Enumerable.Empty<Type>() : new[] {_method.DeclaringType})
|
||||
// .Concat(parameters.Select(x => x.ParameterType)).ToArray();
|
||||
//
|
||||
// var patchMethod = typeBuilder.DefineMethod(methodName, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard,
|
||||
// returnType, parameterTypes);
|
||||
// if (!_method.IsStatic)
|
||||
// patchMethod.DefineParameter(0, ParameterAttributes.None, INSTANCE_PARAMETER);
|
||||
// for (var i = 0; i < parameters.Length; i++)
|
||||
// patchMethod.DefineParameter((patchMethod.IsStatic ? 0 : 1) + i, parameters[i].Attributes, parameters[i].Name);
|
||||
//
|
||||
// var generator = new LoggingIlGenerator(patchMethod.GetILGenerator(), LogLevel.Trace);
|
||||
// List<MsilInstruction> il = EmitPatched((type, pinned) => new MsilLocal(generator.DeclareLocal(type, pinned))).ToList();
|
||||
//
|
||||
// MethodTranspiler.EmitMethod(il, generator);
|
||||
//
|
||||
// Type res = typeBuilder.CreateType();
|
||||
// asmBuilder.Save(Path.GetFileName(target));
|
||||
// foreach (var method in res.GetMethods(BindingFlags.Public | BindingFlags.Static))
|
||||
// _log.Info($"Information " + method);
|
||||
}
|
||||
|
||||
public void Manipulator(ILContext context)
|
||||
{
|
||||
context.IL.Clear();
|
||||
var generator = new LoggingIlGenerator(new CecilILGenerator(context.IL),
|
||||
PrintMode.HasFlag(PrintModeEnum.EmittedReflection) ? LogLevel.Info : LogLevel.Trace);
|
||||
List<MsilInstruction> il = EmitPatched((type, pinned) => new MsilLocal(generator.DeclareLocal(type, pinned))).ToList();
|
||||
|
||||
var dumpTarget = DumpTarget != null ? File.CreateText(DumpTarget) : null;
|
||||
try
|
||||
{
|
||||
const string gap = "\n\n\n\n\n";
|
||||
|
||||
void LogTarget(PrintModeEnum mode, bool err, string msg)
|
||||
{
|
||||
if (DumpMode.HasFlag(mode))
|
||||
dumpTarget?.WriteLine((err ? "ERROR " : "") + msg);
|
||||
if (!PrintMode.HasFlag(mode)) return;
|
||||
if (err)
|
||||
_log.Error(msg);
|
||||
else
|
||||
_log.Info(msg);
|
||||
}
|
||||
|
||||
#pragma warning disable CS0612
|
||||
if (PrintMsil || DumpTarget != null)
|
||||
#pragma warning restore CS0612
|
||||
{
|
||||
lock (_log)
|
||||
{
|
||||
var ctx = new MethodContext(_method);
|
||||
ctx.Read();
|
||||
LogTarget(PrintModeEnum.Original, false, "========== Original method ==========");
|
||||
MethodTranspiler.IntegrityAnalysis((a, b) => LogTarget(PrintModeEnum.Original, a, b), ctx.Instructions, true);
|
||||
LogTarget(PrintModeEnum.Original, false, gap);
|
||||
|
||||
LogTarget(PrintModeEnum.Emitted, false, "========== Desired method ==========");
|
||||
MethodTranspiler.IntegrityAnalysis((a, b) => LogTarget(PrintModeEnum.Emitted, a, b), il);
|
||||
LogTarget(PrintModeEnum.Emitted, false, gap);
|
||||
// If the method is invalid the program is likely to hard crash in EmitMethod or Compile, so flush the log
|
||||
LogManager.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
MethodTranspiler.EmitMethod(il, generator);
|
||||
|
||||
#pragma warning disable CS0612
|
||||
if (PrintMsil || DumpTarget != null)
|
||||
#pragma warning restore CS0612
|
||||
{
|
||||
lock (_log)
|
||||
{
|
||||
var instructions = context.Body.Instructions
|
||||
.Select(b => b.ToMsilInstruction()).ToList();
|
||||
LogTarget(PrintModeEnum.Patched, false, "========== Patched method ==========");
|
||||
MethodTranspiler.IntegrityAnalysis((a, b) => LogTarget(PrintModeEnum.Patched, a, b), instructions, true);
|
||||
LogTarget(PrintModeEnum.Patched, false, gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
dumpTarget?.Close();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Emit
|
||||
|
||||
private IEnumerable<MsilInstruction> EmitPatched(Func<Type, bool, MsilLocal> declareLocal)
|
||||
{
|
||||
var methodBody = _method.GetMethodBody();
|
||||
Debug.Assert(methodBody != null, "Method body is null");
|
||||
foreach (var localVar in methodBody.LocalVariables)
|
||||
{
|
||||
Debug.Assert(localVar.LocalType != null);
|
||||
declareLocal(localVar.LocalType, localVar.IsPinned);
|
||||
}
|
||||
|
||||
var instructions = new List<MsilInstruction>();
|
||||
var specialVariables = new Dictionary<string, MsilLocal>();
|
||||
|
||||
var labelAfterOriginalContent = new MsilLabel();
|
||||
var labelSkipMethodContent = new MsilLabel();
|
||||
|
||||
|
||||
Type returnType = _method is MethodInfo meth ? meth.ReturnType : typeof(void);
|
||||
MsilLocal resultVariable = null;
|
||||
if (returnType != typeof(void))
|
||||
{
|
||||
if (Prefixes.Concat(Suffixes).SelectMany(x => x.GetParameters()).Any(x => x.Name == RESULT_PARAMETER)
|
||||
|| Prefixes.Any(x => x.ReturnType == typeof(bool)))
|
||||
resultVariable = declareLocal(returnType, false);
|
||||
}
|
||||
|
||||
if (resultVariable != null)
|
||||
instructions.AddRange(resultVariable.SetToDefault());
|
||||
MsilLocal prefixSkippedVariable = null;
|
||||
if (Prefixes.Count > 0 && Suffixes.Any(x => x.GetParameters()
|
||||
.Any(y => y.Name.Equals(PREFIX_SKIPPED_PARAMETER))))
|
||||
{
|
||||
prefixSkippedVariable = declareLocal(typeof(bool), false);
|
||||
specialVariables.Add(PREFIX_SKIPPED_PARAMETER, prefixSkippedVariable);
|
||||
}
|
||||
|
||||
if (resultVariable != null)
|
||||
specialVariables.Add(RESULT_PARAMETER, resultVariable);
|
||||
|
||||
// Create special variables
|
||||
foreach (var m in Prefixes.Concat(Suffixes))
|
||||
foreach (var param in m.GetParameters())
|
||||
if (param.Name.StartsWith(LOCAL_PARAMETER))
|
||||
{
|
||||
var requiredType = param.ParameterType.IsByRef ? param.ParameterType.GetElementType() : param.ParameterType;
|
||||
if (specialVariables.TryGetValue(param.Name, out var existingParam))
|
||||
{
|
||||
if (existingParam.Type != requiredType)
|
||||
throw new ArgumentException(
|
||||
$"Trying to use injected local {param.Name} for {m.DeclaringType?.FullName}#{m.ToString()} with type {requiredType} but a local with the same name already exists with type {existingParam.Type}",
|
||||
param.Name);
|
||||
}
|
||||
else
|
||||
specialVariables.Add(param.Name, declareLocal(requiredType, false));
|
||||
}
|
||||
|
||||
foreach (MethodInfo prefix in Prefixes)
|
||||
{
|
||||
instructions.AddRange(EmitMonkeyCall(prefix, specialVariables));
|
||||
if (prefix.ReturnType == typeof(bool))
|
||||
instructions.Add(new MsilInstruction(OpCodes.Brfalse).InlineTarget(labelSkipMethodContent));
|
||||
else if (prefix.ReturnType != typeof(void))
|
||||
throw new PatchException(
|
||||
$"Prefixes must return void or bool. {prefix.DeclaringType?.FullName}.{prefix.Name} returns {prefix.ReturnType}", prefix);
|
||||
}
|
||||
|
||||
instructions.AddRange(MethodTranspiler.Transpile(_method, (x) => declareLocal(x, false), Transpilers, labelAfterOriginalContent));
|
||||
|
||||
instructions.Add(new MsilInstruction(OpCodes.Nop).LabelWith(labelAfterOriginalContent));
|
||||
if (resultVariable != null)
|
||||
instructions.Add(new MsilInstruction(OpCodes.Stloc).InlineValue(resultVariable));
|
||||
var notSkip = new MsilLabel();
|
||||
instructions.Add(new MsilInstruction(OpCodes.Br).InlineTarget(notSkip));
|
||||
instructions.Add(new MsilInstruction(OpCodes.Nop).LabelWith(labelSkipMethodContent));
|
||||
if (prefixSkippedVariable != null)
|
||||
{
|
||||
instructions.Add(new MsilInstruction(OpCodes.Ldc_I4_1));
|
||||
instructions.Add(new MsilInstruction(OpCodes.Stloc).InlineValue(prefixSkippedVariable));
|
||||
}
|
||||
|
||||
instructions.Add(new MsilInstruction(OpCodes.Nop).LabelWith(notSkip));
|
||||
|
||||
foreach (MethodInfo suffix in Suffixes)
|
||||
{
|
||||
instructions.AddRange(EmitMonkeyCall(suffix, specialVariables));
|
||||
if (suffix.ReturnType != typeof(void))
|
||||
throw new PatchException($"Suffixes must return void. {suffix.DeclaringType?.FullName}.{suffix.Name} returns {suffix.ReturnType}", suffix);
|
||||
}
|
||||
|
||||
if (resultVariable != null)
|
||||
instructions.Add(new MsilInstruction(OpCodes.Ldloc).InlineValue(resultVariable));
|
||||
instructions.Add(new MsilInstruction(OpCodes.Ret));
|
||||
|
||||
var result = MethodTranspiler.Transpile(_method, instructions, (x) => declareLocal(x, false), PostTranspilers, null).ToList();
|
||||
if (result.Last().OpCode != OpCodes.Ret)
|
||||
result.Add(new MsilInstruction(OpCodes.Ret));
|
||||
return result;
|
||||
}
|
||||
|
||||
private IEnumerable<MsilInstruction> EmitMonkeyCall(MethodInfo patch,
|
||||
IReadOnlyDictionary<string, MsilLocal> specialVariables)
|
||||
{
|
||||
foreach (var param in patch.GetParameters())
|
||||
{
|
||||
switch (param.Name)
|
||||
{
|
||||
case INSTANCE_PARAMETER:
|
||||
{
|
||||
if (_method.IsStatic)
|
||||
throw new PatchException("Can't use an instance parameter for a static method", _method);
|
||||
yield return new MsilInstruction(OpCodes.Ldarg_0);
|
||||
break;
|
||||
}
|
||||
case ORIGINAL_PARAMETER:
|
||||
{
|
||||
if (!typeof(MethodBase).IsAssignableFrom(param.ParameterType))
|
||||
throw new PatchException($"Original parameter should be assignable to {nameof(MethodBase)}",
|
||||
_method);
|
||||
yield return new MsilInstruction(OpCodes.Ldtoken).InlineValue(_method);
|
||||
if (_method.DeclaringType!.ContainsGenericParameters)
|
||||
{
|
||||
yield return new MsilInstruction(OpCodes.Ldtoken).InlineValue(_method.DeclaringType);
|
||||
yield return new MsilInstruction(OpCodes.Call).InlineValue(_getMethodFromHandleGeneric);
|
||||
}
|
||||
else
|
||||
yield return new MsilInstruction(OpCodes.Call).InlineValue(_getMethodFromHandle);
|
||||
|
||||
if (param.ParameterType != typeof(MethodBase))
|
||||
yield return new MsilInstruction(OpCodes.Castclass).InlineValue(param.ParameterType);
|
||||
break;
|
||||
}
|
||||
case PREFIX_SKIPPED_PARAMETER:
|
||||
{
|
||||
if (param.ParameterType != typeof(bool))
|
||||
throw new PatchException($"Prefix skipped parameter {param.ParameterType} must be of type bool", _method);
|
||||
if (param.ParameterType.IsByRef || param.IsOut)
|
||||
throw new PatchException($"Prefix skipped parameter {param.ParameterType} can't be a reference type", _method);
|
||||
if (specialVariables.TryGetValue(PREFIX_SKIPPED_PARAMETER, out MsilLocal prefixSkip))
|
||||
yield return new MsilInstruction(OpCodes.Ldloc).InlineValue(prefixSkip);
|
||||
else
|
||||
yield return new MsilInstruction(OpCodes.Ldc_I4_0);
|
||||
break;
|
||||
}
|
||||
case RESULT_PARAMETER:
|
||||
{
|
||||
var retType = param.ParameterType.IsByRef
|
||||
? param.ParameterType.GetElementType()
|
||||
: param.ParameterType;
|
||||
if (retType == null || !retType.IsAssignableFrom(specialVariables[RESULT_PARAMETER].Type))
|
||||
throw new PatchException(
|
||||
$"Return type {specialVariables[RESULT_PARAMETER].Type} can't be assigned to result parameter type {retType}", _method);
|
||||
yield return new MsilInstruction(param.ParameterType.IsByRef ? OpCodes.Ldloca : OpCodes.Ldloc)
|
||||
.InlineValue(specialVariables[RESULT_PARAMETER]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (specialVariables.TryGetValue(param.Name, out var specialVar))
|
||||
{
|
||||
yield return new MsilInstruction(param.ParameterType.IsByRef ? OpCodes.Ldloca : OpCodes.Ldloc)
|
||||
.InlineValue(specialVar);
|
||||
break;
|
||||
}
|
||||
|
||||
if (param.Name.StartsWith("__field_"))
|
||||
{
|
||||
var fieldName = param.Name.Substring(8);
|
||||
var fieldDef = _method.DeclaringType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).FirstOrDefault(x => x.Name == fieldName);
|
||||
if (fieldDef == null) throw new PatchException($"Could not find field {fieldName}", _method);
|
||||
if (fieldDef.IsStatic)
|
||||
yield return new MsilInstruction(param.ParameterType.IsByRef ? OpCodes.Ldsflda : OpCodes.Ldsfld)
|
||||
.InlineValue(fieldDef);
|
||||
else
|
||||
{
|
||||
yield return new MsilInstruction(OpCodes.Ldarg_0);
|
||||
yield return new MsilInstruction(param.ParameterType.IsByRef ? OpCodes.Ldflda : OpCodes.Ldfld)
|
||||
.InlineValue(fieldDef);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ParameterInfo declParam = _method.GetParameters().FirstOrDefault(x => x.Name == param.Name);
|
||||
|
||||
if (declParam == null)
|
||||
throw new PatchException($"Parameter name {param.Name} not found", _method);
|
||||
int paramIdx = (_method.IsStatic ? 0 : 1) + declParam.Position;
|
||||
|
||||
bool patchByRef = param.IsOut || param.ParameterType.IsByRef;
|
||||
bool declByRef = declParam.IsOut || declParam.ParameterType.IsByRef;
|
||||
if (patchByRef == declByRef)
|
||||
yield return new MsilInstruction(OpCodes.Ldarg).InlineValue(new MsilArgument(paramIdx));
|
||||
else if (patchByRef)
|
||||
yield return new MsilInstruction(OpCodes.Ldarga).InlineValue(new MsilArgument(paramIdx));
|
||||
else
|
||||
{
|
||||
yield return new MsilInstruction(OpCodes.Ldarg).InlineValue(new MsilArgument(paramIdx));
|
||||
yield return EmitExtensions.EmitDereference(declParam.ParameterType);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yield return new MsilInstruction(OpCodes.Call).InlineValue(patch);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -7,6 +7,7 @@ using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Windows.Documents;
|
||||
using HarmonyLib;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using MonoMod.Utils;
|
||||
@@ -89,6 +90,94 @@ namespace Torch.Managers.PatchManager.MSIL
|
||||
}
|
||||
}
|
||||
|
||||
public MsilInstruction(CodeInstruction instruction) : this(instruction.opcode)
|
||||
{
|
||||
switch (instruction.operand)
|
||||
{
|
||||
case LocalBuilder builder when Operand is MsilOperandInline.MsilOperandLocal operandLocal:
|
||||
operandLocal.Value = new(builder);
|
||||
break;
|
||||
case MethodBase methodBase when Operand is MsilOperandInline.MsilOperandReflected<MethodBase> operandMethod:
|
||||
operandMethod.Value = methodBase;
|
||||
break;
|
||||
case Type type when Operand is MsilOperandInline.MsilOperandReflected<Type> operandType:
|
||||
operandType.Value = type;
|
||||
break;
|
||||
case MemberInfo info when Operand is MsilOperandInline.MsilOperandReflected<MemberInfo> operandMember:
|
||||
operandMember.Value = info;
|
||||
break;
|
||||
case IEnumerable<Label> labels when Operand is MsilOperandSwitch operandSwitch:
|
||||
operandSwitch.Labels = labels.Select(b => new MsilLabel(b)).ToArray();
|
||||
break;
|
||||
case float single when Operand is MsilOperandInline.MsilOperandSingle operandSingle:
|
||||
operandSingle.Value = single;
|
||||
break;
|
||||
case FieldInfo fieldInfo when Operand is MsilOperandInline.MsilOperandReflected<FieldInfo> operandField:
|
||||
operandField.Value = fieldInfo;
|
||||
break;
|
||||
case string str when Operand is MsilOperandInline.MsilOperandString operandString:
|
||||
operandString.Value = str;
|
||||
break;
|
||||
case SignatureHelper signatureHelper when Operand is MsilOperandInline.MsilOperandSignature operandSignature:
|
||||
operandSignature.Value = signatureHelper;
|
||||
break;
|
||||
case int int32 when Operand is MsilOperandInline.MsilOperandInt32 operandInt32:
|
||||
operandInt32.Value = int32;
|
||||
break;
|
||||
case long int64 when Operand is MsilOperandInline.MsilOperandInt64 operandInt64:
|
||||
operandInt64.Value = int64;
|
||||
break;
|
||||
case Label label when Operand is MsilOperandBrTarget operandBrTarget:
|
||||
operandBrTarget.Target = new(label);
|
||||
break;
|
||||
case double @double when Operand is MsilOperandInline.MsilOperandDouble operandDouble:
|
||||
operandDouble.Value = @double;
|
||||
break;
|
||||
case byte @byte when Operand is MsilOperandInline.MsilOperandArgument operandArgument:
|
||||
operandArgument.Value = new(@byte);
|
||||
break;
|
||||
case byte @byte when Operand is MsilOperandInline.MsilOperandLocal operandArgument:
|
||||
operandArgument.Value = new(@byte);
|
||||
break;
|
||||
}
|
||||
|
||||
Labels = instruction.labels.Select(b => new MsilLabel(b)).ToHashSet();
|
||||
TryCatchOperations =
|
||||
instruction.blocks.Select(
|
||||
b => new MsilTryCatchOperation((MsilTryCatchOperationType)b.blockType, b.catchType == typeof(object) ? null : b.catchType)).ToList();
|
||||
}
|
||||
|
||||
internal CodeInstruction ToCodeIns(LoggingIlGenerator generator)
|
||||
{
|
||||
var ins = new CodeInstruction(OpCode, Operand switch
|
||||
{
|
||||
MsilOperandBrTarget msilOperandBrTarget => msilOperandBrTarget.Target.LabelFor(generator),
|
||||
MsilOperandInline.MsilOperandReflected<MethodBase> msilOperandReflected => msilOperandReflected.Value,
|
||||
MsilOperandInline.MsilOperandReflected<MemberInfo> msilOperandReflected => msilOperandReflected.Value,
|
||||
MsilOperandInline.MsilOperandReflected<FieldInfo> msilOperandReflected => msilOperandReflected.Value,
|
||||
MsilOperandInline.MsilOperandReflected<Type> msilOperandReflected => msilOperandReflected.Value,
|
||||
MsilOperandInline.MsilOperandDouble msilOperandDouble => msilOperandDouble.Value,
|
||||
MsilOperandInline.MsilOperandInt32 msilOperandInt32 => msilOperandInt32.Value,
|
||||
MsilOperandInline.MsilOperandInt64 msilOperandInt64 => msilOperandInt64.Value,
|
||||
MsilOperandInline.MsilOperandLocal msilOperandLocal when OpCode.OperandType == OperandType.InlineVar => msilOperandLocal.Value.Local,
|
||||
MsilOperandInline.MsilOperandLocal msilOperandLocal when OpCode.OperandType == OperandType.ShortInlineVar => (byte)msilOperandLocal.Value.Index,
|
||||
MsilOperandInline.MsilOperandArgument msilOperandArgument when OpCode.OperandType == OperandType.InlineVar => msilOperandArgument.Value,
|
||||
MsilOperandInline.MsilOperandArgument msilOperandArgument when OpCode.OperandType == OperandType.ShortInlineVar => (byte)msilOperandArgument.Value.Position,
|
||||
MsilOperandInline.MsilOperandSignature msilOperandSignature => msilOperandSignature.Value,
|
||||
MsilOperandInline.MsilOperandSingle msilOperandSingle => msilOperandSingle.Value,
|
||||
MsilOperandInline.MsilOperandString msilOperandString => msilOperandString.Value,
|
||||
MsilOperandSwitch msilOperandSwitch => msilOperandSwitch.Labels.Select(b => b.LabelFor(generator)).ToArray(),
|
||||
_ => null
|
||||
})
|
||||
{
|
||||
labels = Labels.Select(b => b.LabelFor(generator)).ToList(),
|
||||
blocks = TryCatchOperations.Select(b => new ExceptionBlock((ExceptionBlockType)b.Type, b.CatchType))
|
||||
.ToList()
|
||||
};
|
||||
|
||||
return ins;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opcode of this instruction
|
||||
/// </summary>
|
||||
|
@@ -13,14 +13,14 @@ namespace Torch.Managers.PatchManager.MSIL
|
||||
private readonly List<KeyValuePair<WeakReference<LoggingIlGenerator>, Label>> _labelInstances =
|
||||
new List<KeyValuePair<WeakReference<LoggingIlGenerator>, Label>>();
|
||||
|
||||
private readonly Label? _overrideLabel;
|
||||
internal readonly Label? OverrideLabel;
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty label the allocates a new <see cref="Label" /> when requested.
|
||||
/// </summary>
|
||||
public MsilLabel()
|
||||
{
|
||||
_overrideLabel = null;
|
||||
OverrideLabel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,7 +28,7 @@ namespace Torch.Managers.PatchManager.MSIL
|
||||
/// </summary>
|
||||
public MsilLabel(Label overrideLabel)
|
||||
{
|
||||
_overrideLabel = overrideLabel;
|
||||
OverrideLabel = overrideLabel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,8 +46,8 @@ namespace Torch.Managers.PatchManager.MSIL
|
||||
|
||||
internal Label LabelFor(LoggingIlGenerator gen)
|
||||
{
|
||||
if (_overrideLabel.HasValue)
|
||||
return _overrideLabel.Value;
|
||||
if (OverrideLabel.HasValue)
|
||||
return OverrideLabel.Value;
|
||||
foreach (KeyValuePair<WeakReference<LoggingIlGenerator>, Label> kv in _labelInstances)
|
||||
if (kv.Key.TryGetTarget(out LoggingIlGenerator gen2) && gen2 == gen)
|
||||
return kv.Value;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user