Merge pull request #2670 from Pryaxis/v144x

1.4.4.x on OTAPI3 and .NET 6
This commit is contained in:
Lucas Nicodemus 2022-10-05 02:42:14 -07:00 committed by GitHub
commit feaf6305f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 984 additions and 815 deletions

View file

@ -1,66 +0,0 @@
name: Build Server
on: [push, pull_request]
jobs:
build:
runs-on: windows-2019
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

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

@ -0,0 +1,30 @@
name: Deploy NuGet(OTAPI3)
on:
push:
branches: [ nuget-release ]
jobs:
build:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.400
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build TShock.sln --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release
# Publish to nuget
- name: Push TShockAPI
run: dotnet nuget push TShockAPI/bin/Release/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json

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

@ -0,0 +1,55 @@
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: 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: Produce build
run: |
cd TShockLauncher
dotnet publish -r ${{ matrix.arch }} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false
- name: Chmod scripts
if: ${{ matrix.arch != 'win-x64' }}
run: |
chmod +x TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/TShock.Server
# preserve file perms: https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files
- name: Archive artifact
run: |
cd TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/
tar -cvf ../../../../../../TShock-Beta-${{ matrix.arch }}-Release.tar *
- 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

@ -13,7 +13,15 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change.
## Upcoming changes ## Upcoming changes
* Your changes could be here! * Reduced load/save console spam. (@SignatureBeef, @YehnBeep)
* Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef)
* Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2)
* Ported to OTAPI3 and .NET6. (@SignatureBeef)
* Introduced a new module framework for TShock developers. (@SignatureBeef)
* Fixed a secondary crash when server init fails and log services were not initialised. (@SignatureBeef)
* Added preliminary support for Terraria 1.4.4.4. (@SignatureBeef)
* GrassSpreadEventArgs Color property has been changed from a Byte to a TileColorCache type. (@SignatureBeef)
* SetDefaultsEventArgs now includes a nullable ItemVariant instance. (@SignatureBeef)
## TShock 4.5.18 ## TShock 4.5.18
* Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@gohjoseph) * Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@gohjoseph)
@ -507,33 +515,33 @@ Please note that the permissions previously tied to the removed commands are als
## TShock 4.3.24 ## TShock 4.3.24
* Updated OpenTerraria API to 1.3.5.3 (@DeathCradle) * Updated OpenTerraria API to 1.3.5.3 (@DeathCradle)
* Updated Terraria Server API to 1.3.5.3 (@WhiteXZ, @hakusaro) * Updated Terraria Server API to 1.3.5.3 (@QuiCM, @hakusaro)
* Updated TShock core components to 1.3.5.3 (@hakusaro) * Updated TShock core components to 1.3.5.3 (@hakusaro)
* Terraria Server API version tick: 2.1 * Terraria Server API version tick: 2.1
* Added OnNpcKilled hook to Server API: 2.2 (@tylerjwatson) * Added OnNpcKilled hook to Server API: 2.2 (@tylerjwatson)
* Added CreateCombatTextExtended to PacketTypes. This packet allows for the same functionality that packet 82 (CreateCombatText) used to have. (@WhiteXZ) * Added CreateCombatTextExtended to PacketTypes. This packet allows for the same functionality that packet 82 (CreateCombatText) used to have. (@QuiCM)
* Updated ServerBroadcast hook to provide a NetworkText object. (@tylerjwatson) * Updated ServerBroadcast hook to provide a NetworkText object. (@tylerjwatson)
* Fixed levers and things not updating properly. (@deathcradle) * Fixed levers and things not updating properly. (@deathcradle)
* Deprecated PacketTypes.ChatText. Chat is now handled using the NetTextModule and packet 82. (@WhiteXZ, @Hakusaro) * Deprecated PacketTypes.ChatText. Chat is now handled using the NetTextModule and packet 82. (@QuiCM, @Hakusaro)
* Removed the -lang command-line flag from TShock. It is now a vanilla feature. (@Hakusaro) * Removed the -lang command-line flag from TShock. It is now a vanilla feature. (@Hakusaro)
## TShock 4.3.23 ## TShock 4.3.23
* Added evil type option during world creation (@mistzzt) * Added evil type option during world creation (@mistzzt)
* Bans can be sorted. TShock's default sorting will retrieve bans sorted from newest to oldest based on the date the ban was added (@WhiteXZ) * Bans can be sorted. TShock's default sorting will retrieve bans sorted from newest to oldest based on the date the ban was added (@QuiCM)
* Resolved issues with mob and item spawning. Thanks to @OnsenManju for your investigative work :) (@WhiteXZ) * Resolved issues with mob and item spawning. Thanks to @OnsenManju for your investigative work :) (@QuiCM)
* Patched a crashing exploit (@Simon311) * Patched a crashing exploit (@Simon311)
## TShock 4.3.22 ## TShock 4.3.22
* Compatibility with Terraria 1.3.4.4 * Compatibility with Terraria 1.3.4.4
* API: Version tick 2.0 * API: Version tick 2.0
* API: Reduced RAM usage by ~80MB (Large server) (@deathcradle) * API: Reduced RAM usage by ~80MB (Large server) (@deathcradle)
* API: Added TSPlayer.KillPlayer() (@WhiteXZ) * API: Added TSPlayer.KillPlayer() (@QuiCM)
* API: Added TSPlayer.Logout() (@ProfessorXZ) * API: Added TSPlayer.Logout() (@ProfessorXZ)
* Fixed connections after max slot is reached (@DeathCradle) * Fixed connections after max slot is reached (@DeathCradle)
* Fixed server crashes caused by client disconnections when attempting to read closed sockets (@Enerdy) * Fixed server crashes caused by client disconnections when attempting to read closed sockets (@Enerdy)
* Added some code to make trapdoors work better (@DogooFalchion) * Added some code to make trapdoors work better (@DogooFalchion)
* AllowCutTilesAndBreakables config option now correctly allows flowers/vines/herbs to be cut in regions without breaking walls (@WhiteXZ) * AllowCutTilesAndBreakables config option now correctly allows flowers/vines/herbs to be cut in regions without breaking walls (@QuiCM)
* REST: `/v3/players/read` now includes a `muted` field (@WhiteXZ) * REST: `/v3/players/read` now includes a `muted` field (@QuiCM)
* REST: Token creation is now more secure (Thanks to @Plazmaz for reporting the issue!) * REST: Token creation is now more secure (Thanks to @Plazmaz for reporting the issue!)
* REST: Deprecated the RestRequestEvent. If you use this event, please let us know. * REST: Deprecated the RestRequestEvent. If you use this event, please let us know.
* REST: ALL endpoints now have a base route (eg you can use `/server/motd` instead of `/v3/server/motd`). These base routes will never change, but will provide an `upgrade` field describing any newer routes * REST: ALL endpoints now have a base route (eg you can use `/server/motd` instead of `/v3/server/motd`). These base routes will never change, but will provide an `upgrade` field describing any newer routes
@ -548,34 +556,34 @@ Please note that the permissions previously tied to the removed commands are als
* Fixed HealOtherPlayer packet exploit (@Simon311). * Fixed HealOtherPlayer packet exploit (@Simon311).
* Added associated config option for HealOtherPlayer exploit prevention (@Simon311). * Added associated config option for HealOtherPlayer exploit prevention (@Simon311).
* Added `/accountinfo` command to get account information for a given TShock account (@Simon311). * Added `/accountinfo` command to get account information for a given TShock account (@Simon311).
* Removed TShock color parsing from MOTDs (@WhiteXZ). * Removed TShock color parsing from MOTDs (@QuiCM).
* Fixed butterfly statues spawning catchable butterflies (@DogooFalchion). * Fixed butterfly statues spawning catchable butterflies (@DogooFalchion).
* Implemented some missing balance changes lost in prior version patches (@DogooFalchion). * Implemented some missing balance changes lost in prior version patches (@DogooFalchion).
* Added alias for server shutdown command: stop (@nicatronTg). * Added alias for server shutdown command: stop (@nicatronTg).
* Removed the old REST model. This includes the following endpoints: * Removed the old REST model. This includes the following endpoints:
* `/status` * `/status`
* `/v2/players/read` * `/v2/players/read`
* `/v2/server/rawcmd` (@WhiteXZ). * `/v2/server/rawcmd` (@QuiCM).
* Fixed `/user group` always giving an unhelpful error messaging telling you to check the console, even if we knew exactly why it failed (@nicatronTg). * Fixed `/user group` always giving an unhelpful error messaging telling you to check the console, even if we knew exactly why it failed (@nicatronTg).
* Removed _all obsolete methods in TShock marked obsolete prior to this version (all of them)_ (@nicatronTg). * Removed _all obsolete methods in TShock marked obsolete prior to this version (all of them)_ (@nicatronTg).
* Fixed issue where registration + login would fail because KnownIps had 0 items and .Last() doesn't work on collections with 0 items (@DogooFalchion, @nicatronTg, @Simon311). * Fixed issue where registration + login would fail because KnownIps had 0 items and .Last() doesn't work on collections with 0 items (@DogooFalchion, @nicatronTg, @Simon311).
* Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion). * Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion).
* Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion). * Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion).
* Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@WhiteXZ, @Simon311, and especially @DogooFalchion) for the hard work on this issue. * Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@QuiCM, @Simon311, and especially @DogooFalchion) for the hard work on this issue.
## TShock 4.3.20 ## TShock 4.3.20
* Security improvement: The auth system is now automatically disabled if a superadmin exists in the database (@Enerdy). * Security improvement: The auth system is now automatically disabled if a superadmin exists in the database (@Enerdy).
* Removed the `auth-verify` command since `auth` now serves its purpose when necessary (@Enerdy). * Removed the `auth-verify` command since `auth` now serves its purpose when necessary (@Enerdy).
* Security: `/"` exploit can no longer break chat mute filters (@Simon311). * Security: `/"` exploit can no longer break chat mute filters (@Simon311).
* Fixed an issue where sometimes players could connect briefly during server shutdown, leading to errors (@Simon311). * Fixed an issue where sometimes players could connect briefly during server shutdown, leading to errors (@Simon311).
* Fixed wyverns despawning & not behaving like normal (@WhiteXZ). * Fixed wyverns despawning & not behaving like normal (@QuiCM).
* Fixed major security issue where InvokeClientConnect could be exploited to do terrible, terrible things (@Simon311, @nicatronTg, @popstarfreas, @ProfessorXZ, @WhiteXZ). * Fixed major security issue where InvokeClientConnect could be exploited to do terrible, terrible things (@Simon311, @nicatronTg, @popstarfreas, @ProfessorXZ, @QuiCM).
## TShock 4.3.19 ## TShock 4.3.19
* Compatibility with Terraria 1.3.3.3 (@Simon311) * Compatibility with Terraria 1.3.3.3 (@Simon311)
* API: Version tick 1.25 * API: Version tick 1.25
* API: Resolved some issues with the ItemForceIntoChest hook (@WhiteXZ, @Patrikkk) * API: Resolved some issues with the ItemForceIntoChest hook (@QuiCM, @Patrikkk)
* API: Resolved some shonky code that caused Vitamins and other Ankh Shield related items to drop at strange rates or not at all (@ProfessorXZ, @WhiteXZ, @nicatronTg) * API: Resolved some shonky code that caused Vitamins and other Ankh Shield related items to drop at strange rates or not at all (@ProfessorXZ, @QuiCM, @nicatronTg)
* Fixed magical ice blocks not working correctly (@ProfessorXZ) * Fixed magical ice blocks not working correctly (@ProfessorXZ)
## TShock 4.3.18 ## TShock 4.3.18
@ -583,7 +591,7 @@ Please note that the permissions previously tied to the removed commands are als
* Compatibility with Terraria 1.3.3.2 * Compatibility with Terraria 1.3.3.2
* API: Version tick 1.24 * API: Version tick 1.24
* API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ) * API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ)
* API: Added ItemForceIntoChest hook (@WhiteXZ) * API: Added ItemForceIntoChest hook (@QuiCM)
* API: Included the player's registration date in REST's players/read endpoints (@ProfessorXZ) * API: Included the player's registration date in REST's players/read endpoints (@ProfessorXZ)
* The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju) * The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju)
* Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ) * Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ)
@ -604,19 +612,19 @@ Please note that the permissions previously tied to the removed commands are als
* Players can no longer bypass tile checks by using the Tile packet (@ProfessorXZ) * Players can no longer bypass tile checks by using the Tile packet (@ProfessorXZ)
* Fixed a bug where players couldn't hammer a Junction Box without "allowclientsideworldedit" permission (@Patrikkk) * Fixed a bug where players couldn't hammer a Junction Box without "allowclientsideworldedit" permission (@Patrikkk)
* Fixed the client's UI not being draw when setting wind speed to abnormal values (@ProfessorXZ) * Fixed the client's UI not being draw when setting wind speed to abnormal values (@ProfessorXZ)
* Added a command to start and stop sandstorms (@WhiteXZ) * Added a command to start and stop sandstorms (@QuiCM)
## TShock 4.3.17 ## TShock 4.3.17
* Compatibility with Terraria 1.3.2.1 * Compatibility with Terraria 1.3.2.1
* Updated superadmin behaviour to conform to expected behaviour (@WhiteXZ, @Patrikk) * Updated superadmin behaviour to conform to expected behaviour (@QuiCM, @Patrikk)
* Fixed a crash involving teleporters and dressers (@WhiteXZ) * Fixed a crash involving teleporters and dressers (@QuiCM)
* Fixed pressure plates (@Enerdy, @Patrikk) * Fixed pressure plates (@Enerdy, @Patrikk)
* Fixed a deadlock in wiring (@Wolfje) * Fixed a deadlock in wiring (@Wolfje)
* Fixed a crash in wiring (@Patrikk) * Fixed a crash in wiring (@Patrikk)
* Improved network syncing on client joins (@Patrikk) * Improved network syncing on client joins (@Patrikk)
* The Presserator can now place actuators (@ProfessorXZ) * The Presserator can now place actuators (@ProfessorXZ)
* Resolved a region error when removing unlisted users from regions (@WhiteXZ) * Resolved a region error when removing unlisted users from regions (@QuiCM)
* Added a `SetDungeon` command to set the dungeon position (@webmilio) * Added a `SetDungeon` command to set the dungeon position (@webmilio)
* The currently running world name is now part of the server application's title (@webmilio) * The currently running world name is now part of the server application's title (@webmilio)
* Gem locks can now be region protected (@mistzzt) * Gem locks can now be region protected (@mistzzt)
@ -640,23 +648,23 @@ Please note that the permissions previously tied to the removed commands are als
* Fixed an issue preventing TShock from starting on certain mono versions (@Wolfje) * Fixed an issue preventing TShock from starting on certain mono versions (@Wolfje)
* Fixed a deadlock in Wiring (@Wolfje) * Fixed a deadlock in Wiring (@Wolfje)
* Fixed character styles/gender not being saved properly on first login while SSC is on (@WhiteXZ) * Fixed character styles/gender not being saved properly on first login while SSC is on (@QuiCM)
* Added a PlayerPermission hook fired whenever a permission check involving said player occurs (when the new TSPlayer.HasPermission method is called) (@Enerdy) * Added a PlayerPermission hook fired whenever a permission check involving said player occurs (when the new TSPlayer.HasPermission method is called) (@Enerdy)
* Resolved an issue where martian invasions and eclipses would have empty messages if AnonymousBossInvasions was set to true (@WhiteXZ) * Resolved an issue where martian invasions and eclipses would have empty messages if AnonymousBossInvasions was set to true (@QuiCM)
* Added an optional `slime` parameter to the `rain` command, allowing slime rain to be started and stopped. New syntax is `rain [slime] <start/stop>` (@WhiteXZ) * Added an optional `slime` parameter to the `rain` command, allowing slime rain to be started and stopped. New syntax is `rain [slime] <start/stop>` (@QuiCM)
* Fixed performance issues due to concurrent dictionary access in TSPlayer (@CoderCow) * Fixed performance issues due to concurrent dictionary access in TSPlayer (@CoderCow)
* Added an ID property to Regions (@WhiteXZ) * Added an ID property to Regions (@QuiCM)
* Fixed an issue where region sizes were calculated incorrectly (@WhiteXZ) * Fixed an issue where region sizes were calculated incorrectly (@QuiCM)
* Fixed a bug in RegionManager preventing regions adding correctly (@pink_panther) * Fixed a bug in RegionManager preventing regions adding correctly (@pink_panther)
* Fixed another bug in RegionManager preventing regions adding correctly (@WhiteXZ) * Fixed another bug in RegionManager preventing regions adding correctly (@QuiCM)
* Fixed a routing issue with the `/v2/token/create` REST endpoint * Fixed a routing issue with the `/v2/token/create` REST endpoint
* Removed the `/token/create` REST endpoint. `/v2/token/create` should be used instead. * Removed the `/token/create` REST endpoint. `/v2/token/create` should be used instead.
## TShock 4.3.12 ## TShock 4.3.12
* Fixed issues with TSPlayer.SetTeam not working (@WhiteXZ) * Fixed issues with TSPlayer.SetTeam not working (@QuiCM)
* Fixed /butcher not killing bosses in expert difficulty (@WhiteXZ) * Fixed /butcher not killing bosses in expert difficulty (@QuiCM)
* API: Deprecated PacketBufferer (now obviated by SendQ) (@WhiteXZ) * API: Deprecated PacketBufferer (now obviated by SendQ) (@QuiCM)
* API: Building on Windows no longer breaks traps (@Wolfje) * API: Building on Windows no longer breaks traps (@Wolfje)
* Fixed bombs, dynamite, and sticky bombs (@Wolfje) * Fixed bombs, dynamite, and sticky bombs (@Wolfje)
* Removed spammy messages from OnSecondUpdate that confused some server owners (@Wolfje) * Removed spammy messages from OnSecondUpdate that confused some server owners (@Wolfje)
@ -688,17 +696,17 @@ Other notable changes include:
* Fixed an issue preventing some players from joining when the world is saving (@Wolfje) * Fixed an issue preventing some players from joining when the world is saving (@Wolfje)
* Fixed an issue adding a ban on a player who has previously been banned (@Wolfje) * Fixed an issue adding a ban on a player who has previously been banned (@Wolfje)
* Fixed /invade martian (@Wolfje) * Fixed /invade martian (@Wolfje)
* Fixed target dummies not working properly (@WhiteXZ) * Fixed target dummies not working properly (@QuiCM)
* Added a config option (DisableSecondUpdateLogs) to prevent log spam from OnSecondUpdate() (@WhiteXZ) * Added a config option (DisableSecondUpdateLogs) to prevent log spam from OnSecondUpdate() (@QuiCM)
* Added RESTful API login rate limiting (@George) * Added RESTful API login rate limiting (@George)
* Added config options (MaximumRequestsPerInterval, RequestBucketDecreaseIntervalMinutes, LimitOnlyFailedLoginRequests) for rate limiting (@George) * Added config options (MaximumRequestsPerInterval, RequestBucketDecreaseIntervalMinutes, LimitOnlyFailedLoginRequests) for rate limiting (@George)
* **DEPRECATION**: Deprecated Disable(string, bool) and added Disable(string, DisableFlags). Please update your plugins accordingly (@WhiteXZ) * **DEPRECATION**: Deprecated Disable(string, bool) and added Disable(string, DisableFlags). Please update your plugins accordingly (@QuiCM)
* Fixed Halloween and Christmas events not working properly (@TomyLobo) * Fixed Halloween and Christmas events not working properly (@TomyLobo)
* Fixed the demon heart's extra accessory slot not working correctly in SSC (@WhiteXZ) * Fixed the demon heart's extra accessory slot not working correctly in SSC (@QuiCM)
* Fixed gender-changing potions not working correctly in SSC (@hastinbe) * Fixed gender-changing potions not working correctly in SSC (@hastinbe)
* Fixed IP bans not working correctly (@hastinbe) * Fixed IP bans not working correctly (@hastinbe)
* Fixed /reload not using the correct permission (@WhiteXZ) * Fixed /reload not using the correct permission (@QuiCM)
* Fixed TSPlayer.ActiveChest not being tracked correctly resulting in item dupes while disabled (@WhiteXZ) * Fixed TSPlayer.ActiveChest not being tracked correctly resulting in item dupes while disabled (@QuiCM)
* /reload now reloads tile and projectile bans * /reload now reloads tile and projectile bans
## TShock 4.3.8 ## TShock 4.3.8
@ -726,8 +734,8 @@ Alternatively, if you do not want to report the crash, just delete the file.
* Auth system kicks players if system is disabled. (@nicatronTg) * Auth system kicks players if system is disabled. (@nicatronTg)
* Fixed /login permitting multiple logins without a logout in between. (@nicatronTg) * Fixed /login permitting multiple logins without a logout in between. (@nicatronTg)
* Allow[Hallow/Corruption/Crimson]Creep in config now work. (@WhiteXZ) * Allow[Hallow/Corruption/Crimson]Creep in config now work. (@QuiCM)
* API: Treasure bags are now named properly. (@WhiteXZ) * API: Treasure bags are now named properly. (@QuiCM)
* API: Clients no longer close on disconnect. (@Wolfje) * API: Clients no longer close on disconnect. (@Wolfje)
* API: Add server broadcast hook. (@Patrikk) * API: Add server broadcast hook. (@Patrikk)
* API: Fixed pressure plate hook triggering multiple times. (@Patrikk) * API: Fixed pressure plate hook triggering multiple times. (@Patrikk)
@ -736,17 +744,17 @@ Alternatively, if you do not want to report the crash, just delete the file.
## TShock 4.3.6 ## TShock 4.3.6
* API: NPCs shoot the right way (@WhiteXZ) * API: NPCs shoot the right way (@QuiCM)
* API: The server config file works correctly with priority and port (@Patrikkk) * API: The server config file works correctly with priority and port (@Patrikkk)
* API: Removed support for favorites and removed JSON dependencies. (@Enerdy) * API: Removed support for favorites and removed JSON dependencies. (@Enerdy)
* API: Removed support for clouds. (@Enerdy) * API: Removed support for clouds. (@Enerdy)
* API: Fixed a whole lot of bugs with wiring, and in general re-wrote some core bits that were bugged. (@WhiteXZ) * API: Fixed a whole lot of bugs with wiring, and in general re-wrote some core bits that were bugged. (@QuiCM)
* API: Fixed projectile AI bugs. (@AndrioCelos) * API: Fixed projectile AI bugs. (@AndrioCelos)
* API: Fixed world saving problems. (WhiteXZ) * API: Fixed world saving problems. (WhiteXZ)
* API: Fixed server not accepting more connections once max slots was filled. (@WhiteXZ) * API: Fixed server not accepting more connections once max slots was filled. (@QuiCM)
* API: Removed startup parameters and moved them to TShock. (@Cleant) * API: Removed startup parameters and moved them to TShock. (@Cleant)
* API: Item.SetDefaults() no longer kills some tools. (@Enerdy) * API: Item.SetDefaults() no longer kills some tools. (@Enerdy)
* API: Restored chat bubbles. (@WhiteXZ) * API: Restored chat bubbles. (@QuiCM)
* API: Updated to 1.3.0.6. (@Enerdy & @Patrikkk) * API: Updated to 1.3.0.6. (@Enerdy & @Patrikkk)
* API: Lots and I mean lots of network improvements in the SendQ department. (@tylerjwatson) * API: Lots and I mean lots of network improvements in the SendQ department. (@tylerjwatson)
* API: Added NpcLootDrop and DropBossBag hooks. (@Patrikkk) * API: Added NpcLootDrop and DropBossBag hooks. (@Patrikkk)
@ -770,20 +778,20 @@ Alternatively, if you do not want to report the crash, just delete the file.
* API: API Version Tick to 1.20. * API: API Version Tick to 1.20.
* The config option disabling the DCU has been deprecated and will be removed in a future release. (@nicatronTg) * The config option disabling the DCU has been deprecated and will be removed in a future release. (@nicatronTg)
* Fixed bubble tile triggering noclip checks. (@Enerdy) * Fixed bubble tile triggering noclip checks. (@Enerdy)
* Updated projectile handling in GetDataHandlers. (@WhiteXZ) * Updated projectile handling in GetDataHandlers. (@QuiCM)
* Fixed issue #992. (@WhiteXZ) * Fixed issue #992. (@QuiCM)
* Teleport handler now handles wormholes. (@WhiteXZ) * Teleport handler now handles wormholes. (@QuiCM)
* Fixed tall gates and trap doors (issue #998). (@WhiteXZ) * Fixed tall gates and trap doors (issue #998). (@QuiCM)
* Added monoliths to orientable tiles (issue #999). (@WhiteXZ) * Added monoliths to orientable tiles (issue #999). (@QuiCM)
* Fixed vortex stealth armor (issue #964). (@WhiteXZ) * Fixed vortex stealth armor (issue #964). (@QuiCM)
* Added moon lord to spawn boss. (@WhiteXZ) * Added moon lord to spawn boss. (@QuiCM)
* Fixed serverpassword syntax error error message. (@JordyMoos) * Fixed serverpassword syntax error error message. (@JordyMoos)
* Fixed issue #1019. (@WhiteXZ) * Fixed issue #1019. (@QuiCM)
* Fix: Region protection prevents placement of objects. (@Patrikkk) * Fix: Region protection prevents placement of objects. (@Patrikkk)
* Moved all startup parameters to TShock. (@Cleant) * Moved all startup parameters to TShock. (@Cleant)
* Fix: Target dummies are no longer butchered. (@Denway) * Fix: Target dummies are no longer butchered. (@Denway)
* Added projectile 465 to the ignore list, which fixes some other issues. (@Enerdy) * Added projectile 465 to the ignore list, which fixes some other issues. (@Enerdy)
* Fix: Logging out is now safe with SSC (/logout) (issue #1037). (@WhiteXZ) * Fix: Logging out is now safe with SSC (/logout) (issue #1037). (@QuiCM)
* API/TShock: Removed -world parameter from TShock, put it back in the API. (@tylerjwatson) * API/TShock: Removed -world parameter from TShock, put it back in the API. (@tylerjwatson)
## TShock 4.3.5 ## TShock 4.3.5
@ -794,34 +802,34 @@ Alternatively, if you do not want to report the crash, just delete the file.
## TShock 4.3.4 ## TShock 4.3.4
* Fix invasion progress messages (@WhiteXZ) * Fix invasion progress messages (@QuiCM)
* Completely rewrite SendQ to have less deadlocks (@tylerjwatson) * Completely rewrite SendQ to have less deadlocks (@tylerjwatson)
## TShock 4.3.3 ## TShock 4.3.3
* Fix dihydrogen monoxide (@tylerjwatson) * Fix dihydrogen monoxide (@tylerjwatson)
* Whitelist another boss projectile (@Patrikkk, @WhiteXZ) * Whitelist another boss projectile (@Patrikkk, @QuiCM)
## TShock 4.3.2 ## TShock 4.3.2
* Fixed the issue where using the Super Absorbent Sponge would disable users (@WhiteXZ) * Fixed the issue where using the Super Absorbent Sponge would disable users (@QuiCM)
* Fixed an issue in NetGetData where e.Length - 1 would be -1 (@WhiteXZ) * Fixed an issue in NetGetData where e.Length - 1 would be -1 (@QuiCM)
* Fixed /who -i and /userinfo (@Enerdy) * Fixed /who -i and /userinfo (@Enerdy)
* API: OnRegionEntered hook now returns the region entered (@Patrikkk) * API: OnRegionEntered hook now returns the region entered (@Patrikkk)
* Support for Terraria 1.3.0.4 (@nicatronTg) * Support for Terraria 1.3.0.4 (@nicatronTg)
* Fixed dressers being unbreakable. (@nicatronTg) * Fixed dressers being unbreakable. (@nicatronTg)
* Fixed wall placement mechanics (@nicatronTg, @Ijwu, @WhiteXZ) * Fixed wall placement mechanics (@nicatronTg, @Ijwu, @QuiCM)
* Fixed Moon Lord projectiles disabling players (@k0rd, @nicatronTg) * Fixed Moon Lord projectiles disabling players (@k0rd, @nicatronTg)
* Fixed several potential crashes in server (@Patrikkk) * Fixed several potential crashes in server (@Patrikkk)
* Fixed -autocreate command line argument (@WhiteXZ, @nicatronTg) * Fixed -autocreate command line argument (@QuiCM, @nicatronTg)
* Added more world data to world load menu (@WhiteXZ) * Added more world data to world load menu (@QuiCM)
* Moved server password to TShock config (@Enerdy) * Moved server password to TShock config (@Enerdy)
* Fixed world delete in server (@benjiro) * Fixed world delete in server (@benjiro)
* Fixed disappearing NPCs (@WhiteXZ) * Fixed disappearing NPCs (@QuiCM)
* Added much more performant code, SendQ, to server module. Reduces downstream network overhead by at least 40% (@tylerjwatson) * Added much more performant code, SendQ, to server module. Reduces downstream network overhead by at least 40% (@tylerjwatson)
* API: Updated TSPlayer.Disable to use new buffs (@Enerdy) * API: Updated TSPlayer.Disable to use new buffs (@Enerdy)
* Updated default max damage & projectile damage to 1,175 (based on 625 people) * Updated default max damage & projectile damage to 1,175 (based on 625 people)
* Fixed support for SSC (@WhiteXZ) * Fixed support for SSC (@QuiCM)
## TShock 4.3.1 ## TShock 4.3.1
@ -832,9 +840,9 @@ Alternatively, if you do not want to report the crash, just delete the file.
* Fixed projectiles 435-438 (martian invasion) freezing everyone under certain conditions. (@Enerdy) * Fixed projectiles 435-438 (martian invasion) freezing everyone under certain conditions. (@Enerdy)
* DisableTombstones now works properly with the new golden gravestones. (@Enerdy) * DisableTombstones now works properly with the new golden gravestones. (@Enerdy)
* REST module now properly catches exceptions during Start(). (@Patrikkk) * REST module now properly catches exceptions during Start(). (@Patrikkk)
* Added /expert command to toggle expert mode. (@WhiteXZ) * Added /expert command to toggle expert mode. (@QuiCM)
* Fixed pirate invasions. (@patrik) * Fixed pirate invasions. (@patrik)
* Fixed worldinfo packet. (@WhiteXZ) * Fixed worldinfo packet. (@QuiCM)
* Fixed server passwords. (@Enerdy) * Fixed server passwords. (@Enerdy)
## TShock 4.3.0.0 ## TShock 4.3.0.0
@ -843,10 +851,10 @@ Alternatively, if you do not want to report the crash, just delete the file.
* Updated prebuilts (SQLite, JSON, MySQL) to latest versions. (@nicatronTg) * Updated prebuilts (SQLite, JSON, MySQL) to latest versions. (@nicatronTg)
* Added a minimum password length to prevent blank passwords. (@nicatronTg) * Added a minimum password length to prevent blank passwords. (@nicatronTg)
* Modified item ban checks to provide which item is disabling a player in the logs. (@Enerdy) * Modified item ban checks to provide which item is disabling a player in the logs. (@Enerdy)
* API: Modified TSPlayer to store a user, and deprecated calls to TSPlayer.User.ID. (@WhiteXZ) * API: Modified TSPlayer to store a user, and deprecated calls to TSPlayer.User.ID. (@QuiCM)
* Modified chat color specs in config file to be int arrays rather than floats. (@nicatronTg) * Modified chat color specs in config file to be int arrays rather than floats. (@nicatronTg)
* Modified verbiage for ```/auth``` and ```/auth-verify``` to make it clearer how they operate. (@nicatronTg) * Modified verbiage for ```/auth``` and ```/auth-verify``` to make it clearer how they operate. (@nicatronTg)
* API: Added fuzzy name searching for users. (@WhiteXZ) * API: Added fuzzy name searching for users. (@QuiCM)
* API: Fixed ```OnPlayerLogout``` not being fired when a player disconnects. (@nicatronTg) * API: Fixed ```OnPlayerLogout``` not being fired when a player disconnects. (@nicatronTg)
* API: Deprecated ```ValidString``` and ```SanitizeString``` methods in Utils. (@nicatronTg) * API: Deprecated ```ValidString``` and ```SanitizeString``` methods in Utils. (@nicatronTg)
* Added BCrypt password hashing and related systems for it. BCrypt replaces the old system using non-password hashing algorithms for storing passwords. It breaks implementations of the login code that were manually recreated, but is otherwise seamless in transition. (@nicatronTg) * Added BCrypt password hashing and related systems for it. BCrypt replaces the old system using non-password hashing algorithms for storing passwords. It breaks implementations of the login code that were manually recreated, but is otherwise seamless in transition. (@nicatronTg)

View file

@ -4,7 +4,7 @@
<img src="https://ci.appveyor.com/api/projects/status/chhe61q227lqdlg1?svg=true" alt="AppVeyor Build Status"> <img src="https://ci.appveyor.com/api/projects/status/chhe61q227lqdlg1?svg=true" alt="AppVeyor Build Status">
</a> </a>
<a href="https://github.com/Pryaxis/TShock/actions"> <a href="https://github.com/Pryaxis/TShock/actions">
<img src="https://github.com/Pryaxis/TShock/workflows/Build%20Server/badge.svg" alt="GitHub Actions Build Status"> <img src="https://github.com/Pryaxis/TShock/actions/workflows/Build%20Server/badge.svg" alt="GitHub Actions Build Status">
</a> </a>
<a href="#contributors"> <a href="#contributors">
<img src="https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square" alt="All contributors"> <img src="https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square" alt="All contributors">

View file

@ -1,6 +1,6 @@
<p align="center"> <p align="center">
<img src="https://tshock.co/newlogo.png" alt="TShock for Terraria"><br /> <img src="https://tshock.co/newlogo.png" alt="TShock for Terraria"><br />
<a href="https://ci.appveyor.com/project/hakusaro/tshock"><img src="https://ci.appveyor.com/api/projects/status/chhe61q227lqdlg1?svg=true" alt="AppVeyor Build Status"></a><a href="https://github.com/Pryaxis/TShock/actions"><img src="https://github.com/Pryaxis/TShock/workflows/Build%20Server/badge.svg" alt="GitHub Actions Build Status"></a><a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square" alt="All contributors"></a><br /> <a href="https://ci.appveyor.com/project/hakusaro/tshock"><img src="https://ci.appveyor.com/api/projects/status/chhe61q227lqdlg1?svg=true" alt="AppVeyor Build Status"></a><a href="https://github.com/Pryaxis/TShock/actions"><img src="https://github.com/Pryaxis/TShock/actions/workflows/Build%20Server/badge.svg" alt="GitHub Actions Build Status"></a><a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square" alt="All contributors"></a><br />
</p> </p>
TShock是为泰拉瑞亚设计的多功能服务端。它拥有反作弊/强制开荒/用户组/权限管理/物品封禁/大量指令和无限的扩展性。 TShock是为泰拉瑞亚设计的多功能服务端。它拥有反作弊/强制开荒/用户组/权限管理/物品封禁/大量指令和无限的扩展性。

View file

@ -1,13 +1,30 @@
 
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}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
appveyor.yml = appveyor.yml
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci-otapi3-nuget.yml = .github\workflows\ci-otapi3-nuget.yml
.github\workflows\ci-otapi3.yml = .github\workflows\ci-otapi3.yml
COPYING = COPYING
.github\workflows\danger.yml = .github\workflows\danger.yml
README.md = README.md
README_cn.md = README_cn.md
SECURITY.md = SECURITY.md
EndProjectSection
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 +32,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 +45,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 +53,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

@ -45,7 +45,7 @@ namespace TShockAPI.DB
{ {
com.CommandText = query; com.CommandText = query;
for (int i = 0; i < args.Length; i++) for (int i = 0; i < args.Length; i++)
com.AddParameter("@" + i, args[i]); com.AddParameter("@" + i, args[i] ?? DBNull.Value);
return com.ExecuteNonQuery(); return com.ExecuteNonQuery();
} }
} }
@ -65,13 +65,13 @@ namespace TShockAPI.DB
try try
{ {
db.Open(); db.Open();
using (var com = db.CreateCommand()) var com = db.CreateCommand(); // this will be disposed via the QueryResult instance
{ {
com.CommandText = query; com.CommandText = query;
for (int i = 0; i < args.Length; i++) for (int i = 0; i < args.Length; i++)
com.AddParameter("@" + i, args[i]); com.AddParameter("@" + i, args[i]);
return new QueryResult(db, com.ExecuteReader()); return new QueryResult(db, com.ExecuteReader(), com);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -117,13 +117,13 @@ namespace TShockAPI.DB
{ {
var db = olddb.CloneEx(); var db = olddb.CloneEx();
db.Open(); db.Open();
using (var com = db.CreateCommand()) var com = db.CreateCommand(); // this will be disposed via the QueryResult instance
{ {
com.CommandText = query; com.CommandText = query;
foreach (var kv in values) foreach (var kv in values)
com.AddParameter("@" + kv.Key, kv.Value); com.AddParameter("@" + kv.Key, kv.Value);
return new QueryResult(db, com.ExecuteReader()); return new QueryResult(db, com.ExecuteReader(), com);
} }
} }
@ -274,11 +274,13 @@ namespace TShockAPI.DB
{ {
public IDbConnection Connection { get; protected set; } public IDbConnection Connection { get; protected set; }
public IDataReader Reader { get; protected set; } public IDataReader Reader { get; protected set; }
public IDbCommand Command { get; protected set; }
public QueryResult(IDbConnection conn, IDataReader reader) public QueryResult(IDbConnection conn, IDataReader reader, IDbCommand command)
{ {
Connection = conn; Connection = conn;
Reader = reader; Reader = reader;
Command = command;
} }
~QueryResult() ~QueryResult()
@ -301,6 +303,11 @@ namespace TShockAPI.DB
Reader.Dispose(); Reader.Dispose();
Reader = null; Reader = null;
} }
if (Command != null)
{
Command.Dispose();
Command = null;
}
if (Connection != null) if (Connection != null)
{ {
Connection.Dispose(); Connection.Dispose();

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

@ -0,0 +1,34 @@
/*
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;
namespace TShockAPI.Modules
{
public abstract class Module : IDisposable
{
/// <summary>
/// Entry point of the module
/// </summary>
public abstract void Initialise();
/// <summary>
/// Resource cleanup, e.g. hooks and events
/// </summary>
public virtual void Dispose() { }
}
}

View file

@ -0,0 +1,101 @@
/*
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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace TShockAPI.Modules
{
public class ModuleManager : IDisposable
{
private List<Module> _modules = new();
/// <summary>
/// Discovers <see cref="Module"/> derived classes from across the assembly
/// </summary>
/// <returns>Type definitions of the modules that can be created</returns>
IEnumerable<Type> CollectModules() => Assembly.GetExecutingAssembly()
.GetTypes()
.Where(t => typeof(Module).IsAssignableFrom(t) && !t.IsAbstract)
;
/// <summary>
/// Initialises <see cref="Module"/> derived classes defined across the assembly
/// </summary>
/// <param name="parameters">Additional constructor arguments allowed for modules</param>
public void Initialise(object[] parameters)
{
foreach (var moduleType in CollectModules())
InitialiseModule(moduleType, parameters);
}
/// <summary>
/// Initialises a module by its type definition
/// </summary>
/// <param name="moduleType">The type of the module</param>
/// <param name="parameters">Additional constructor arguments allowed for modules</param>
public void InitialiseModule(Type moduleType, object[] parameters)
{
if (!typeof(Module).IsAssignableFrom(moduleType))
throw new NotSupportedException($"Cannot load module {moduleType.FullName} as it does not derive from {typeof(Module).FullName}");
var args = new List<object>();
ConstructorInfo constructor = null;
foreach (var ctor in moduleType.GetConstructors())
{
args.Clear();
var ctorParams = ctor.GetParameters();
foreach (var prm in ctorParams)
{
var matching_objects = parameters.Where(p => prm.ParameterType.IsAssignableFrom(p.GetType()));
if (matching_objects.Count() == 1)
args.Add(matching_objects.Single());
else
{
// skip this ctor since we cannot find a suitable parameter for it.
break;
}
}
if (args.Count() == ctorParams.Length)
constructor = ctor;
}
if (constructor is not null)
{
var module = (Module)constructor.Invoke(args.ToArray());
_modules.Add(module);
module.Initialise();
}
}
/// <summary>
/// Disposes of the module and the manager instance
/// </summary>
public void Dispose()
{
foreach (var module in _modules)
module.Dispose();
_modules.Clear();
}
}
}

View file

@ -0,0 +1,101 @@
/*
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;
namespace TShockAPI.Modules;
public class ReduceConsoleSpam : Module
{
public override void Initialise() =>
OTAPI.Hooks.Main.StatusTextChange += OnMainStatusTextChange;
public override void Dispose() =>
OTAPI.Hooks.Main.StatusTextChange -= OnMainStatusTextChange;
/// <summary>
/// Holds the last status text value, to determine if there is a suitable change to report.
/// </summary>
private string _lastStatusText = null;
/// <summary>
/// Aims to reduce the amount of console spam by filtering out load/save progress
/// </summary>
/// <param name="sender"></param>
/// <param name="e">OTAPI event</param>
private void OnMainStatusTextChange(object sender, OTAPI.Hooks.Main.StatusTextChangeArgs e)
{
void WriteIfChange(string text)
{
if (_lastStatusText != text)
{
Console.WriteLine(text); // write it manually instead of terraria which causes double writes
_lastStatusText = text;
}
}
bool replace(string text)
{
if (e.Value.StartsWith(text))
{
var segment = e.Value.Substring(0, text.Length);
WriteIfChange(segment);
e.Value = "";
return true;
}
return false;
}
if (replace("Resetting game objects")
|| replace("Settling liquids")
|| replace("Loading world data")
|| replace("Saving world data")
|| replace("Validating world save"))
return;
// try parsing % - [text] - %
const string FindMaster = "% - ";
const string FindSub = " - ";
var master = e.Value.IndexOf(FindMaster);
if (master > -1)
{
var sub = e.Value.LastIndexOf(FindSub);
if (master > -1 && sub > master)
{
var mprogress = e.Value.Substring(0, master + 1/*%*/);
var sprogress = e.Value.Substring(sub + FindSub.Length);
if (mprogress.EndsWith("%") && sprogress.EndsWith("%"))
{
var text = e.Value.Substring(master + FindMaster.Length, sub - master - FindMaster.Length).Trim();
if (text.Length > 0 && !(
// relogic has made a mess of this
(
_lastStatusText != "Validating world save"
|| _lastStatusText != "Saving world data"
)
&& text == "Finalizing world"
))
WriteIfChange(text);
e.Value = "";
}
}
}
}
}

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-2022")]
[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.18")]
[assembly: AssemblyFileVersion("4.5.18")]

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,6 @@ using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using MaxMind; using MaxMind;
using Mono.Data.Sqlite;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Newtonsoft.Json; using Newtonsoft.Json;
using Rests; using Rests;
@ -45,6 +44,8 @@ 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;
using TShockAPI.Modules;
namespace TShockAPI namespace TShockAPI
{ {
@ -148,6 +149,8 @@ namespace TShockAPI
/// </summary> /// </summary>
public static event Action Initialized; public static event Action Initialized;
public static ModuleManager ModuleManager { get; } = new ModuleManager();
/// <summary>Version - The version required by the TerrariaAPI to be passed back for checking &amp; loading the plugin.</summary> /// <summary>Version - The version required by the TerrariaAPI to be passed back for checking &amp; loading the plugin.</summary>
/// <value>value - The version number specified in the Assembly, based on the VersionNum variable set in this class.</value> /// <value>value - The version number specified in the Assembly, based on the VersionNum variable set in this class.</value>
public override Version Version public override Version Version
@ -190,6 +193,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,17 +249,14 @@ 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.Hooks.NetMessage.PlayerAnnounceResult.None;
}; };
Main.SettingsUnlock_WorldEvil = true; Main.SettingsUnlock_WorldEvil = true;
@ -269,7 +318,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 Microsoft.Data.Sqlite.SqliteConnection(string.Format("Data Source={0}", sql));
} }
else if (Config.Settings.StorageType.ToLower() == "mysql") else if (Config.Settings.StorageType.ToLower() == "mysql")
{ {
@ -371,6 +420,8 @@ namespace TShockAPI
EnglishLanguage.Initialize(); EnglishLanguage.Initialize();
ModuleManager.Initialise(new object[] { this });
if (Config.Settings.RestApiEnabled) if (Config.Settings.RestApiEnabled)
RestApi.Start(); RestApi.Start();
@ -386,9 +437,15 @@ namespace TShockAPI
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.ConsoleError("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem."); // handle if Log was not initialised
Log.ConsoleError("Until the problem is resolved, TShock will not be able to start (and will crash on startup)."); void SafeError(string message)
Log.ConsoleError(ex.ToString()); {
if(Log is not null) Log.ConsoleError(message);
else Console.WriteLine(message);
};
SafeError("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem.");
SafeError("Until the problem is resolved, TShock will not be able to start (and will crash on startup).");
SafeError(ex.ToString());
Environment.Exit(1); Environment.Exit(1);
} }
} }
@ -414,6 +471,8 @@ namespace TShockAPI
} }
SaveManager.Instance.Dispose(); SaveManager.Instance.Dispose();
ModuleManager.Dispose();
ServerApi.Hooks.GamePostInitialize.Deregister(this, OnPostInit); ServerApi.Hooks.GamePostInitialize.Deregister(this, OnPostInit);
ServerApi.Hooks.GameUpdate.Deregister(this, OnUpdate); ServerApi.Hooks.GameUpdate.Deregister(this, OnUpdate);
ServerApi.Hooks.GameHardmodeTileUpdate.Deregister(this, OnHardUpdate); ServerApi.Hooks.GameHardmodeTileUpdate.Deregister(this, OnHardUpdate);

View file

@ -1,242 +1,59 @@
<?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> <!--
<Prefer32Bit>false</Prefer32Bit> Version information for an assembly consists of the following four values:
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> Major Version
<DebugType>pdbonly</DebugType> Minor Version
<Optimize>true</Optimize> Build Number
<OutputPath>bin\Release\</OutputPath> Starting in version 4.2.5, we are no longer including the fourth decimal
<DefineConstants>TRACE;COMPAT_SIGS</DefineConstants> location, which previously held the date and time.
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> Also, be sure to release on github with the exact assembly version tag as below
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> so that the update manager works correctly (via the Github releases api and mimic)
<DocumentationFile>bin\Release\TShockAPI.XML</DocumentationFile> -->
<PlatformTarget>x86</PlatformTarget> <Version>5.0.0-beta</Version>
<Prefer32Bit>false</Prefer32Bit> <AssemblyTitle>TShock for Terraria</AssemblyTitle>
<Company>Pryaxis &amp; TShock Contributors</Company>
<Product>TShockAPI</Product>
<Copyright>Copyright © Pryaxis &amp; TShock Contributors 2011-2022</Copyright>
<!-- extras for nuget -->
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<Authors>Pryaxis &amp; TShock Contributors</Authors>
<Description>TShock is a toolbox for Terraria servers and communities.</Description>
<PackageId>TShock</PackageId> <!-- package name for nuget, instead of TShockAPI -->
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="MySql.Data" Version="8.0.30" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.8" />
</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> <ItemGroup>
<Compile Include="BackupManager.cs" /> <None Include="..\prebuilts\HttpServer.dll">
<Compile Include="CLI\CommandLineParser.cs" /> <Link>HttpServer.dll</Link>
<Compile Include="CLI\FlagSet.cs" /> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Compile Include="Configuration\ConfigFile.cs" /> <PackageCopyToOutput>true</PackageCopyToOutput>
<Compile Include="Configuration\IConfigFile.cs" /> <Pack>true</Pack>
<Compile Include="Configuration\TShockConfig.cs" /> </None>
<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>
<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="13.0.1" 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,54 @@
using NUnit.Framework;
using Terraria;
using Terraria.Localization;
using TShockAPI;
using TShockAPI.DB;
namespace TShockLauncher.Tests;
public class GroupTests
{
/// <summary>
/// This will be called automatically by nunit before other tests in this class.
/// It serves to initialise the bare minimum variables needed for TShock to be testable without booting up an actual server.
/// </summary>
[SetUp]
public static void SetupTShock()
{
Program.SavePath = ""; // 1.4.4.2 staticness introduced this where by default it is null, and any touch to Terraria.Main will use it and cause a crash.
LanguageManager.Instance.SetLanguage(GameCulture.DefaultCulture); // TShockAPI.Localization will fail without ActiveCulture set
Lang.InitializeLegacyLocalization(); // TShockAPI.Localization will fail without preparing NPC names etc
var ts = new TShock(null); // prepares configs etc
ts.Initialize(); // used to prepare tshocks own static variables, such as the TShock.DB instance
}
/// <summary>
/// This tests to ensure the group commands work.
/// </summary>
/// <remarks>Due to the switch to Microsoft.Data.Sqlite, nulls have to be replaced with DBNull for the query to complete</remarks>
[TestCase]
public void TestPermissions()
{
var groups = TShock.Groups = new GroupManager(TShock.DB);
if (!groups.GroupExists("test"))
groups.AddGroup("test", null, "test", Group.defaultChatColor);
groups.AddPermissions("test", new() { "abc" });
var hasperm = groups.GetGroupByName("test").Permissions.Contains("abc");
Assert.IsTrue(hasperm);
groups.DeletePermissions("test", new() { "abc" });
hasperm = groups.GetGroupByName("test").Permissions.Contains("abc");
Assert.IsFalse(hasperm);
groups.DeleteGroup("test");
var g = groups.GetGroupByName("test");
Assert.IsNull(g);
}
}

View file

@ -0,0 +1,33 @@
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Threading;
namespace TShockLauncher.Tests;
public class ServerInitTests
{
/// <summary>
/// This test will ensure that the TSAPI binary boots up as expected
/// </summary>
[TestCase]
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.IsTrue(hit);
}
}

View file

@ -0,0 +1,25 @@
<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="17.3.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj" />
<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-2022 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 publish 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);
}

View file

@ -0,0 +1,59 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>TShock.Server</AssemblyName> <!-- TShock was initially decided on by a community poll, however tshock already exists as a folder and will clash -->
<RunPostBuildEvent>Always</RunPostBuildEvent>
<DebugType>embedded</DebugType>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> <!-- needed for sqlite native libs -->
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj" ExcludeFromSingleFile="true" />
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj" ExcludeFromSingleFile="true" ReferenceOutputAssembly="false" /> <!-- allow api to rebuilt with this project, so ServerPlugins are refreshed -->
<Reference Include="HttpServer" ExcludeFromSingleFile="true">
<HintPath>..\prebuilts\HttpServer.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="MySql.Data" Version="8.0.30" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.8" />
<PackageReference Include="ModFramework" Version="1.1.2-alpha" GeneratePathProperty="true" /> <!-- only used to extract out to ./bin. -->
<!-- the launcher doesnt need the direct OTAPI reference, but since PackageReference[ExcludeFromSingleFile] doesnt work, exclude the assets and copy manually -->
<PackageReference Include="OTAPI.Upcoming" Version="3.1.7-alpha" ExcludeAssets="all" GeneratePathProperty="true" />
<None Include="$(PkgOTAPI_Upcoming)\lib\net6.0\OTAPI.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
<None Include="$(PkgOTAPI_Upcoming)\lib\net6.0\OTAPI.Runtime.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
<None Include="$(PkgModFramework)\lib\net6.0\ModFramework.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>
<Target Name="CreateServerPlugins" AfterTargets="PostBuildEvent;Publish">
<MakeDir Directories="$(OutDir)ServerPlugins" />
<MakeDir Directories="$(PublishDir)ServerPlugins" />
<ItemGroup>
<ApiFiles Include="$(ProjectDir)../TShockAPI/bin/$(Configuration)/$(TargetFramework)/TShockAPI*" />
</ItemGroup>
<Copy SourceFiles="@(ApiFiles)" DestinationFolder="$(OutDir)ServerPlugins" ContinueOnError="true" />
<Copy SourceFiles="@(ApiFiles)" DestinationFolder="$(PublishDir)ServerPlugins" ContinueOnError="true" />
</Target>
<Target Name="MoveBin" AfterTargets="Publish">
<ItemGroup>
<MoveBinaries Include="$(PublishDir)*" Exclude="$(PublishDir)\TShock.Server*" />
</ItemGroup>
<Move SourceFiles="@(MoveBinaries)" DestinationFolder="$(PublishDir)bin" ContinueOnError="true" />
</Target>
</Project>

@ -1 +1 @@
Subproject commit 4c2075fbdd7e9b17dd96d6495fe9f491a2af0bbb Subproject commit ada183220947c1e44887161431e1ad520eb0e931

View file

@ -1,56 +1,13 @@
version: '{build}' version: '{build}'
max_jobs: 16 max_jobs: 16
image: Visual Studio 2019 image: Visual Studio 2022
build_script: build_script:
- ps: >- - ps: >-
git submodule update --init --recursive git submodule update --init --recursive
cd ./TerrariaServerAPI/ dotnet build TShock.sln
dotnet test
nuget restore TShock.4.OTAPI.sln
msbuild TShock.4.OTAPI.sln /p:Configuration=Debug
cd ./TShock.Modifications.Bootstrapper/bin/Debug/
./TShock.Modifications.Bootstrapper.exe
cd ../../../
msbuild ./TerrariaServerAPI/TerrariaServerAPI.csproj /p:Configuration=Debug
msbuild TShock.4.OTAPI.sln /p:Configuration=Release
cd ./TShock.Modifications.Bootstrapper/bin/Release/
./TShock.Modifications.Bootstrapper.exe
cd ../../../
msbuild ./TerrariaServerAPI/TerrariaServerAPI.csproj /p:Configuration=Release
cd ../
nuget restore TShock.sln
msbuild ./TShockAPI/TShockAPI.csproj /p:Configuration=Release
msbuild ./TShockAPI/TShockAPI.csproj /p:Configuration=Debug
artifacts: artifacts:
- path: ./TShockAPI/bin/Debug/ - path: ./TShockLauncher/bin/Debug/net6.0
name: TShockAVDebug name: TShockAVDebug
- path: ./TShockAPI/bin/Release/
name: TShockAVRelease

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.