Merge remote-tracking branch 'deathcradle/otapi3' into otapi3

This commit is contained in:
Lucas Nicodemus 2021-12-07 21:06:48 -08:00
commit c62fca5353
28 changed files with 577 additions and 695 deletions

View file

@ -1,66 +0,0 @@
name: Build Server
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
mode: ["Debug", "Release"]
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
submodules: recursive
- name: Install NuGet client
uses: nuget/setup-nuget@v1
- name: Restore NuGet packages
run: |
nuget restore .\TerrariaServerAPI\TShock.4.OTAPI.sln
nuget restore TShock.sln
- name: Build OTAPI
shell: cmd
run: |
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" .\TerrariaServerAPI\TShock.4.OTAPI.sln /p:Configuration=${{ matrix.mode }}
cd .\TerrariaServerAPI\TShock.Modifications.Bootstrapper\bin\${{ matrix.mode }}
TShock.Modifications.Bootstrapper.exe
- name: Build TerrariaServerAPI
shell: cmd
run: |
cd .\TerrariaServerAPI
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" .\TerrariaServerAPI\TerrariaServerAPI.csproj /p:Configuration=${{ matrix.mode }}
- name: Build TShock
shell: cmd
run: |
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" .\TShockAPI\TShockAPI.csproj /p:Configuration=${{ matrix.mode }}
- name: Normalize release packaging
shell: cmd
run: |
xcopy /Y prebuilts\*.* TShockAPI\bin\${{ matrix.mode }}
mkdir TShockAPI\bin\${{ matrix.mode }}\ServerPlugins
move TShockAPI\bin\${{ matrix.mode }}\TShockAPI.dll TShockAPI\bin\${{ matrix.mode }}\ServerPlugins
- name: Upload TShock (Debug)
if: contains(matrix.mode, 'Debug')
uses: actions/upload-artifact@master
with:
name: Experimental TShock (debug)
path: TShockAPI\bin\Debug
- name: Upload OTAPI Bootstrapper (Debug)
if: contains(matrix.mode, 'Debug')
uses: actions/upload-artifact@master
with:
name: Experimental (debug) OTAPI Bootstrapper
path: .\TerrariaServerAPI\TShock.Modifications.Bootstrapper\bin\Debug\TShock.Modifications.Bootstrapper.exe
- name: Upload TShock (Not Debug)
if: contains(matrix.mode, 'Release')
uses: actions/upload-artifact@master
with:
name: Experimental TShock (not debug)
path: TShockAPI\bin\Release
- name: Upload OTAPI Bootstrapper (Not Debug)
if: contains(matrix.mode, 'Release')
uses: actions/upload-artifact@master
with:
name: Experimental (not debug) OTAPI Bootstrapper
path: .\TerrariaServerAPI\TShock.Modifications.Bootstrapper\bin\Release\TShock.Modifications.Bootstrapper.exe

59
.github/workflows/ci-otapi3.yml vendored Normal file
View file

@ -0,0 +1,59 @@
name: CI(OTAPI3)
on: [push]
jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.100'
- name: MonoMod dev build
run: dotnet nuget add source https://pkgs.dev.azure.com/MonoMod/MonoMod/_packaging/DevBuilds%40Local/nuget/v3/index.json -n DevBuilds@Local
- name: Run tests
run: dotnet test
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["win-x64", "osx-x64", "linux-x64", "linux-arm64", "linux-arm"]
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.100'
- name: MonoMod dev build
run: dotnet nuget add source https://pkgs.dev.azure.com/MonoMod/MonoMod/_packaging/DevBuilds%40Local/nuget/v3/index.json -n DevBuilds@Local
- name: Produce build
run: |
cd TShockLauncher
dotnet publish -r ${{ matrix.arch }} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained true
- name: Chmod scripts
if: ${{ matrix.arch != 'win-x64' }}
run: |
chmod +x TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/TShock.sh
# preserve file perms: https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files
- name: Archive artifact
run: tar -cvf TShock-Beta-${{ matrix.arch }}-Release.tar TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/
- uses: actions/upload-artifact@v2
with:
name: TShock-Beta-${{ matrix.arch }}-Release
path: TShock-Beta-${{ matrix.arch }}-Release.tar

86
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,86 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/TShock.Run.dll",
"windows": {
"program": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/TShock.dll",
},
"args": [],
"cwd": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/",
"console": "integratedTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
},
{
// this command assumes you have:
// raspberry pi 4 b with default user/pass, SSH enabled & connected to a reliable connection
// dotnet sdk 6.0.100 (needed for breakpoints to hit)
// windows with putty installed
// vsdbg
// follow this for other OS's: https://docs.microsoft.com/en-us/dotnet/iot/debugging?tabs=self-contained&pivots=vscode
// TODO: ability to chmod +x TShock.sh && chmod +x bin/TShock.Run
"name": ".NET Remote Launch - Self-contained",
"type": "coreclr",
"request": "launch",
"program": "/home/pi/dotnet/dotnet",
"args": [
"bin/TShock.Run.dll"
],
"cwd": "/home/pi/tshockdev/publish",
"stopAtEntry": false,
"console": "integratedTerminal",
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "C:\\Program Files\\PuTTY\\PLINK.EXE",
"pipeArgs": [
"-pw",
"raspberry",
"pi@raspberrypi"
],
"debuggerPath": "/home/pi/vsdbg/vsdbg"
}
},
{
// this command assumes you have:
// raspberry pi 4 b with default user/pass, SSH enabled & connected to a reliable connection
// dotnet sdk 6.0.100 (needed for breakpoints to hit)
// windows with putty installed
// vsdbg
// follow this for other OS's: https://docs.microsoft.com/en-us/dotnet/iot/debugging?tabs=self-contained&pivots=vscode
// TODO: ability to chmod +x TShock.sh && chmod +x bin/TShock.Run
"name": ".NET Remote Publish & Launch - Self-contained",
"type": "coreclr",
"request": "launch",
"program": "/home/pi/dotnet/dotnet",
"args": [
"bin/TShock.Run.dll"
],
"cwd": "/home/pi/tshockdev/publish",
"stopAtEntry": false,
"console": "integratedTerminal",
"preLaunchTask": "Remote Publish",
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "C:\\Program Files\\PuTTY\\PLINK.EXE",
"pipeArgs": [
"-pw",
"raspberry",
"pi@raspberrypi"
],
"debuggerPath": "/home/pi/vsdbg/vsdbg"
}
}
]
}

56
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,56 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TShock.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "Publish",
"options": {
"cwd": "TShockLauncher"
},
"command": "dotnet",
"type": "process",
"args": [
"publish",
"-c",
"Debug",
"--self-contained",
"true",
"-r",
"linux-arm64",
"/nowarn:CS1591",
"/nowarn:CS1587"
],
},
{
"label": "Remote Publish",
"options": {
"cwd": "TShockLauncher/bin/Debug/net6.0/linux-arm64"
},
"command": "C:\\Program Files\\PuTTY\\pscp.exe",
"type": "process",
"args": [
"-pw",
"raspberry",
"-sftp",
"-p",
"-r",
"publish",
"pi@raspberrypi:/home/pi/tshockdev"
],
"dependsOn": [
"Publish"
]
}
]
}

View file

@ -1,13 +1,17 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio Version 17
VisualStudioVersion = 14.0.25420.1 VisualStudioVersion = 17.0.31825.309
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServerAPI", "TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj", "{6877506E-ADC6-4142-98A6-79E4FA02855A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TerrariaServerAPI", "TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj", "{6877506E-ADC6-4142-98A6-79E4FA02855A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TShockLauncher", "TShockLauncher\TShockLauncher.csproj", "{2A312452-A43F-43E3-8AEB-E22F9A35C210}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TShockLauncher.Tests", "TShockLauncher.Tests\TShockLauncher.Tests.csproj", "{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,10 +19,6 @@ Global
Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86 Debug|x86 = Debug|x86
Mono|Any CPU = Mono|Any CPU
Mono|Mixed Platforms = Mono|Mixed Platforms
Mono|x64 = Mono|x64
Mono|x86 = Mono|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms Release|Mixed Platforms = Release|Mixed Platforms
Release|x64 = Release|x64 Release|x64 = Release|x64
@ -32,14 +32,7 @@ Global
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|x64.ActiveCfg = Debug|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Debug|x64.ActiveCfg = Debug|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|x64.Build.0 = Debug|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Debug|x64.Build.0 = Debug|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|x86.ActiveCfg = Debug|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Debug|x86.ActiveCfg = Debug|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Any CPU.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Debug|x86.Build.0 = Debug|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Any CPU.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Mixed Platforms.ActiveCfg = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Mixed Platforms.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x64.ActiveCfg = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x64.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x86.ActiveCfg = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x86.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Any CPU.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Any CPU.Build.0 = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|Any CPU.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -47,31 +40,62 @@ Global
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x64.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|x64.ActiveCfg = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x64.Build.0 = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|x64.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.ActiveCfg = Debug|x86 {49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.Build.0 = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.Build.0 = Debug|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.ActiveCfg = Debug|x64 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.Build.0 = Debug|x64 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.ActiveCfg = Debug|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.ActiveCfg = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.Build.0 = Debug|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.Build.0 = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Any CPU.ActiveCfg = Mono|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.ActiveCfg = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Mixed Platforms.ActiveCfg = Mono|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.Build.0 = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Mixed Platforms.Build.0 = Mono|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x64.ActiveCfg = Mono|x64 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.Build.0 = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x64.Build.0 = Mono|x64 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x86.ActiveCfg = Mono|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x86.Build.0 = Mono|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.ActiveCfg = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.ActiveCfg = Release|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.Build.0 = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.ActiveCfg = Release|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.ActiveCfg = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.Build.0 = Release|x86 {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.Build.0 = Release|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.ActiveCfg = Release|x64 {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.Build.0 = Release|x64 {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.ActiveCfg = Release|x86 {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.Build.0 = Release|x86 {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|x64.ActiveCfg = Debug|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|x64.Build.0 = Debug|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|x86.ActiveCfg = Debug|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|x86.Build.0 = Debug|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|Any CPU.Build.0 = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|x64.ActiveCfg = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|x64.Build.0 = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|x86.ActiveCfg = Release|Any CPU
{2A312452-A43F-43E3-8AEB-E22F9A35C210}.Release|x86.Build.0 = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|x64.ActiveCfg = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|x64.Build.0 = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|x86.ActiveCfg = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Debug|x86.Build.0 = Debug|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|Any CPU.Build.0 = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|x64.ActiveCfg = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|x64.Build.0 = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|x86.ActiveCfg = Release|Any CPU
{90AB47F3-8220-48FC-BDAB-D6E97BFDA51B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B56F0765-BADD-48CF-8A19-436BD0EAD34A}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = Terraria.vsmdi CategoryFile = Terraria.vsmdi
EndGlobalSection EndGlobalSection

View file

@ -22,7 +22,6 @@ using Terraria.ID;
using TShockAPI.Net; using TShockAPI.Net;
using Terraria; using Terraria;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using OTAPI.Tile;
using TShockAPI.Localization; using TShockAPI.Localization;
using static TShockAPI.GetDataHandlers; using static TShockAPI.GetDataHandlers;
using Terraria.ObjectData; using Terraria.ObjectData;

View file

@ -33,7 +33,6 @@ using TerrariaApi.Server;
using TShockAPI.Hooks; using TShockAPI.Hooks;
using Terraria.GameContent.Events; using Terraria.GameContent.Events;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using OTAPI.Tile;
using TShockAPI.Localization; using TShockAPI.Localization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Terraria.DataStructures; using Terraria.DataStructures;

View file

@ -34,7 +34,6 @@ using Terraria.DataStructures;
using Terraria.GameContent.Tile_Entities; using Terraria.GameContent.Tile_Entities;
using Terraria.Localization; using Terraria.Localization;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using OTAPI.Tile;
using TShockAPI.Localization; using TShockAPI.Localization;
using TShockAPI.Models; using TShockAPI.Models;
using TShockAPI.Models.PlayerUpdate; using TShockAPI.Models.PlayerUpdate;

View file

@ -1,6 +1,4 @@
using OTAPI.Tile; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View file

@ -23,7 +23,6 @@ using TShockAPI.DB;
using TShockAPI.Net; using TShockAPI.Net;
using Terraria; using Terraria;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using OTAPI.Tile;
using TShockAPI.Localization; using TShockAPI.Localization;
using static TShockAPI.GetDataHandlers; using static TShockAPI.GetDataHandlers;
using TerrariaApi.Server; using TerrariaApi.Server;

View file

@ -1,57 +0,0 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011-2019 Pryaxis & TShock Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TShock for Terraria")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Re-Logic, Pryaxis & TShock Contributors")]
[assembly: AssemblyProduct("TShockAPI")]
[assembly: AssemblyCopyright("Copyright © Re-Logic, Pryaxis & TShock Contributors 2011-2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("01e38989-993c-410c-9011-487f824a606d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Starting in version 4.2.5, we are no longer including the fourth decimal
// location, which previously held the date and time.
// Also, be sure to release on github with the exact assembly version tag as below
// so that the update manager works correctly (via the Github releases api and mimic)
[assembly: AssemblyVersion("4.5.12")]
[assembly: AssemblyFileVersion("4.5.12")]

View file

@ -25,7 +25,6 @@ using System.IO;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Timers; using System.Timers;
using OTAPI.Tile;
using Terraria; using Terraria;
using Terraria.DataStructures; using Terraria.DataStructures;
using Terraria.ID; using Terraria.ID;

View file

@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using OTAPI.Tile;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Terraria; using Terraria;

View file

@ -28,7 +28,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using MaxMind; using MaxMind;
using Mono.Data.Sqlite; using System.Data.SQLite;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Newtonsoft.Json; using Newtonsoft.Json;
using Rests; using Rests;
@ -45,6 +45,7 @@ using TShockAPI.CLI;
using TShockAPI.Localization; using TShockAPI.Localization;
using TShockAPI.Configuration; using TShockAPI.Configuration;
using Terraria.GameContent.Creative; using Terraria.GameContent.Creative;
using System.Runtime.InteropServices;
namespace TShockAPI namespace TShockAPI
{ {
@ -190,6 +191,55 @@ namespace TShockAPI
instance = this; instance = this;
} }
static Dictionary<string, IntPtr> _nativeCache = new Dictionary<string, IntPtr>();
static IntPtr ResolveNativeDep(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
{
if (_nativeCache.TryGetValue(libraryName, out IntPtr cached))
return cached;
IEnumerable<string> matches = Enumerable.Empty<string>();
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var osx = Path.Combine(Environment.CurrentDirectory, "runtimes", "osx-x64");
if(Directory.Exists(osx))
matches = Directory.GetFiles(osx, "*" + libraryName + "*", SearchOption.AllDirectories);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
var lib64 = Path.Combine(Environment.CurrentDirectory, "runtimes", "linux-x64");
if (Directory.Exists(lib64))
matches = Directory.GetFiles(lib64, "*" + libraryName + "*", SearchOption.AllDirectories);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var x64 = Path.Combine(Environment.CurrentDirectory, "runtimes", "win-x64");
if (Directory.Exists(x64))
matches = Directory.GetFiles(x64, "*" + libraryName + "*", SearchOption.AllDirectories);
}
if (matches.Count() == 0)
{
matches = Directory.GetFiles(Environment.CurrentDirectory, "*" + libraryName + "*");
}
Debug.WriteLine($"Looking for `{libraryName}` with {matches.Count()} match(es)");
var handle = IntPtr.Zero;
if (matches.Count() == 1)
{
var match = matches.Single();
handle = NativeLibrary.Load(match);
}
// cache either way. if zero, no point calling IO if we've checked this assembly before.
_nativeCache.Add(libraryName, handle);
return handle;
}
/// <summary>Initialize - Called by the TerrariaServerAPI during initialization.</summary> /// <summary>Initialize - Called by the TerrariaServerAPI during initialization.</summary>
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public override void Initialize() public override void Initialize()
@ -197,18 +247,18 @@ namespace TShockAPI
string logFilename; string logFilename;
string logPathSetupWarning; string logPathSetupWarning;
OTAPI.Hooks.Net.Socket.Create = () => OTAPI.Hooks.Netplay.CreateTcpListener += (sender, args) =>
{ {
//Console.WriteLine($"Creating socket {nameof(LinuxTcpSocket)}"); args.Result = new LinuxTcpSocket();
return new LinuxTcpSocket();
//return new OTAPI.Sockets.PoolSocket();
//return new Terraria.Net.Sockets.TcpSocket();
}; };
OTAPI.Hooks.Player.Announce = (int playerId) => OTAPI.Hooks.NetMessage.PlayerAnnounce += (sender, args) =>
{ {
//TShock handles this //TShock handles this
return OTAPI.HookResult.Cancel; args.Result = OTAPI.HookResult.Cancel;
}; };
// if sqlite.interop cannot be found, try and search the runtimes folder. this usually happens when debugging tsapi
// since it does not have the dependency installed directly
NativeLibrary.SetDllImportResolver(typeof(SQLiteConnection).Assembly, ResolveNativeDep);
Main.SettingsUnlock_WorldEvil = true; Main.SettingsUnlock_WorldEvil = true;
@ -269,7 +319,7 @@ namespace TShockAPI
{ {
string sql = Path.Combine(SavePath, Config.Settings.SqliteDBPath); string sql = Path.Combine(SavePath, Config.Settings.SqliteDBPath);
Directory.CreateDirectory(Path.GetDirectoryName(sql)); Directory.CreateDirectory(Path.GetDirectoryName(sql));
DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); DB = new SQLiteConnection(string.Format("Data Source={0},Version=3", sql));
} }
else if (Config.Settings.StorageType.ToLower() == "mysql") else if (Config.Settings.StorageType.ToLower() == "mysql")
{ {

View file

@ -1,242 +1,47 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{49606449-072B-4CF5-8088-AA49DA586694}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <TargetFramework>net6.0</TargetFramework>
<RootNamespace>TShockAPI</RootNamespace>
<AssemblyName>TShockAPI</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\Debug\TShockAPI.XML</DocumentationFile> <GenerateDocumentationFile>True</GenerateDocumentationFile>
<PlatformTarget>x86</PlatformTarget> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Prefer32Bit>false</Prefer32Bit> <PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
</PropertyGroup> <!--
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> Version information for an assembly consists of the following four values:
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> Major Version
<OutputPath>bin\Release\</OutputPath> Minor Version
<DefineConstants>TRACE;COMPAT_SIGS</DefineConstants> Build Number
<ErrorReport>prompt</ErrorReport> Starting in version 4.2.5, we are no longer including the fourth decimal
<WarningLevel>4</WarningLevel> location, which previously held the date and time.
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\Release\TShockAPI.XML</DocumentationFile> Also, be sure to release on github with the exact assembly version tag as below
<PlatformTarget>x86</PlatformTarget> so that the update manager works correctly (via the Github releases api and mimic)
<Prefer32Bit>false</Prefer32Bit> -->
<Version>4.5.7-beta</Version>
<AssemblyTitle>TShock for Terraria</AssemblyTitle>
<Company>Pryaxis &amp; TShock Contributors</Company>
<Product>TShockAPI</Product>
<Copyright>Copyright © Pryaxis &amp; TShock Contributors 2011-2021</Copyright>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.2" />
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BCrypt.Net, Version=0.1.4141.31969, Culture=neutral, PublicKeyToken=f3bc8f8c31beeb49, processorArchitecture=MSIL">
<HintPath>..\packages\BCrypt.Net.0.1.0\lib\net35\BCrypt.Net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="HttpServer"> <Reference Include="HttpServer">
<HintPath>..\prebuilts\HttpServer.dll</HintPath> <HintPath>..\prebuilts\HttpServer.dll</HintPath>
</Reference> </Reference>
<Reference Include="Mono.Data.Sqlite">
<HintPath>..\prebuilts\Mono.Data.Sqlite.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.6.9.8\lib\net45\MySql.Data.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="OTAPI">
<SpecificVersion>False</SpecificVersion>
<HintPath Condition="Exists('..\TerrariaServerAPI\TerrariaServerAPI\bin\$(ConfigurationName)\OTAPI.dll')">..\TerrariaServerAPI\TerrariaServerAPI\bin\$(ConfigurationName)\OTAPI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="BackupManager.cs" />
<Compile Include="CLI\CommandLineParser.cs" />
<Compile Include="CLI\FlagSet.cs" />
<Compile Include="Configuration\ConfigFile.cs" />
<Compile Include="Configuration\IConfigFile.cs" />
<Compile Include="Configuration\TShockConfig.cs" />
<Compile Include="DB\ProjectileManager.cs" />
<Compile Include="DB\RegionManager.cs" />
<Compile Include="DB\ResearchDatastore.cs" />
<Compile Include="DB\TileManager.cs" />
<Compile Include="Extensions\ExceptionExt.cs" />
<Compile Include="Handlers\DisplayDollItemSyncHandler.cs" />
<Compile Include="Handlers\IPacketHandler.cs" />
<Compile Include="Handlers\NetModules\AmbienceHandler.cs" />
<Compile Include="Handlers\NetModules\BestiaryHandler.cs" />
<Compile Include="Handlers\NetModules\CreativePowerHandler.cs" />
<Compile Include="Handlers\NetModules\CreativeUnlocksHandler.cs" />
<Compile Include="Handlers\NetModules\INetModuleHandler.cs" />
<Compile Include="Handlers\NetModules\LiquidHandler.cs" />
<Compile Include="Handlers\NetModules\NetModulePacketHandler.cs" />
<Compile Include="Handlers\NetModules\PylonHandler.cs" />
<Compile Include="Handlers\EmojiHandler.cs" />
<Compile Include="Handlers\LandGolfBallInCupHandler.cs" />
<Compile Include="Handlers\RequestTileEntityInteractionHandler.cs" />
<Compile Include="Handlers\SendTileRectHandler.cs" />
<Compile Include="Handlers\SyncTilePickingHandler.cs" />
<Compile Include="Handlers\IllegalPerSe\EmojiPlayerMismatch.cs" />
<Compile Include="Hooks\AccountHooks.cs" />
<Compile Include="Hooks\GeneralHooks.cs" />
<Compile Include="Hooks\PlayerHooks.cs" />
<Compile Include="Hooks\RegionHooks.cs" />
<Compile Include="ILog.cs" />
<Compile Include="Localization\EnglishLanguage.cs" />
<Compile Include="Models\PlayerUpdate\ControlSet.cs" />
<Compile Include="Models\PlayerUpdate\MiscDataSet1.cs" />
<Compile Include="Models\PlayerUpdate\MiscDataSet2.cs" />
<Compile Include="Models\PlayerUpdate\MiscDataSet3.cs" />
<Compile Include="Models\Projectiles\NewProjectileData.cs" />
<Compile Include="NetItem.cs" />
<Compile Include="PlayerData.cs" />
<Compile Include="RegionHandler.cs" />
<Compile Include="Sockets\LinuxTcpSocket.cs" />
<Compile Include="SqlLog.cs" />
<Compile Include="TextLog.cs" />
<Compile Include="PaginationTools.cs" />
<Compile Include="Rest\RestPermissions.cs" />
<Compile Include="SaveManager.cs" />
<Compile Include="DB\BanManager.cs" />
<Compile Include="DB\CharacterManager.cs" />
<Compile Include="DB\IQueryBuilder.cs" />
<Compile Include="DB\ItemManager.cs" />
<Compile Include="DB\SqlColumn.cs" />
<Compile Include="DB\SqlTable.cs" />
<Compile Include="DB\SqlValue.cs" />
<Compile Include="Extensions\DbExt.cs" />
<Compile Include="DB\GroupManager.cs" />
<Compile Include="DB\UserManager.cs" />
<Compile Include="Extensions\RandomExt.cs" />
<Compile Include="Extensions\StringExt.cs" />
<Compile Include="GeoIPCountry.cs" />
<Compile Include="HandlerList.cs" />
<Compile Include="IPackable.cs" />
<Compile Include="Commands.cs" />
<Compile Include="FileTools.cs" />
<Compile Include="GetDataHandlers.cs" />
<Compile Include="Group.cs" />
<Compile Include="Extensions\LinqExt.cs" />
<Compile Include="Net\BaseMsg.cs" />
<Compile Include="Net\DisconnectMsg.cs" />
<Compile Include="Net\NetTile.cs" />
<Compile Include="Net\ProjectileRemoveMsg.cs" />
<Compile Include="Net\SpawnMsg.cs" />
<Compile Include="Net\WorldInfoMsg.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="DB\RememberedPosManager.cs" />
<Compile Include="Bouncer.cs" />
<Compile Include="ItemBans.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Rest\Rest.cs" />
<Compile Include="Rest\RestCommand.cs" />
<Compile Include="Rest\RestManager.cs" />
<Compile Include="Rest\RestObject.cs" />
<Compile Include="Rest\RestVerbs.cs" />
<Compile Include="Rest\SecureRest.cs" />
<Compile Include="Configuration\ServerSideConfig.cs" />
<Compile Include="TSServerPlayer.cs" />
<Compile Include="Utils.cs" />
<Compile Include="TShock.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TSPlayer.cs" />
<Compile Include="UpdateManager.cs" />
<Compile Include="DB\WarpsManager.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="TShockAPI.licenseheader" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj">
<Project>{6877506e-adc6-4142-98a6-79e4fa02855a}</Project>
<Name>TerrariaServerAPI</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project> </Project>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup></configuration>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BCrypt.Net" version="0.1.0" targetFramework="net45" />
<package id="MySql.Data" version="6.9.8" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
</packages>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
</configuration>

View file

@ -0,0 +1,31 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using System.Threading;
namespace TShockLauncher.Tests
{
[TestClass]
public class ServerInitTests
{
[TestMethod]
public void EnsureBoots()
{
var are = new AutoResetEvent(false);
On.Terraria.Main.hook_DedServ cb = (On.Terraria.Main.orig_DedServ orig, Terraria.Main instance) =>
{
are.Set();
Debug.WriteLine("Server init process successful");
};
On.Terraria.Main.DedServ += cb;
new Thread(() => TerrariaApi.Server.Program.Main(new string[] { })).Start();
var hit = are.WaitOne(TimeSpan.FromSeconds(10));
On.Terraria.Main.DedServ -= cb;
Assert.AreEqual(true, hit);
}
}
}

View file

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TShockLauncher\TShockLauncher.csproj" />
</ItemGroup>
</Project>

66
TShockLauncher/Program.cs Normal file
View file

@ -0,0 +1,66 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2021 Pryaxis & TShock Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* The purpose of this project is to be the launcher of the TSAPI server.
* We use this project:
* - to copy/move around TShockAPI.dll (the TShock plugin to TSAPI)
* - to publishing TShock releases.
* - move dependencies to a ./bin folder
*
* The assembly name of this launcher (TShock.exe) was decided on by a community poll.
*/
using System.Reflection;
Dictionary<string, Assembly> _cache = new Dictionary<string, Assembly>();
System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving;
Start();
/// <summary>
/// Resolves a module from the ./bin folder, either with a .dll by preference or .exe
/// </summary>
Assembly? Default_Resolving(System.Runtime.Loader.AssemblyLoadContext arg1, AssemblyName arg2)
{
if (arg2?.Name is null) return null;
if (_cache.TryGetValue(arg2.Name, out Assembly? asm) && asm is not null) return asm;
var loc = Path.Combine(Environment.CurrentDirectory, "bin", arg2.Name + ".dll");
if (File.Exists(loc))
asm = arg1.LoadFromAssemblyPath(loc);
loc = Path.ChangeExtension(loc, ".exe");
if (File.Exists(loc))
asm = arg1.LoadFromAssemblyPath(loc);
if(asm is not null)
_cache[arg2.Name] = asm;
return asm;
}
/// <summary>
/// Initiates the TSAPI server.
/// </summary>
/// <remarks>This method exists so that the resolver can attach before TSAPI needs its dependencies.</remarks>
void Start()
{
TerrariaApi.Server.Program.Main(args);
}

2
TShockLauncher/TShock.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
./bin/TShock.Run

View file

@ -0,0 +1,94 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName Condition="'$(RuntimeIdentifier)' == 'win-x64' Or '$(RuntimeIdentifier)' == ''">TShock</AssemblyName>
<AssemblyName Condition="'$(RuntimeIdentifier)' != 'win-x64' And '$(RuntimeIdentifier)' != ''">TShock.Run</AssemblyName>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<DebugType>embedded</DebugType>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj" ExcludeFromSingleFile="true" />
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj" ExcludeFromSingleFile="true" Condition="'$(PublishSingleFile)' == 'true'" />
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj" ReferenceOutputAssembly="false" Condition="'$(PublishSingleFile)' != 'true'" />
<Reference Include="HttpServer" ExcludeFromSingleFile="true" >
<HintPath>..\prebuilts\HttpServer.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<!-- match tshocks dependencies so that publishing outputs all files to ./bin -->
<PackageReference Include="BCrypt.Net-Next" Version="4.0.2" />
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115.5" />
</ItemGroup>
<Target Name="MoveTShockDebug" AfterTargets="FinalCleanup;PostBuildEvent">
<ItemGroup>
<TShockPluginFilesDebug Include="$(TargetDir)/TShockAPI*" />
</ItemGroup>
<Move SourceFiles="@(TShockPluginFilesDebug)" DestinationFolder="$(TargetDir)ServerPlugins" ContinueOnError="true" />
</Target>
<Target Name="MoveTShockPublish" AfterTargets="Publish">
<ItemGroup>
<TShockPluginFilesPublish Include="$(PublishDir)/TShockAPI*" />
<TShockPluginFilesForPublish Include="$(ProjectDir)../TShockAPI/bin/$(Configuration)/$(TargetFramework)/TShockAPI*" Condition="'$(PublishSingleFile)' != 'true'" />
</ItemGroup>
<Move SourceFiles="@(TShockPluginFilesPublish)" DestinationFolder="$(PublishDir)ServerPlugins" ContinueOnError="true" />
<Copy SourceFiles="@(TShockPluginFilesForPublish)" DestinationFolder="$(PublishDir)ServerPlugins" ContinueOnError="true" Condition="'$(PublishSingleFile)' != 'true'" />
</Target>
<Target Name="MoveBin" AfterTargets="Publish">
<ItemGroup>
<MoveBinaries Include="$(PublishDir)*" Exclude="$(PublishDir)\TShock.exe;$(PublishDir)\TShockAPI*" />
</ItemGroup>
<Move SourceFiles="@(MoveBinaries)" DestinationFolder="$(PublishDir)bin" ContinueOnError="true" />
</Target>
<UsingTask TaskName="PatchAppHost" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<HostExe ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
/*
This is a patch to allow self contained apps to run from the root while having the modules in a ./bin folder.
https://github.com/dotnet/sdk/issues/10366
The script replaces the ./TShock.dll with ./bin/TShock.dll
alternates: dnSpy(does this method), NetCoreBeauty
*/
var find = Encoding.UTF8.GetBytes("TShock.dll\0");
var replace = Encoding.UTF8.GetBytes("bin" + Path.DirectorySeparatorChar + "TShock.dll\0");
var contents = File.ReadAllBytes(HostExe);
var matches = 0;
var offset = Array.FindIndex(contents, (b) =&gt; {
matches = (b == find[matches]) ? matches + 1 : 0;
return matches == find.Length;
});
if (offset &gt; -1) offset -= find.Length - 1;
var x = 0;
Array.ForEach(replace, _ =&gt; { contents[offset + x] = replace[x++]; });
File.WriteAllBytes(HostExe, contents);
</Code>
</Task>
</UsingTask>
<Target Name="PatchAppHostAfterPublish" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'win-x64'">
<PatchAppHost HostExe="$(PublishDir)TShock.exe" />
<Message Text="Patched TShock.exe host for ./bin redirect" Importance="High" />
</Target>
<Target Name="CreateScriptAfterPublish" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' != 'win-x64'">
<Copy SourceFiles="$(ProjectDir)TShock.sh" DestinationFolder="$(PublishDir)" />
<Message Text="Run the launcher with chmod +x TShock.sh &amp;&amp; ./TShock.sh" Importance="High" />
</Target>
</Project>

View file

@ -0,0 +1,5 @@
{
"additionalProbingPaths": [
"../ServerPlugins"
]
}

@ -1 +1 @@
Subproject commit 5314669394193a8a9a6a40036e00bcf8838254af Subproject commit a7949a2cee98e43e321ed9981c92d08334156f79

Binary file not shown.

View file

@ -1,261 +0,0 @@
EXPORTS
sqlite3_aggregate_context
sqlite3_aggregate_count
sqlite3_auto_extension
sqlite3_backup_finish
sqlite3_backup_init
sqlite3_backup_pagecount
sqlite3_backup_remaining
sqlite3_backup_step
sqlite3_bind_blob
sqlite3_bind_blob64
sqlite3_bind_double
sqlite3_bind_int
sqlite3_bind_int64
sqlite3_bind_null
sqlite3_bind_parameter_count
sqlite3_bind_parameter_index
sqlite3_bind_parameter_name
sqlite3_bind_pointer
sqlite3_bind_text
sqlite3_bind_text16
sqlite3_bind_text64
sqlite3_bind_value
sqlite3_bind_zeroblob
sqlite3_bind_zeroblob64
sqlite3_blob_bytes
sqlite3_blob_close
sqlite3_blob_open
sqlite3_blob_read
sqlite3_blob_reopen
sqlite3_blob_write
sqlite3_busy_handler
sqlite3_busy_timeout
sqlite3_cancel_auto_extension
sqlite3_changes
sqlite3_clear_bindings
sqlite3_close
sqlite3_close_v2
sqlite3_collation_needed
sqlite3_collation_needed16
sqlite3_column_blob
sqlite3_column_bytes
sqlite3_column_bytes16
sqlite3_column_count
sqlite3_column_database_name
sqlite3_column_database_name16
sqlite3_column_decltype
sqlite3_column_decltype16
sqlite3_column_double
sqlite3_column_int
sqlite3_column_int64
sqlite3_column_name
sqlite3_column_name16
sqlite3_column_origin_name
sqlite3_column_origin_name16
sqlite3_column_table_name
sqlite3_column_table_name16
sqlite3_column_text
sqlite3_column_text16
sqlite3_column_type
sqlite3_column_value
sqlite3_commit_hook
sqlite3_compileoption_get
sqlite3_compileoption_used
sqlite3_complete
sqlite3_complete16
sqlite3_config
sqlite3_context_db_handle
sqlite3_create_collation
sqlite3_create_collation16
sqlite3_create_collation_v2
sqlite3_create_function
sqlite3_create_function16
sqlite3_create_function_v2
sqlite3_create_module
sqlite3_create_module_v2
sqlite3_create_window_function
sqlite3_data_count
sqlite3_db_cacheflush
sqlite3_db_config
sqlite3_db_filename
sqlite3_db_handle
sqlite3_db_mutex
sqlite3_db_readonly
sqlite3_db_release_memory
sqlite3_db_status
sqlite3_declare_vtab
sqlite3_enable_load_extension
sqlite3_enable_shared_cache
sqlite3_errcode
sqlite3_errmsg
sqlite3_errmsg16
sqlite3_errstr
sqlite3_exec
sqlite3_expanded_sql
sqlite3_expired
sqlite3_extended_errcode
sqlite3_extended_result_codes
sqlite3_file_control
sqlite3_finalize
sqlite3_free
sqlite3_free_table
sqlite3_get_autocommit
sqlite3_get_auxdata
sqlite3_get_table
sqlite3_global_recover
sqlite3_initialize
sqlite3_interrupt
sqlite3_keyword_check
sqlite3_keyword_count
sqlite3_keyword_name
sqlite3_last_insert_rowid
sqlite3_libversion
sqlite3_libversion_number
sqlite3_limit
sqlite3_load_extension
sqlite3_log
sqlite3_malloc
sqlite3_malloc64
sqlite3_memory_alarm
sqlite3_memory_highwater
sqlite3_memory_used
sqlite3_mprintf
sqlite3_msize
sqlite3_mutex_alloc
sqlite3_mutex_enter
sqlite3_mutex_free
sqlite3_mutex_leave
sqlite3_mutex_try
sqlite3_next_stmt
sqlite3_open
sqlite3_open16
sqlite3_open_v2
sqlite3_os_end
sqlite3_os_init
sqlite3_overload_function
sqlite3_prepare
sqlite3_prepare16
sqlite3_prepare16_v2
sqlite3_prepare16_v3
sqlite3_prepare_v2
sqlite3_prepare_v3
sqlite3_profile
sqlite3_progress_handler
sqlite3_randomness
sqlite3_realloc
sqlite3_realloc64
sqlite3_release_memory
sqlite3_reset
sqlite3_reset_auto_extension
sqlite3_result_blob
sqlite3_result_blob64
sqlite3_result_double
sqlite3_result_error
sqlite3_result_error16
sqlite3_result_error_code
sqlite3_result_error_nomem
sqlite3_result_error_toobig
sqlite3_result_int
sqlite3_result_int64
sqlite3_result_null
sqlite3_result_pointer
sqlite3_result_subtype
sqlite3_result_text
sqlite3_result_text16
sqlite3_result_text16be
sqlite3_result_text16le
sqlite3_result_text64
sqlite3_result_value
sqlite3_result_zeroblob
sqlite3_result_zeroblob64
sqlite3_rollback_hook
sqlite3_rtree_geometry_callback
sqlite3_rtree_query_callback
sqlite3_set_authorizer
sqlite3_set_auxdata
sqlite3_set_last_insert_rowid
sqlite3_shutdown
sqlite3_sleep
sqlite3_snprintf
sqlite3_soft_heap_limit
sqlite3_soft_heap_limit64
sqlite3_sourceid
sqlite3_sql
sqlite3_status
sqlite3_status64
sqlite3_step
sqlite3_stmt_busy
sqlite3_stmt_readonly
sqlite3_stmt_status
sqlite3_str_append
sqlite3_str_appendall
sqlite3_str_appendchar
sqlite3_str_appendf
sqlite3_str_errcode
sqlite3_str_finish
sqlite3_strglob
sqlite3_stricmp
sqlite3_str_length
sqlite3_strlike
sqlite3_str_new
sqlite3_strnicmp
sqlite3_str_reset
sqlite3_str_value
sqlite3_str_vappendf
sqlite3_system_errno
sqlite3_table_column_metadata
sqlite3_test_control
sqlite3_thread_cleanup
sqlite3_threadsafe
sqlite3_total_changes
sqlite3_trace
sqlite3_trace_v2
sqlite3_transfer_bindings
sqlite3_update_hook
sqlite3_uri_boolean
sqlite3_uri_int64
sqlite3_uri_parameter
sqlite3_user_data
sqlite3_value_blob
sqlite3_value_bytes
sqlite3_value_bytes16
sqlite3_value_double
sqlite3_value_dup
sqlite3_value_free
sqlite3_value_int
sqlite3_value_int64
sqlite3_value_nochange
sqlite3_value_numeric_type
sqlite3_value_pointer
sqlite3_value_subtype
sqlite3_value_text
sqlite3_value_text16
sqlite3_value_text16be
sqlite3_value_text16le
sqlite3_value_type
sqlite3_vfs_find
sqlite3_vfs_register
sqlite3_vfs_unregister
sqlite3_vmprintf
sqlite3_vsnprintf
sqlite3_vtab_collation
sqlite3_vtab_config
sqlite3_vtab_nochange
sqlite3_vtab_on_conflict
sqlite3_wal_autocheckpoint
sqlite3_wal_checkpoint
sqlite3_wal_checkpoint_v2
sqlite3_wal_hook
sqlite3_win32_is_nt
sqlite3_win32_mbcs_to_utf8
sqlite3_win32_mbcs_to_utf8_v2
sqlite3_win32_set_directory
sqlite3_win32_set_directory16
sqlite3_win32_set_directory8
sqlite3_win32_sleep
sqlite3_win32_unicode_to_utf8
sqlite3_win32_utf8_to_mbcs
sqlite3_win32_utf8_to_mbcs_v2
sqlite3_win32_utf8_to_unicode
sqlite3_win32_write_debug

Binary file not shown.