projectharmonia / bevy_replicon

Server-authoritative networking crate for the Bevy game engine.
https://crates.io/crates/bevy_replicon
Apache License 2.0
353 stars 31 forks source link

Fix replication with visibility policy != `VisibilityPolicy::All` #261

Closed Shatur closed 6 months ago

Shatur commented 6 months ago

Visibility was coupled with a check if a client was just connected. This resulted in a passed test that checks replication of previously spawned entities (it was running with VisibilityPolicy::All). But for all other policies the logic was incorrect and led to a crash with "entity should be present after adding component".

I decoupled the logic. We now determine if the entity is new to a client by checking if it has a tick.

I thinking that we need to rename "change limit" into "init tick" because we use this terminology on client. But it will be a breaking change, so I will leave it for the next release.

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 93.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 90.79%. Comparing base (e128056) to head (b3bb6cf).

Files Patch % Lines
src/server/connected_clients/client_visibility.rs 75.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #261 +/- ## ========================================== - Coverage 90.82% 90.79% -0.03% ========================================== Files 37 37 Lines 2081 2076 -5 ========================================== - Hits 1890 1885 -5 Misses 191 191 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Shatur commented 6 months ago

Add test to document the bug?

We have a test for it, but it didn't trigger the bug because the check for new entities was tied to the visibility policy :)