Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netcode Overhaul #2970

Merged
merged 1 commit into from
Mar 5, 2025
Merged

Netcode Overhaul #2970

merged 1 commit into from
Mar 5, 2025

Conversation

Boondorl
Copy link
Contributor

@Boondorl Boondorl commented Mar 4, 2025

This PR includes a total overhaul to GZDoom's netcode with almost all of it being removed and replaced. For ages GZDoom's netcode has only been slightly better than its 1993 counterpart and this has led to a lot of headaches with simple tasks like:

  • Setting up lobbies
  • Getting everyone to actually connect
  • Stability of the game once started

P2P in particular is problematic because while it works in LAN play, ISP configurations can cause users to be completely shut off from communicating with each other. Packet-server acted as a fix for this by having the host act as a middleman for routing packets instead of using direct communication, but this mode was incredibly laggy and prone to desyncs. Over longer distances (>80ms) it was unusable.

Most of these issues have been fixed. To start, the netcode has been further unhooked from the rest of the engine. While it was only a small amount, this PR manages to further isolate it reducing potential knock-on effects. Some strategies the main thread uses have also be re-evaluated for online play to ensure connection stability above all else. For instance, the wipe screens have now been disabled since they locked up the main thread and would cause bursty map change barriers that made the experience less comfortable. A particularly big change is that consistencies and inputs have been decoupled from each other, allowing input buffers to be sent over ahead of time helping reduce the stop and go nature of netplay.

Packet-server has been entirely restrategized to be usable over long distances. Now the host will act as the ultimate authority on the game's state and latency reducing measures have been put in place to improve the feel for all clients. The result is that the latency clients feel is now directly correlated to their round-trip time instead of the player with the highest latency dictating the base state of the game. Because of these changes, packet-server will now be the default mode for non-LAN play with 3+ players. The max player count has also been bumped to 16 because of this mode making this level of connectivity possible.

In preparation for future games being made publicly accessible, some features have been added to improve both the host's control and the client experience. Chat has been given new options including the ability to disable bold text via /me, mute the chat sound, and dictate what kind of chat messages (none/team/global) can be received. mute(all) and unmute(all) have been added for targeted muting. The non-all versions take a player number which can be gotten through listplayers (the * denotes which user the client is). kick has been added for hosts that wish to remove annoying users and they now have options to set both who can control pausing the game and if the chat should have slow mode (message throttling).

Other fixes include cleaning up TryRunTics to make it more inline with the new renderer. Some of the old code from 1993 remained that was used for tick control by locking up the main thread, but this strategy shouldn't be used when playing online and the renderer needs to be free to run immediately. In general the game will now handle lag outs far more gracefully. Instead of 3 seconds from the last update with a max of 17 commands in the buffer (including from the natural net delay), users can now generate up to 1 second worth of commands from the last time they updated, allowing for a smoother recovery since everyone will have the same level of commands in buffer. A few fixes for prediction have also been added to help improve the feel of the game during these lagging out periods.

On a final note, this will also impact demo support and this is currently untested. It's fully possible demos will be temporarily broken until they can be reworked later, however I have plans to fix this up and add more playback features for it to make GZDoom's demos more enticing. I'm not even sure they work as is so it's possible this won't actually affect their real viability to begin with.

Rewrote netcode to be more stable and functional. Packet-server mode has been restrategized and will now be the default netmode when playing with 3+ non-LAN players. TryRunTics has been cleaned up with older tick control behavior removed to account for the rewritten renderer. The main thread is now more consistent when playing online to prevent potential slow downs and lock ups. Load barriers are better accounted for to prevent spikes on level transition. Improvements to chat and lobby systems including a force start game button. Added a suite of new host options such as kicking and controlling who can pause the game. Max players increased from 8 to 16 since the new code can now handle it.

Note: Demo functionality is untested. This will be rewritten at a later time alongside improvements to GZDoom's playback features (e.g. freecam mode).
@TheKins
Copy link

TheKins commented Mar 5, 2025

Pretty incredible stuff. We've been helping test it with an (unreleased, WIP) version of Reelism 2, and it's held up incredibly well to scenarios with 6-8 players on open maps with hundreds of active monsters and all sorts of Stupid Script Tricks being pulled on the regular.

A massive, essential improvement over the past situation.

@madame-rachelle
Copy link
Collaborator

I'm going to go ahead and merge this because this has already received a ton of testing and likely will receive a whole lot more, and this is by far one of the most anticipated features for 4.15. I'm fairly confident that if any regressions exist here they either will be found and fixed quickly or they already have been fixed.

@madame-rachelle madame-rachelle merged commit 94be307 into ZDoom:master Mar 5, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants