Repository navigation
Fix stale position packets and remember minigame arenas - #64
Merged
Merged
Conversation
The client keeps reporting its old position until it receives the teleport (or the new level), and those packets were taken as the new position. After walking into a portal the player could be moved back or trigger portals and checkpoints at the old coordinates in the new level. For two seconds after the server moves a player, packets that are still next to the old spot and far from the new one are dropped; the first packet near the new position ends that early.
/restart started a new copy of the server and exited. Under systemd, pm2 or a start script loop the supervisor then started another one, and the two fought over the port. With MCSCRIPT_SUPERVISED set, /restart only exits.
Arenas enabled with /<game> enable are stored and loaded at startup, so /<game> join works from the lobby instead of only from a loaded arena. /warp changes level and then teleports; the second move replaced the spot the client was really coming from, so a normal step near the new spawn looked like a late packet. Keep the first spot while it's fresh and only drop packets closer to it than to the new position.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
This PR fixes two issues and adds one feature:
Stale position packets after teleport/level change: When a server teleports a player or changes their level, the client continues sending position packets from its old location until it receives the teleport/level change packet. These late-arriving packets were being processed as if the player had moved to that old position, which could trigger portals, message blocks, or parkour checkpoints in the wrong place. The fix tracks the old position and ignores packets that are closer to it than the new position (within a 2-second window).
Minigame arena persistence: Levels enabled as minigame arenas (via
/tntwars enable,/ctf enable,/zombie enable) are now remembered and loaded at startup. This allows/<game> jointo work from any level, and/<game> join <level>can load the arena if needed.Supervised restart fix: When
/restartis used under a supervisor (systemd, pm2, or a start script loop), the server now exits cleanly instead of spawning a second copy. This is controlled by theMCSCRIPT_SUPERVISED=1environment variable.How did you test it?
'position packets sent before a teleport or level change arrived are ignored'covering teleport, level change, and combined scenarios'minigame arenas are remembered and loaded at startup'verifying arena persistence across restarts'minigames: capture the flag'test to properly simulate client behavior by confirming spawn position before movingnpm test