Multiplayer: Separate synced animation state from local rendering state#4678
Merged
Loobinex merged 3 commits intodkfans:masterfrom Apr 19, 2026
Merged
Conversation
a9ddcda to
7447cde
Compare
4795ee2 to
e06cfda
Compare
Loobinex
reviewed
Apr 18, 2026
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.
There's an issue with the animation variables on an individual creature being treated as local variables, while they're actually supposed to be synced. They're being shared between players, because there's only one creature with one set of variables.
I'll just lead with the obvious here: animation variables need to be synced because there's a lot of gameplay stuff tied to them.
They changed locally whenever you switched views. So in multiplayer when a resync happens they get copied from the host machine, which apparently can cause a permanent resync loop. When you switch between first person view and top down view, the
current_frameandmax_framesinside creatures change, which might have you wondering: Which player's current view owns thething->current_frame? In multiplayer each machine can have a different local view (someone can be in first person and someone can be in top down view), but they are still utilizing these same shared variables on the same creature which isn't very safe.One partial solution would be to simply not checksum
current_frameandmax_frames, which is what we've mostly been doing, but I'm pretty sure that's just hiding the issue away and results in obscure butterfly-effect desyncs down the line.Anyway what I've done here: Inside a Thing/creature, the anim_sprite/anim_speed/anim_time/current_frame/max_frames variables now all consistently refer to the top down values, but during render time this is converted to the first-person values (if player is in first person view). This "conversion" doesn't mean setting the values, it's just local to the rendering code.