Skip to content

Multiplayer: Separate synced animation state from local rendering state#4678

Merged
Loobinex merged 3 commits intodkfans:masterfrom
rainlizard:current_frame-max_frames11
Apr 19, 2026
Merged

Multiplayer: Separate synced animation state from local rendering state#4678
Loobinex merged 3 commits intodkfans:masterfrom
rainlizard:current_frame-max_frames11

Conversation

@rainlizard
Copy link
Copy Markdown
Contributor

@rainlizard rainlizard commented Apr 18, 2026

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_frame and max_frames inside creatures change, which might have you wondering: Which player's current view owns the thing->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_frame and max_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.

@rainlizard rainlizard marked this pull request as draft April 18, 2026 07:22
@rainlizard rainlizard closed this Apr 18, 2026
@rainlizard rainlizard force-pushed the current_frame-max_frames11 branch from a9ddcda to 7447cde Compare April 18, 2026 11:32
@rainlizard rainlizard reopened this Apr 18, 2026
@rainlizard rainlizard force-pushed the current_frame-max_frames11 branch from 4795ee2 to e06cfda Compare April 18, 2026 23:27
@rainlizard rainlizard marked this pull request as ready for review April 18, 2026 23:42
Comment thread src/creature_graphics.h
@Loobinex Loobinex merged commit b7907db into dkfans:master Apr 19, 2026
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.

2 participants