Skip to content

Comments

Only send entity updates to players able to see them#105

Merged
caelunshun merged 11 commits intodevelopfrom
feature/nearby-broadcast
Sep 5, 2019
Merged

Only send entity updates to players able to see them#105
caelunshun merged 11 commits intodevelopfrom
feature/nearby-broadcast

Conversation

@caelunshun
Copy link
Member

@caelunshun caelunshun commented Sep 1, 2019

Resolves #78.

  • Implement utility functions to broadcast packets to nearby players.
  • Broadcast entity and block updates only to nearby players.
  • Destroy and spawn entities on the client when they leave and enter the view distance.

This function adds an easy way to broadcast a packet
to all players who are able to see a given chunk.
For example, movement packets for a player can
be sent to all players able to see that player's
chunk.

The function hasn't yet been used, but player action
broadcast systems will soon be modified to use
`Util::broadcast()`.

Also see #78.
This function efficiently finds all entities within the view
distance of a player. It can be used to, for example, send initial
entities to the player when they join. However, it should not
be used for broadcasting packets; `Util::broadcast` is more
efficient in this regard, since it does not have to iterate
over `view_distance^2` chunks.

See also #78.
@caelunshun caelunshun added this to the 0.5 milestone Sep 1, 2019
@codecov
Copy link

codecov bot commented Sep 1, 2019

Codecov Report

Merging #105 into develop will increase coverage by 0.8%.
The diff coverage is 78.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #105     +/-   ##
==========================================
+ Coverage    57.16%   57.97%   +0.8%     
==========================================
  Files           56       58      +2     
  Lines         7392     7726    +334     
==========================================
+ Hits          4226     4479    +253     
- Misses        3166     3247     +81
Impacted Files Coverage Δ
core/src/network/packet/mod.rs 0% <ø> (ø) ⬆️
server/src/entity/component.rs 71.42% <0%> (ø) ⬆️
core/src/network/packet/implementation.rs 0% <0%> (ø) ⬆️
server/src/player/movement.rs 30.48% <10%> (-1.16%) ⬇️
server/src/entity/mod.rs 100% <100%> (ø) ⬆️
server/src/entity/metadata.rs 78.68% <100%> (ø) ⬆️
server/src/testframework.rs 93.89% <100%> (+0.82%) ⬆️
server/src/entity/item.rs 94.02% <100%> (-0.09%) ⬇️
server/src/player/mod.rs 100% <100%> (ø) ⬆️
server/src/player/animation.rs 96.66% <100%> (-0.11%) ⬇️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc68185...855e401. Read the comment docs.

@caelunshun caelunshun force-pushed the feature/nearby-broadcast branch from b815e7d to cfe9256 Compare September 5, 2019 03:03
@codecov-io
Copy link

codecov-io commented Sep 5, 2019

Codecov Report

Merging #105 into develop will increase coverage by 0.79%.
The diff coverage is 78.86%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #105      +/-   ##
===========================================
+ Coverage    57.16%   57.96%   +0.79%     
===========================================
  Files           56       58       +2     
  Lines         7392     7725     +333     
===========================================
+ Hits          4226     4478     +252     
- Misses        3166     3247      +81
Impacted Files Coverage Δ
core/src/network/packet/mod.rs 0% <ø> (ø) ⬆️
server/src/entity/component.rs 71.42% <0%> (ø) ⬆️
core/src/network/packet/implementation.rs 0% <0%> (ø) ⬆️
server/src/player/movement.rs 30.48% <10%> (-1.16%) ⬇️
server/src/util/mod.rs 85.71% <100%> (+22.55%) ⬆️
server/src/entity/mod.rs 100% <100%> (ø) ⬆️
server/src/entity/metadata.rs 78.68% <100%> (ø) ⬆️
server/src/testframework.rs 93.89% <100%> (+0.82%) ⬆️
server/src/entity/item.rs 94.02% <100%> (-0.09%) ⬇️
server/src/player/mod.rs 100% <100%> (ø) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc68185...5495df8. Read the comment docs.

@caelunshun caelunshun marked this pull request as ready for review September 5, 2019 23:06
@caelunshun caelunshun merged commit 9e38b20 into develop Sep 5, 2019
@caelunshun caelunshun deleted the feature/nearby-broadcast branch September 5, 2019 23:26
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.

Only broadcast entity actions to players who can see them

2 participants