Ensure Rollback
Order is Stable After Rollback
#82
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.
Objective
If a
Rollback
entity is spawned, then rollback causes that entity to no longer be spawned (or vice versa), the generation of thatEntity
will be different across clients that did/not rollback. BecauseEntity
derives itsPartialOrd
, the generation value changes the order of the entities, and likewise forRollback
. Any code relying on a stable ordering ofRollback
components will then likely desync.This should not happen!
Solution
PartialOrd
andOrd
implementations forRollback
, since they are not stable across clients, and therefore using them is a footgun waiting to happen.RollbackOrdered::push
to simply stack the values in the orderAddRollbackCommand
is called. I believe this ordering is stable across clients so it can be used.Clone
forRollbackOrdered
and added it to the rollback schedule to account forRollback
entities de/spawned during rollback.Rollback
entities, and the total number spawnedRollback
entities is a part of the checksum. These are cheap since both are singlelen()
calls.Notes
I've tested rebasing #78 onto this PR and from my testing, all desync issues are resolved. At a minimum, the frequency of desync issues is so drastically reduced that I was not able to replicate them no matter how randomly and quickly I switched peers/inputs.