Code Monkey home page Code Monkey logo

tsapi's People

Contributors

andriocelos avatar axeelander avatar axiskriel avatar aylinni-empyrea avatar bartico6 avatar celant avatar codercow avatar edg-l avatar hakusaro avatar ivanbiljan avatar marioe avatar mistzzt avatar moisterrific avatar patrikkk avatar pilihp64 avatar quicm avatar renovate[bot] avatar ristellise avatar signaturebeef avatar simon311 avatar stealownz avatar stevenh avatar sunjayc avatar tomylobo avatar tylerjwatson avatar tysonstrange avatar whitexz avatar zaicon avatar zakfahey avatar zidonuke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tsapi's Issues

Add license

This repo no longer has the full decompile of the Terraria Server source code. Therefore, we should have our GPL v3 stamp on everything in this repo too (as we do for TShock).

That is, we just need to copy the COPYING file from TShock and put it here.

Rename packet 82

The name of packet [82] (https://github.com/Pryaxis/TerrariaAPI-Server/blob/28200f7d4447ee275e85856f97eee58fa156ffc4/TerrariaServerAPI/TerrariaApi.Server/PacketTypes.cs#L88) is misleading - it does not cause any netmodule to be loaded, as netmodules are loaded on server startup when NetManager.Initialize() is called.

It's an issue rather than PR as we should decide on which name will fit the most, as we'd like to avoid incidents like d8c7be1, da8fded and 28200f7 due to poor communication of the change.

I personally opt to rename it to simply NetModule, as that's exactly what it contains. It's a minor change, though.

TSApi for Terraria 1.3.3.x Updated File List

This issue should be updated as changes are added. Anything listed here should be considered completed.
If you have PRed a file or files, please tag me in a reply to this issue to have them added to the list.

  • Projectile.cs
  • GlowMaskID.cs
  • Recipe.cs
  • TileID.cs
  • ProjectileID.cs
  • ExtrasID.cs
  • DustID.cs
  • BuffID.cs
  • NPCID.cs
  • ItemID.cs
  • ArmorID.cs
  • Lang.cs
  • MessageBuffer.cs
  • TileObjectData.cs
  • Sandstorm.cs
  • NetMessage.cs
  • FixEploitManEaters.cs (seems like they made a typo in the file name here)
  • Worldgen.cs
  • NPC.cs
  • MountID.cs
  • GoreID.cs
  • WorldFile.cs
  • ISocket.cs
  • TcpSocket.cs
  • WeightedRandom.cs
  • Utils.cs
  • MethodSequenceListItem.cs
  • PlayerDeathReason.cs
  • Mount.cs
  • Item.cs
  • Main.cs

Sand Elementals despawning

First of all, I wasn't sure if it was a TShock or TAPI issue, but since there was something similar for wyverns, here goes...
No matter what I try, I can't get Sand Elementals to spawn properly. If spawned with /sm they briefly appear then immediately (a fraction of a second) despawn. Tried this both in the middle of a sandstorm and with no sandstorm ongoing.
If causing a sandstorm and increasing the spawnrate, you get a ton of... well, everything desert-related, except for elementals. I waited around 5 minutes and nothing.

The two methods above were tried on a completely clean install of TShock 4.3.20. The last one I'm adding below was my attempt at bruteforcing the problem: I used Diemob to replace some other mob so it turned into a sand elemental, and the same as spawning them with command, they just dissapear after a fraction of a second. Why did I try this? It worked for turning the Explosive Snowman into a mob with an actual AI, so yeah...

Thread race on incoming connections (findNextOpenClientSlot)

Reported by GameRoom on Slack:

I just found a bug with Terraria's netcode. It's somewhat specific to my server since it'd be rare to replicate outside of the stuff we're doing, but it's kind of general I guess. Essentially, if multiple players join the server at the exact same time, the findNextOpenClientSlot method can have 2 players go into the same slot since it's multithreaded
I found it on ours since we redirect all our players to different servers when they shut down. Other than that I doubt it could happen naturally but whatever
I put a lock statement around the contents of Netplay.OnConnectionAccepted and it works fine now

making a pull request

[8:48]  
oh apparently I don't have write access

[8:50]  
I just changed a few lines in Netplay.cs:
public static bool spamCheck = false;
public static bool anyClients = false;
**private static object slotLock = new object();**

...

        private static void OnConnectionAccepted(ISocket client)
        {
           **lock(slotLock)**
           {
               int num = Netplay.FindNextOpenClientSlot();
               if(num != -1)
               {
                   Netplay.Clients[num].Reset();
                   Netplay.Clients[num].Socket = client;
                   Console.WriteLine(client.GetRemoteAddress() + " is connecting...");
               }
               if(Netplay.FindNextOpenClientSlot() == -1)
               {
                   Netplay.StopListening();
               }
           }

ServerPlugins directory should be in the executing directory, not the working directory

When starting the TerrariaServer.exe while the current working directory differs from the directory containing the .exe, the ServerPlugins directory is assumed to be inside the working directory.

To reproduce the problem I'm trying to describe, assume the following.

  • There's an installation of TShock inside the directory D:\Servers\01_TShock
  • There's a run.bat inside the directory D:\Servers\ with the following content
start D:\Servers\01_TShock\TerrariaServer.exe 

When starting the run.bat, it would be expected, that the server starts normally, loading the plugins from the directory D:\Servers\01_TShock\ServerPlugins. Instead, the directory D:\Servers\01_TShock\ServerPlugins is not used and a directory C:\Servers\ServerPlugins will be created.

The cause for this is, that in ServerApi.cs:94 Environment.CurrentDirectory is used instead of the directory of the executing assembly.

The ServerLog.txt is also created inside the working directory (ServerLogWriter.cs:19).

I'm not sure if this is intended or not, but @QuiCM agreed with me on discord and asked me to create this issue.

Joining with same name kicks the other

It used to be that if "Panther" was already online, trying to join with another player called "Panther" would be met with "Panther is already online", but now it kicks the player in game and lets this new player join.

I think its SendQ, as I noticed it around that time, but now people are catching on and causing problems.

Repeated leaves and joins results in being stuck at "Found Server"

Steps leading up to this issue:

  • Created a new world (small, non-expert) via server console
  • Opened world
  • Joined and disconnected as fast as possible with one character, 7 times

After a not attempting to connect for ~10 seconds, I was once again able to connect, however quickly disconnecting and attempting to reconnect once again results in being stuck at "Found Server".

Wyverns despawn

Tracking a TShock reported issue from Pryaxis/TShock#1297 here. Wyverns need to not despawn and need to function as normal. According to @ProfessorXz, the solution might be to re-diff and see if we missed something.

Use SocketAsyncEventArgs

Using SocketAsyncEventArgs could greatly improve performance when compared to using the Begin/End Socket methods.

Benefits:

  • Non-blocking.
  • Reduce strain on the GC by pre-allocating SocketAsyncEventArgs objects (also doesn't create an IAsyncResult object on each call).
  • Can prevent memory fragmentation from occurring.
  • SocketAsyncEventArgs does not block when the buffer is full (compared to Begin/End).

API crashes on startup on Chinese language systems?

I'm not entirely sure about the root cause here, but a user reported having issues with the API starting on Chinese, English systems.

ServerLog.txt
ServerLog (1).txt

It wasn't TShock related, and it wasn't file permissions related, I assume some weird quirk about how either we're compiling TSAPI or how the decompile works is causing this. He said TShock 4.0 started fine, and also said the normal server starts fine. Without TShock, it crashes, and with it, it crashes.

Time Skipping is still a known issue.

Apart from monster skipping, which simply is to be resolved by Re-Logic which probably will be buried deep down in the ground I'd like to share that Time Skipping is still a known issue in the latest OTAPI Pre-Release. It has improved quite a lot from TSAPI but it remains an issue which should be fixed if possible.

Create a crash reporter

There is a need for TSAPI to inform us of a crash report. The crash report will be in JSON format and submitted to a TShock endpoint for the purposes of finding server-breaking exploits before they have a chance to ruin the multiplayer experience for everybody. The mechanism is opt-out, but enabled by default, and will generate a 'crash dump' and save it to a subfolder of terraria called crashes.

Optionally, the crash reporter will include a memory dump of the calling process to help us find bugs in TShock.

Structure

The following information is due to be collected in this first pass:

[ ] OS Information (Type, bit-depth, platform, version)
[ ] Hardware information (Memory capacity, CPU count)
[ ] Software information (TSAPI Heapsize (?), Exception Information, stack info)
[ ] Heap information (core dump)
[ ] Metrics (Number of players, capacity, plugins loaded & versions, mostly TBD)
[ ] Auxiliiary Information (ServerLog.txt, as well as others)

Method

  1. On exception, a system profile is generated
  2. Optionally, a memory dump is created
  3. The payload is zipped, and stored inside crashes as crash_{datetime}.zip
  4. JSON payload is submitted to webservice
  5. Crash dump is submitted to webservice

Enable AppVeyor

Now that we've experimentally turned on AppVeyor we should probably make it actually try to build something. It's scaring the developer of #134 that his build failed...even though AV didn't even run a .sln.

Sand Sharks and their biome relatives skip a lot, even on localhost

Just what the tin says. Pretty much every mob, worm enemies included, work as intended on localhost. However, sand sharks will skip quite a bit when hit for no apparent reason.
On a remote install one would think it's just lag, but it even happens on localhost, where even the biggest worms don't skip when hit.

Tested on TShock 4.3.20, clean install (just in case).

`ServerLeave` is not being invoked on `otapi3`

Specifically tested on af21743, the ServerApi.Hooks.ServerLeave does not seem to be invoked.

Example:

ServerApi.Hooks.ServerLeave.Register(this, args =>
{
    Console.WriteLine($"{args.Who} left!");
});

NPC's they are not spawning

@Zaicon, I know that the current build for the update is not yet final, but I would like to report that NPC's are not auto spawning, sometimes it is possible to see a Devourer in map, the command /sm (Example: /sm zombie 50), also does not work. Some boss and events are working perfectly, both through commands or over items.

Thank you very much for the excellent work in updating!

Regression: Not possible to run bootstrapper with 1 click in VS2017

A change introduced in 1ebf418 requires an env.config to be present in the build folder in order to run the bootstrapper in one click. It looks like a55a178 should have enabled a pre-build event that would create the env.config file in the output directory, but it doesn't do that on VS2017. I have no idea what causes this -- I'm not a Visual Studio person -- but the result is pretty clear: you can't 1-click run the bootstrapper anymore.

As part of Pryaxis/TShock#1558 I'm trying to document the build process. Right now I have to write an extra instruction to build the bootstrapper, make an env.config and then run it, which is a stupid amount of friction to go through. This needs to be a 1-click event because the process is already complicated enough as it is, between submodules, nuget, patchers, and more builds.

I'm marking this as high importance because it currently breaks the build instructions that we have officially published. This needs to be resolved as soon as possible.

Server Fails to load world, sometimes...

Occasionally my world filles will just no longer load in TerrariaServer, but will have been used on the server for days.

I've found the world files still open in the vanilla TerrariaServer and/or in TEdit no problem.

After investigation and adding some debug code into the World Loading section of TSAPI I've found the following.

The following function throwing a null reference exception:
CheckWaterDeath(Tile checkTile) line 1561
System.NullReferenceException: Object reference not set to an instance of an object.
at Terraria.ObjectData.TileObjectData.GetTileData(Tile getTile) in C:\Users\tyson\Dropbox\Documents\Terraria tShock\Projects\TShock-general-devel\TerrariaServerAPI\Terraria\ObjectData\TileObjectData.cs:line 1716
at Terraria.ObjectData.TileObjectData.CheckWaterDeath(Tile checkTile) in C:\Users\tyson\Dropbox\Documents\Terraria tShock\Projects\TShock-general-devel\TerrariaServerAPI\Terraria\ObjectData\TileObjectData.cs:line 1569

This function is used inside the WaterCheck() function in WorldGen.cs , which is used twice inside the loadWorld() function in WorldFile.cs

Not sure why this is happening, as Vanilla TerrariaServer loads the world fine, like i mentioned.

Here is a copy of one of my world files that stopped working for you to have a look at: http://vps.tls.id.au/broken.wld

Putting the following inside the loop helped track down which x,y tile it was breaking on:
Main.statusText = "X " + i + " Y " + j;

I concluded in this world file that it throws the exception on 6126, 726 which appears to be a Tall Gate (like a wooden door, but 1 block talker). Why it throws the null reference I have no idea, but would like some assistance trying to resolve this issue.

A workaround can be to load the world in vanilla, go to that pos and just smash that 1 tile and it will load again in this TSAPI

Server Deleting Config file Occasionally

This issue results in this:

[06/18/16 12:42:06] [Server API] Error: Startup aborted due to an exception in the Server API initialization:
System.InvalidOperationException: Plugin "TShock" has thrown an exception during initialization. ---> System.Exception: Fatal TShock initialization exception. See inner exception for details. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at TShockAPI.FileTools.SetupConfig()
at TShockAPI.TShock.Initialize()
--- End of inner exception stack trace ---
at TShockAPI.TShock.Initialize()
at TerrariaApi.Server.ServerApi.LoadPlugins()
--- End of inner exception stack trace ---
at TerrariaApi.Server.ServerApi.LoadPlugins()
at TerrariaApi.Server.ServerApi.Initialize(String[] commandLi

The cause? No idea, How to replicate it? No idea. I shut down my server sometimes, using [X] and once in a while it either wipes the config.json file, or the sscconfig.json file clean, making it empty. The result? This error, the result of this is frustration for any user trying to figure out why this is happening...

So for those trying to mess around, stop, Back up SSCConfig, and Config in a RAR file and keep it there in case tShock decided to wipe it for god knows why. This is the 5th time this has happened, and needs some investigation what causes it?

(#484+) World Saving fails at "Validating World Save 1%)

Issue: When the world attempts to save, it will not finish saving nor create a backup world file. It remains hanging in console at Validating World Save 1%. Meanwhile, server can operate normally, however, if server is restarted, crashes, or closed, the world will be at its last successful save or use a later stable version of TerrariaServer.exe. As far as testing goes, this is not an issue with TShock DLL.

AssemblyInfo outdated version

Is

[assembly: AssemblyFileVersion("1.3.0.4")]

and

[assembly: AssemblyVersion("1.3.0.4")]

in Properties/AssemblyInfo.cs outdated?

PS: I am aware of possible irrelevance.

Server Fails to load world, sometimes... part 2 (To do with chest count)

I've found an issue where sometimes a world will fail to load chests (maybe signs too) because there are too many on the map.

The strange thing is that the map will load in tshock and save and load again fine, however I've come across this issue with loading the world in Tedit and saving it again.

The world file will load in vanilla Terraria Server fine.

After some investigation I've narrowed the issue down to the loadWorld() function in WorldFile.cs where it gets to num = (num1 > 87 ? WorldFile.LoadWorld_Version2(binaryReader) : WorldFile.LoadWorld_Version1(binaryReader));

Within the LoadWorld_Version2() function, we find the LoadChests(); function which is where the crash occurs.

Through my investigation, I've found that a map with over 1000 chests seems to trigger the trash.

Like I said, strange thing is it saves and loads fine in TSAPI, but after being opened and saved again in TEdit it breaks. Might be somethign to do with the way the chests are resaved.

Inside the LoadChests() function there is a loop where it creates the chests and sets it's items and it will crash when it gets to chest 1001

On this line:
for (i = 0; i < num3; i++)

num3 (really descriptive) is the number of chests in the world that it tries to laod, but as soon as i > 1000 it crashes.

I dont have a lot of exp, but changing num3 to 1000 doesn't workd around this as the stream position becomes out of place because it skips a number of reads.

What I did find however, is that if I opened the world in Tedit again and delete however many chests I am over the 1000 chest limit, the world will load fine again.

This issue may be present with Signs as well, but I dont think ive ever had over 1000 signs in a world.

World stops loading for clients...

The world stops loading after some time for all clients, only way to fix this is to restart the server and it will load for a while. Figured I put this issue up until it actually gets resolved in the future. So no one misses out on that fact that the issue exists or is too lazy to put it out there.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v3
  • actions/setup-dotnet v3
.github/workflows/nuget.yml
  • actions/checkout v3
  • actions/setup-dotnet v3
nuget
TerrariaServerAPI.Tests/TerrariaServerAPI.Tests.csproj
  • coverlet.collector 3.1.2
  • NUnit.Analyzers 3.3.0
  • NUnit3TestAdapter 4.2.1
  • NUnit 3.13.3
  • Microsoft.NET.Test.Sdk 17.3.1
  • BenchmarkDotNet 0.13.2
TerrariaServerAPI/TerrariaServerAPI.csproj
  • OTAPI.Upcoming 3.1.20
  • System.Diagnostics.PerformanceCounter 6.0.1
  • Newtonsoft.Json 13.0.1

  • Check this box to trigger a request for Renovate to run again on this repository

TEItemFrame doesn't load or send properly.

When TerrariaAPI-Server loads a world with a TEItemFrame, clients connected will not receive that "section" of the map, leaving a void.

Place an item in an Item frame in single player and save the world, load this world with a recent TerrariaAPI-Server and connect. The area with the TEItemFrame is now a void as it appears to the character. This could be a loading problem, or a network sending problem leaving the section blank.

This happens regardless of any plugins including TShock.

sendq: Allocate of message to player xxx timed out.

So apparently when a player gets kicked through any GetData stuff, this happens.
I triggerred the damage cap kick in TShock.
(Also working on a plugin where I kick player at playerdamage packet and same thing happens)

http://puu.sh/jcCg7/d86039bcde.png

and after world is done saving http://puu.sh/jcCh4/9bfc3760b8.png

I debugged to see where the booboo happens. And it's here http://puu.sh/jcBwZ/113872e58b.png

(#isuckwithreports)
Ping pong @tylerjwatson

Disappearing NPCs

The following relates to Terraria API Server version 1.18.0.0, at commit c9252be, with no plugins (not even TShock).

Shortly after I started the server, I noticed that the mechanic's projectile was appearing at the wrong location. Then, some of my citizens mysteriously vanishing, specifically, the demolitionists, dryads and mechanics. At one point I even appeared to have two dryads, but that may have been due to the first dryad not having been removed from my client's memory yet.

Some investigation revealed that the citizens were being deleted because their AI crashed at the sight of a monster. The exception is as follows:

System.NullReferenceException: Object reference not set to an instance of an object.
    at Terraria.NPC.AI() line 9072
    at Terraria.NPC.UpdateNPC(int i) line 58752
    at Terraria.Main.Update() line 12579
    at Terraria.ProgramServer.InerStart(string[] args) line 194
    at Terraria.ProgramServer.Main(string[] args) line 207

The offending object seems to be set to either null or 8 just before the offending reference, neither of which can be cast to a float. This smells strongly of decompilation errors.

I also noticed that the citizens were not showing chat bubbles on the API server, but are on the vanilla server.

PlayerActive packet spam

This has been discussed in #support channel with Yor, Popstarfreas ( ๐Ÿ‘ to him for pointing this out) and Zaicon.
Basically, in syncPlayers it loops through all the player slots. if Netplay.Client state is == 10 (fully connected player) It sends packets to synchronize everything.
SyncPlayers is called every join/leave, and if tick counter is over 10800 ticks.
If client state is not 10, it sends packet 14 to everyone, 224 times.
So that's 224 * 225 packets sent by the server. (Each player gets 225 packets)
This is completely redundant to do so at every join and leave. This is only required on leave, (maybe in the update too, but I will test this)
Yor confirmed this as bad code, and said we can apply a fix until they make an official one to increase multiplayer server performance.
I hope I made sense with this. It's 2am :|
I already made a PR for this, by adding 2 extra parameters to syncPlayers, bool ghostUpdate = true and int leavingPlayer = -1 (I call it ghost update because without sending the playeractive packet and the player leaves it leaves a ghost. Feel free to suggest other name)
Referencing PR here asap.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.