diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index fda7514d..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/ci-otapi3-nuget.yml b/.github/workflows/ci-otapi3-nuget.yml new file mode 100644 index 00000000..7d979bf0 --- /dev/null +++ b/.github/workflows/ci-otapi3-nuget.yml @@ -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 diff --git a/.github/workflows/ci-otapi3.yml b/.github/workflows/ci-otapi3.yml new file mode 100644 index 00000000..72414ef5 --- /dev/null +++ b/.github/workflows/ci-otapi3.yml @@ -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 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..a4795b3a --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..e8db5b18 --- /dev/null +++ b/.vscode/tasks.json @@ -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" + ] + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 2940e13e..bd7736bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. ## 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 * 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 * 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) * Terraria Server API version tick: 2.1 * 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) * 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) ## TShock 4.3.23 * 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) -* Resolved issues with mob and item spawning. Thanks to @OnsenManju for your investigative work :) (@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 :) (@QuiCM) * Patched a crashing exploit (@Simon311) ## TShock 4.3.22 * Compatibility with Terraria 1.3.4.4 * API: Version tick 2.0 * API: Reduced RAM usage by ~80MB (Large server) (@deathcradle) -* API: Added TSPlayer.KillPlayer() (@WhiteXZ) +* API: Added TSPlayer.KillPlayer() (@QuiCM) * API: Added TSPlayer.Logout() (@ProfessorXZ) * Fixed connections after max slot is reached (@DeathCradle) * Fixed server crashes caused by client disconnections when attempting to read closed sockets (@Enerdy) * 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) -* REST: `/v3/players/read` now includes a `muted` field (@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 (@QuiCM) * 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: 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). * Added associated config option for HealOtherPlayer exploit prevention (@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). * Implemented some missing balance changes lost in prior version patches (@DogooFalchion). * Added alias for server shutdown command: stop (@nicatronTg). * Removed the old REST model. This includes the following endpoints: * `/status` * `/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). * 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). * 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 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 * 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). * 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 wyverns despawning & not behaving like normal (@WhiteXZ). -* Fixed major security issue where InvokeClientConnect could be exploited to do terrible, terrible things (@Simon311, @nicatronTg, @popstarfreas, @ProfessorXZ, @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, @QuiCM). ## TShock 4.3.19 * Compatibility with Terraria 1.3.3.3 (@Simon311) * API: Version tick 1.25 -* API: Resolved some issues with the ItemForceIntoChest hook (@WhiteXZ, @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 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, @QuiCM, @nicatronTg) * Fixed magical ice blocks not working correctly (@ProfessorXZ) ## 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 * API: Version tick 1.24 * 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) * The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju) * 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) * 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) -* Added a command to start and stop sandstorms (@WhiteXZ) +* Added a command to start and stop sandstorms (@QuiCM) ## TShock 4.3.17 * Compatibility with Terraria 1.3.2.1 -* Updated superadmin behaviour to conform to expected behaviour (@WhiteXZ, @Patrikk) -* Fixed a crash involving teleporters and dressers (@WhiteXZ) +* Updated superadmin behaviour to conform to expected behaviour (@QuiCM, @Patrikk) +* Fixed a crash involving teleporters and dressers (@QuiCM) * Fixed pressure plates (@Enerdy, @Patrikk) * Fixed a deadlock in wiring (@Wolfje) * Fixed a crash in wiring (@Patrikk) * Improved network syncing on client joins (@Patrikk) * 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) * The currently running world name is now part of the server application's title (@webmilio) * 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 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) -* Resolved an issue where martian invasions and eclipses would have empty messages if AnonymousBossInvasions was set to true (@WhiteXZ) -* Added an optional `slime` parameter to the `rain` command, allowing slime rain to be started and stopped. New syntax is `rain [slime] ` (@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] ` (@QuiCM) * Fixed performance issues due to concurrent dictionary access in TSPlayer (@CoderCow) -* Added an ID property to Regions (@WhiteXZ) -* Fixed an issue where region sizes were calculated incorrectly (@WhiteXZ) +* Added an ID property to Regions (@QuiCM) +* Fixed an issue where region sizes were calculated incorrectly (@QuiCM) * 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 * Removed the `/token/create` REST endpoint. `/v2/token/create` should be used instead. ## TShock 4.3.12 -* Fixed issues with TSPlayer.SetTeam not working (@WhiteXZ) -* Fixed /butcher not killing bosses in expert difficulty (@WhiteXZ) -* API: Deprecated PacketBufferer (now obviated by SendQ) (@WhiteXZ) +* Fixed issues with TSPlayer.SetTeam not working (@QuiCM) +* Fixed /butcher not killing bosses in expert difficulty (@QuiCM) +* API: Deprecated PacketBufferer (now obviated by SendQ) (@QuiCM) * API: Building on Windows no longer breaks traps (@Wolfje) * Fixed bombs, dynamite, and sticky bombs (@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 adding a ban on a player who has previously been banned (@Wolfje) * Fixed /invade martian (@Wolfje) -* Fixed target dummies not working properly (@WhiteXZ) -* Added a config option (DisableSecondUpdateLogs) to prevent log spam from OnSecondUpdate() (@WhiteXZ) +* Fixed target dummies not working properly (@QuiCM) +* Added a config option (DisableSecondUpdateLogs) to prevent log spam from OnSecondUpdate() (@QuiCM) * Added RESTful API login 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 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 IP bans not working correctly (@hastinbe) -* Fixed /reload not using the correct permission (@WhiteXZ) -* Fixed TSPlayer.ActiveChest not being tracked correctly resulting in item dupes while disabled (@WhiteXZ) +* Fixed /reload not using the correct permission (@QuiCM) +* Fixed TSPlayer.ActiveChest not being tracked correctly resulting in item dupes while disabled (@QuiCM) * /reload now reloads tile and projectile bans ## 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) * Fixed /login permitting multiple logins without a logout in between. (@nicatronTg) -* Allow[Hallow/Corruption/Crimson]Creep in config now work. (@WhiteXZ) -* API: Treasure bags are now named properly. (@WhiteXZ) +* Allow[Hallow/Corruption/Crimson]Creep in config now work. (@QuiCM) +* API: Treasure bags are now named properly. (@QuiCM) * API: Clients no longer close on disconnect. (@Wolfje) * API: Add server broadcast hook. (@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 -* 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: Removed support for favorites and removed JSON dependencies. (@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 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: 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: Lots and I mean lots of network improvements in the SendQ department. (@tylerjwatson) * 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. * 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) -* Updated projectile handling in GetDataHandlers. (@WhiteXZ) -* Fixed issue #992. (@WhiteXZ) -* Teleport handler now handles wormholes. (@WhiteXZ) -* Fixed tall gates and trap doors (issue #998). (@WhiteXZ) -* Added monoliths to orientable tiles (issue #999). (@WhiteXZ) -* Fixed vortex stealth armor (issue #964). (@WhiteXZ) -* Added moon lord to spawn boss. (@WhiteXZ) +* Updated projectile handling in GetDataHandlers. (@QuiCM) +* Fixed issue #992. (@QuiCM) +* Teleport handler now handles wormholes. (@QuiCM) +* Fixed tall gates and trap doors (issue #998). (@QuiCM) +* Added monoliths to orientable tiles (issue #999). (@QuiCM) +* Fixed vortex stealth armor (issue #964). (@QuiCM) +* Added moon lord to spawn boss. (@QuiCM) * Fixed serverpassword syntax error error message. (@JordyMoos) -* Fixed issue #1019. (@WhiteXZ) +* Fixed issue #1019. (@QuiCM) * Fix: Region protection prevents placement of objects. (@Patrikkk) * Moved all startup parameters to TShock. (@Cleant) * Fix: Target dummies are no longer butchered. (@Denway) * 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) ## 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 -* Fix invasion progress messages (@WhiteXZ) +* Fix invasion progress messages (@QuiCM) * Completely rewrite SendQ to have less deadlocks (@tylerjwatson) ## TShock 4.3.3 * Fix dihydrogen monoxide (@tylerjwatson) -* Whitelist another boss projectile (@Patrikkk, @WhiteXZ) +* Whitelist another boss projectile (@Patrikkk, @QuiCM) ## TShock 4.3.2 -* Fixed the issue where using the Super Absorbent Sponge would disable users (@WhiteXZ) -* Fixed an issue in NetGetData where e.Length - 1 would be -1 (@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 (@QuiCM) * Fixed /who -i and /userinfo (@Enerdy) * API: OnRegionEntered hook now returns the region entered (@Patrikkk) * Support for Terraria 1.3.0.4 (@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 several potential crashes in server (@Patrikkk) -* Fixed -autocreate command line argument (@WhiteXZ, @nicatronTg) -* Added more world data to world load menu (@WhiteXZ) +* Fixed -autocreate command line argument (@QuiCM, @nicatronTg) +* Added more world data to world load menu (@QuiCM) * Moved server password to TShock config (@Enerdy) * 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) * API: Updated TSPlayer.Disable to use new buffs (@Enerdy) * 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 @@ -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) * DisableTombstones now works properly with the new golden gravestones. (@Enerdy) * 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 worldinfo packet. (@WhiteXZ) +* Fixed worldinfo packet. (@QuiCM) * Fixed server passwords. (@Enerdy) ## 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) * 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) -* 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 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: 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) diff --git a/README.md b/README.md index ebc852bb..7a5ae50c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ AppVeyor Build Status - GitHub Actions Build Status + GitHub Actions Build Status All contributors diff --git a/README_cn.md b/README_cn.md index 70d3c33e..83a62f97 100644 --- a/README_cn.md +++ b/README_cn.md @@ -1,6 +1,6 @@

TShock for Terraria
-
AppVeyor Build StatusGitHub Actions Build StatusAll contributors
+ AppVeyor Build StatusGitHub Actions Build StatusAll contributors

TShock是为泰拉瑞亚设计的多功能服务端。它拥有反作弊/强制开荒/用户组/权限管理/物品封禁/大量指令和无限的扩展性。 diff --git a/TShock.sln b/TShock.sln index af79472c..7e9acded 100644 --- a/TShock.sln +++ b/TShock.sln @@ -1,13 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31825.309 MinimumVisualStudioVersion = 10.0.40219.1 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 -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 -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 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,10 +32,6 @@ Global Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x64 = Debug|x64 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|Mixed Platforms = Release|Mixed Platforms 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.Build.0 = 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}.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}.Debug|x86.Build.0 = Debug|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|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.Build.0 = 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 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.ActiveCfg = Debug|x64 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.Build.0 = Debug|x64 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.ActiveCfg = Debug|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.Build.0 = Debug|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Any CPU.ActiveCfg = Mono|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Mixed Platforms.ActiveCfg = Mono|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Mixed Platforms.Build.0 = Mono|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x64.ActiveCfg = Mono|x64 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x64.Build.0 = Mono|x64 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x86.ActiveCfg = Mono|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x86.Build.0 = Mono|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.ActiveCfg = Release|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.Build.0 = Release|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.ActiveCfg = Release|x64 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.Build.0 = Release|x64 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.ActiveCfg = Release|x86 - {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.Build.0 = Release|x86 + {49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.Build.0 = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.ActiveCfg = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.Build.0 = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.ActiveCfg = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.Build.0 = Debug|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.Build.0 = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.ActiveCfg = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.Build.0 = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.ActiveCfg = Release|Any CPU + {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.Build.0 = Release|Any CPU + {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A312452-A43F-43E3-8AEB-E22F9A35C210}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B56F0765-BADD-48CF-8A19-436BD0EAD34A} + EndGlobalSection GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = Terraria.vsmdi EndGlobalSection diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 0f578998..469b6ee9 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -22,7 +22,6 @@ using Terraria.ID; using TShockAPI.Net; using Terraria; using Microsoft.Xna.Framework; -using OTAPI.Tile; using TShockAPI.Localization; using static TShockAPI.GetDataHandlers; using Terraria.ObjectData; diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 6b7f3259..af5b06e4 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -33,7 +33,6 @@ using TerrariaApi.Server; using TShockAPI.Hooks; using Terraria.GameContent.Events; using Microsoft.Xna.Framework; -using OTAPI.Tile; using TShockAPI.Localization; using System.Text.RegularExpressions; using Terraria.DataStructures; diff --git a/TShockAPI/Extensions/DbExt.cs b/TShockAPI/Extensions/DbExt.cs index b4fc7c31..5785becb 100644 --- a/TShockAPI/Extensions/DbExt.cs +++ b/TShockAPI/Extensions/DbExt.cs @@ -45,7 +45,7 @@ namespace TShockAPI.DB { com.CommandText = query; for (int i = 0; i < args.Length; i++) - com.AddParameter("@" + i, args[i]); + com.AddParameter("@" + i, args[i] ?? DBNull.Value); return com.ExecuteNonQuery(); } } @@ -65,13 +65,13 @@ namespace TShockAPI.DB try { db.Open(); - using (var com = db.CreateCommand()) + var com = db.CreateCommand(); // this will be disposed via the QueryResult instance { com.CommandText = query; for (int i = 0; i < args.Length; i++) com.AddParameter("@" + i, args[i]); - return new QueryResult(db, com.ExecuteReader()); + return new QueryResult(db, com.ExecuteReader(), com); } } catch (Exception ex) @@ -117,13 +117,13 @@ namespace TShockAPI.DB { var db = olddb.CloneEx(); db.Open(); - using (var com = db.CreateCommand()) + var com = db.CreateCommand(); // this will be disposed via the QueryResult instance { com.CommandText = query; foreach (var kv in values) 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 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; Reader = reader; + Command = command; } ~QueryResult() @@ -301,6 +303,11 @@ namespace TShockAPI.DB Reader.Dispose(); Reader = null; } + if (Command != null) + { + Command.Dispose(); + Command = null; + } if (Connection != null) { Connection.Dispose(); diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index b766763d..ace40b78 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -34,7 +34,6 @@ using Terraria.DataStructures; using Terraria.GameContent.Tile_Entities; using Terraria.Localization; using Microsoft.Xna.Framework; -using OTAPI.Tile; using TShockAPI.Localization; using TShockAPI.Models; using TShockAPI.Models.PlayerUpdate; diff --git a/TShockAPI/Handlers/SendTileRectHandler.cs b/TShockAPI/Handlers/SendTileRectHandler.cs index dbe80ec6..c165a267 100644 --- a/TShockAPI/Handlers/SendTileRectHandler.cs +++ b/TShockAPI/Handlers/SendTileRectHandler.cs @@ -1,6 +1,4 @@ -using OTAPI.Tile; - -using System; +using System; using System.Collections.Generic; using System.Linq; diff --git a/TShockAPI/ItemBans.cs b/TShockAPI/ItemBans.cs index 2fa9e85e..9f951ed2 100644 --- a/TShockAPI/ItemBans.cs +++ b/TShockAPI/ItemBans.cs @@ -23,7 +23,6 @@ using TShockAPI.DB; using TShockAPI.Net; using Terraria; using Microsoft.Xna.Framework; -using OTAPI.Tile; using TShockAPI.Localization; using static TShockAPI.GetDataHandlers; using TerrariaApi.Server; diff --git a/TShockAPI/Modules/Module.cs b/TShockAPI/Modules/Module.cs new file mode 100644 index 00000000..20bef23b --- /dev/null +++ b/TShockAPI/Modules/Module.cs @@ -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 . +*/ +using System; +namespace TShockAPI.Modules +{ + public abstract class Module : IDisposable + { + /// + /// Entry point of the module + /// + public abstract void Initialise(); + + /// + /// Resource cleanup, e.g. hooks and events + /// + public virtual void Dispose() { } + } +} + diff --git a/TShockAPI/Modules/ModuleManager.cs b/TShockAPI/Modules/ModuleManager.cs new file mode 100644 index 00000000..c1458fb6 --- /dev/null +++ b/TShockAPI/Modules/ModuleManager.cs @@ -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 . +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace TShockAPI.Modules +{ + public class ModuleManager : IDisposable + { + private List _modules = new(); + + /// + /// Discovers derived classes from across the assembly + /// + /// Type definitions of the modules that can be created + IEnumerable CollectModules() => Assembly.GetExecutingAssembly() + .GetTypes() + .Where(t => typeof(Module).IsAssignableFrom(t) && !t.IsAbstract) + ; + + /// + /// Initialises derived classes defined across the assembly + /// + /// Additional constructor arguments allowed for modules + public void Initialise(object[] parameters) + { + foreach (var moduleType in CollectModules()) + InitialiseModule(moduleType, parameters); + } + + /// + /// Initialises a module by its type definition + /// + /// The type of the module + /// Additional constructor arguments allowed for modules + 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(); + 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(); + } + } + + /// + /// Disposes of the module and the manager instance + /// + public void Dispose() + { + foreach (var module in _modules) + module.Dispose(); + _modules.Clear(); + } + } +} + diff --git a/TShockAPI/Modules/ReduceConsoleSpam.cs b/TShockAPI/Modules/ReduceConsoleSpam.cs new file mode 100644 index 00000000..40e0fbfc --- /dev/null +++ b/TShockAPI/Modules/ReduceConsoleSpam.cs @@ -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 . +*/ +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; + + /// + /// Holds the last status text value, to determine if there is a suitable change to report. + /// + private string _lastStatusText = null; + + /// + /// Aims to reduce the amount of console spam by filtering out load/save progress + /// + /// + /// OTAPI event + 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 = ""; + } + } + } + } + +} + diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs deleted file mode 100644 index f4d9e4d5..00000000 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ /dev/null @@ -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 . -*/ - -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")] diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 1aa7203d..194d11f0 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -25,7 +25,6 @@ using System.IO; using System.Text; using System.Threading; using System.Timers; -using OTAPI.Tile; using Terraria; using Terraria.DataStructures; using Terraria.ID; diff --git a/TShockAPI/TSServerPlayer.cs b/TShockAPI/TSServerPlayer.cs index 14ea674b..33f1ffe5 100644 --- a/TShockAPI/TSServerPlayer.cs +++ b/TShockAPI/TSServerPlayer.cs @@ -17,7 +17,6 @@ along with this program. If not, see . */ using Microsoft.Xna.Framework; -using OTAPI.Tile; using System; using System.Collections.Generic; using Terraria; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 5bd88598..a2c52ad3 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -28,7 +28,6 @@ using System.Linq; using System.Net; using System.Reflection; using MaxMind; -using Mono.Data.Sqlite; using MySql.Data.MySqlClient; using Newtonsoft.Json; using Rests; @@ -45,6 +44,8 @@ using TShockAPI.CLI; using TShockAPI.Localization; using TShockAPI.Configuration; using Terraria.GameContent.Creative; +using System.Runtime.InteropServices; +using TShockAPI.Modules; namespace TShockAPI { @@ -148,6 +149,8 @@ namespace TShockAPI /// public static event Action Initialized; + public static ModuleManager ModuleManager { get; } = new ModuleManager(); + /// Version - The version required by the TerrariaAPI to be passed back for checking & loading the plugin. /// value - The version number specified in the Assembly, based on the VersionNum variable set in this class. public override Version Version @@ -190,6 +193,55 @@ namespace TShockAPI instance = this; } + + static Dictionary _nativeCache = new Dictionary(); + static IntPtr ResolveNativeDep(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) + { + if (_nativeCache.TryGetValue(libraryName, out IntPtr cached)) + return cached; + + IEnumerable matches = Enumerable.Empty(); + + 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; + } + /// Initialize - Called by the TerrariaServerAPI during initialization. [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] public override void Initialize() @@ -197,17 +249,14 @@ namespace TShockAPI string logFilename; string logPathSetupWarning; - OTAPI.Hooks.Net.Socket.Create = () => + OTAPI.Hooks.Netplay.CreateTcpListener += (sender, args) => { - //Console.WriteLine($"Creating socket {nameof(LinuxTcpSocket)}"); - return new LinuxTcpSocket(); - //return new OTAPI.Sockets.PoolSocket(); - //return new Terraria.Net.Sockets.TcpSocket(); + args.Result = new LinuxTcpSocket(); }; - OTAPI.Hooks.Player.Announce = (int playerId) => + OTAPI.Hooks.NetMessage.PlayerAnnounce += (sender, args) => { //TShock handles this - return OTAPI.HookResult.Cancel; + args.Result = OTAPI.Hooks.NetMessage.PlayerAnnounceResult.None; }; Main.SettingsUnlock_WorldEvil = true; @@ -269,7 +318,7 @@ namespace TShockAPI { string sql = Path.Combine(SavePath, Config.Settings.SqliteDBPath); 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") { @@ -371,6 +420,8 @@ namespace TShockAPI EnglishLanguage.Initialize(); + ModuleManager.Initialise(new object[] { this }); + if (Config.Settings.RestApiEnabled) RestApi.Start(); @@ -386,9 +437,15 @@ namespace TShockAPI } catch (Exception ex) { - Log.ConsoleError("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem."); - Log.ConsoleError("Until the problem is resolved, TShock will not be able to start (and will crash on startup)."); - Log.ConsoleError(ex.ToString()); + // handle if Log was not initialised + void SafeError(string message) + { + 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); } } @@ -414,6 +471,8 @@ namespace TShockAPI } SaveManager.Instance.Dispose(); + ModuleManager.Dispose(); + ServerApi.Hooks.GamePostInitialize.Deregister(this, OnPostInit); ServerApi.Hooks.GameUpdate.Deregister(this, OnUpdate); ServerApi.Hooks.GameHardmodeTileUpdate.Deregister(this, OnHardUpdate); diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 146fea27..f03f4c42 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -1,242 +1,59 @@  - + + - Debug - AnyCPU - {49606449-072B-4CF5-8088-AA49DA586694} Library - Properties - TShockAPI - TShockAPI - v4.5 - 512 - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + net6.0 true - bin\Debug\TShockAPI.XML - x86 - false - - - pdbonly - true - bin\Release\ - TRACE;COMPAT_SIGS - prompt - 4 - true - bin\Release\TShockAPI.XML - x86 - false + True + + 5.0.0-beta + TShock for Terraria + Pryaxis & TShock Contributors + TShockAPI + Copyright © Pryaxis & TShock Contributors 2011-2022 + + True + GPL-3.0-or-later + Pryaxis & TShock Contributors + TShock is a toolbox for Terraria servers and communities. + TShock + + + + + + + + + + + - - ..\packages\BCrypt.Net.0.1.0\lib\net35\BCrypt.Net.dll - True - ..\prebuilts\HttpServer.dll - - ..\prebuilts\Mono.Data.Sqlite.dll - - - ..\packages\MySql.Data.6.9.8\lib\net45\MySql.Data.dll - True - - - ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - - - False - ..\TerrariaServerAPI\TerrariaServerAPI\bin\$(ConfigurationName)\OTAPI.dll - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - + + HttpServer.dll + PreserveNewest + true + true + - - - - - - - - ResXFileCodeGenerator - Designer - Resources.Designer.cs - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - - - {6877506e-adc6-4142-98a6-79e4fa02855a} - TerrariaServerAPI - - - - - - - - - - - - - - - - - - + diff --git a/TShockAPI/app.config b/TShockAPI/app.config deleted file mode 100644 index 1565cd9f..00000000 --- a/TShockAPI/app.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/TShockAPI/packages.config b/TShockAPI/packages.config deleted file mode 100644 index b0cddcdc..00000000 --- a/TShockAPI/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TShockAPI/web.config b/TShockAPI/web.config deleted file mode 100644 index 74c0d886..00000000 --- a/TShockAPI/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/TShockLauncher.Tests/GroupTests.cs b/TShockLauncher.Tests/GroupTests.cs new file mode 100644 index 00000000..61a70b33 --- /dev/null +++ b/TShockLauncher.Tests/GroupTests.cs @@ -0,0 +1,54 @@ +using NUnit.Framework; +using Terraria; +using Terraria.Localization; +using TShockAPI; +using TShockAPI.DB; + +namespace TShockLauncher.Tests; + +public class GroupTests +{ + /// + /// 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. + /// + [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 + } + + /// + /// This tests to ensure the group commands work. + /// + /// Due to the switch to Microsoft.Data.Sqlite, nulls have to be replaced with DBNull for the query to complete + [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); + } +} + diff --git a/TShockLauncher.Tests/ServerInitTests.cs b/TShockLauncher.Tests/ServerInitTests.cs new file mode 100644 index 00000000..dc5f6731 --- /dev/null +++ b/TShockLauncher.Tests/ServerInitTests.cs @@ -0,0 +1,33 @@ +using NUnit.Framework; +using System; +using System.Diagnostics; +using System.Threading; + +namespace TShockLauncher.Tests; + +public class ServerInitTests +{ + /// + /// This test will ensure that the TSAPI binary boots up as expected + /// + [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); + } +} + diff --git a/TShockLauncher.Tests/TShockLauncher.Tests.csproj b/TShockLauncher.Tests/TShockLauncher.Tests.csproj new file mode 100644 index 00000000..e560d5d1 --- /dev/null +++ b/TShockLauncher.Tests/TShockLauncher.Tests.csproj @@ -0,0 +1,25 @@ + + + + net6.0 + enable + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/TShockLauncher/Program.cs b/TShockLauncher/Program.cs new file mode 100644 index 00000000..0410f341 --- /dev/null +++ b/TShockLauncher/Program.cs @@ -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 . +*/ + +/* + * 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 _cache = new Dictionary(); + +System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving; + +Start(); + +/// +/// Resolves a module from the ./bin folder, either with a .dll by preference or .exe +/// +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; +} + +/// +/// Initiates the TSAPI server. +/// +/// This method exists so that the resolver can attach before TSAPI needs its dependencies. +void Start() +{ + TerrariaApi.Server.Program.Main(args); +} diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj new file mode 100644 index 00000000..6ac080fc --- /dev/null +++ b/TShockLauncher/TShockLauncher.csproj @@ -0,0 +1,59 @@ + + + + Exe + net6.0 + enable + enable + TShock.Server + Always + embedded + true + + + + + + + ..\prebuilts\HttpServer.dll + + + + + + + + + + + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 4c2075fb..ada18322 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 4c2075fbdd7e9b17dd96d6495fe9f491a2af0bbb +Subproject commit ada183220947c1e44887161431e1ad520eb0e931 diff --git a/appveyor.yml b/appveyor.yml index 245dbcdc..a96c0049 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,56 +1,13 @@ version: '{build}' max_jobs: 16 -image: Visual Studio 2019 +image: Visual Studio 2022 build_script: - ps: >- git submodule update --init --recursive - cd ./TerrariaServerAPI/ + dotnet build TShock.sln - - 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 + dotnet test artifacts: -- path: ./TShockAPI/bin/Debug/ +- path: ./TShockLauncher/bin/Debug/net6.0 name: TShockAVDebug -- path: ./TShockAPI/bin/Release/ - name: TShockAVRelease diff --git a/prebuilts/Mono.Data.Sqlite.dll b/prebuilts/Mono.Data.Sqlite.dll deleted file mode 100644 index ce600dbc..00000000 Binary files a/prebuilts/Mono.Data.Sqlite.dll and /dev/null differ diff --git a/prebuilts/sqlite3.def b/prebuilts/sqlite3.def deleted file mode 100644 index caa046e3..00000000 --- a/prebuilts/sqlite3.def +++ /dev/null @@ -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 diff --git a/prebuilts/sqlite3.dll b/prebuilts/sqlite3.dll deleted file mode 100755 index d1b9cb82..00000000 Binary files a/prebuilts/sqlite3.dll and /dev/null differ