-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix buffering for events that have mapped entities. #321
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #321 +/- ##
==========================================
- Coverage 90.60% 89.79% -0.82%
==========================================
Files 37 37
Lines 2300 2293 -7
==========================================
- Hits 2084 2059 -25
- Misses 216 234 +18 ☔ View full report in Codecov by Sentry. |
let event = (deserialize)(ctx, cursor); | ||
if ctx.invalid_entities.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should clear the invalid_entities
in case multiple server events are received but only some of them are invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, good catch!
events.send(event); | ||
} | ||
Err(e) => error!( | ||
"unable to deserialize independent event `{}`: {e}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unable to deserialize independent event `{}`: {e}", | |
"ignoring independent event `{}` from server that failed to deserialize: {e}", |
It's unnecessary. Spawning any replicated entity is enough to trigger the world change.
Fixed the bug reported by @NiseVoid in Discord. After the events refactor I map the event inside the deserialization function. But I need to deserialize the tick first and compare it for buffering. We didn't catch it in the tests because we didn't have a test for the combination of event buffering and entity mapping. The fix is simple. The event queue is not generic now and stores the event in its serialized form. The resource now initialized inside the |
registry: ®istry.read(), | ||
entity_map: &entity_map, | ||
}; | ||
world.resource_scope(|world, mut queue: Mut<ServerEventQueue>| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff is messy, but I just added a new scope for ServerEventQueue
.
|
||
let world_cell = world.as_unsafe_world_cell(); | ||
for event_data in event_registry.iter_server_events() { | ||
// SAFETY: both resources mutably borrowed uniquely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need to be unsafe since we borrow only one resource and can get rid of the world cell.
Closes #311.