-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Send key updates to the server immediately (to fix presses shorter than 100ms being missed) #16805
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
base: master
Are you sure you want to change the base?
Conversation
…the server as being pressed
|
This looks like a step in the right direction; it should alleviate the problem, especially in singleplayer. I'm not sure whether the problem can be properly fixed this way, because we only send "is pressed" state as opposed to "was pressed / released" events to the server. So if you press a key and subsequently release it, what's likely to happen is that the control down state gets overwritten by the second packet, if both happen within the same server step. So to mods, the event is still lost. Now you could have some server logic that diffs packets arriving in the same step and synthesizes events from that, but really we should think about different packets for sending an ordered stream of control events: The set pos packet is more of a hack and not nice to extend for custom controls. |
that's more bandaid on something that can't ever work properly. the solution is SSCSM. |
|
It might not be perfect, but it is at least better that the current state. And it actually works, no key presses are lost for me anymore. |
|
Did you try it outside of singleplayer? on a multiplayer server? It's also worth noting that the server will by definition never see key pressed for shorter than the step size. |
|
I think you misunderstand. This isn't in code, it's just logical: If you check something every N milliseconds, you can miss changes that last for less than N milliseconds. |
Goal of the PR
Fast/short key presses should always result in a change to the result of
player.get_player_control()- for at least one game step.How does the PR work?
In client.cpp,
sendPlayerPos()is only called ifcounter >= m_recommended_send_interval, which is fine for sending repeated packets to the server. Checking if any pressed keys changed is already done insendPlayerPos().This PR moves the
counter >= m_recommended_send_intervalcheck tosendPlayerPos(), into theif (identical)branch. This way, a package with new key state is directly send when a key is pressed.Without this change, a short key press is lost if the m_recommended_send_interval (by default 100ms) just started, a key is pressed and released before the timer ends. After 100ms, the position and pressed keys are sent again, but the already released key press is lost.
Does it resolve any reported issue?
This one.
Does this relate to a goal in the roadmap?
No
To do
This PR is Ready for Review.
How to test
Example how to reproduce in singleplayer mode, short press aux1 or jump (or other keys):