Skip to content

fix: player join #903

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

TestingPlant
Copy link
Collaborator

This fixes the player join code to reduce the number of possible errors. The rationale of each change is explained in each commit message.

There may be a period where the skin has been received through skins_rx
but the appropriate components (most importantly Position, as that must
be set through the event code and is out of the control of the hyperion
crate) have not yet been set, causing get to fail. Moving the
player_join_world call to its own system resolves this issue.
Originally, PacketState was added as both a struct and enum component,
meaning that there were two separate values of PacketState. This unifies
them into one enum component.
Previously, if someone connected to the server twice with the same
account, the server would abort because two entities cannot have the
same name in flecs. In addition, having multiple players from the same
account would not make sense. This code disconnects the previous player
if a new player with the same name connects.

This also modifies IgnMap to no longer use DeferredMap. Deferred
insertions would allow for race conditions because two players with the
same name could be inserted into the IgnMap with neither insertion call
knowing that there's another player with the same name. The code also
cannot rely on flecs to determine if there's another player with the
same name using World::try_lookup because this would introduce a race
condition between the try_lookup call and setting the entity name.
This ensures that all packets, especially the disconnect message packet,
are sent to the client before the server disconnects the client.
@github-actions github-actions bot added the fix label May 20, 2025
Copy link

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  34.9 ns ...  34.5 ns ]      -1.12%
ray_intersection/aabb_size_1                       [  33.6 ns ...  33.7 ns ]      +0.35%
ray_intersection/aabb_size_10                      [  24.3 ns ...  24.3 ns ]      +0.13%
ray_intersection/ray_distance_1                    [  13.8 ns ...  13.8 ns ]      +0.09%
ray_intersection/ray_distance_5                    [  13.8 ns ...  13.8 ns ]      -0.38%
ray_intersection/ray_distance_20                   [  13.8 ns ...  13.8 ns ]      +0.03%
overlap/no_overlap                                 [  25.2 ns ...  25.2 ns ]      +0.05%
overlap/partial_overlap                            [  25.2 ns ...  25.2 ns ]      +0.04%
overlap/full_containment                           [  22.8 ns ...  22.8 ns ]      +0.06%
point_containment/inside                           [   4.9 ns ...   4.9 ns ]      +0.05%
point_containment/outside                          [   4.4 ns ...   4.4 ns ]      +0.64%
point_containment/boundary                         [   5.0 ns ...   5.0 ns ]      +0.18%

Comparing to 188a3e4

Copy link

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 28.04878% with 59 lines in your changes missing coverage. Please review.

Project coverage is 20.69%. Comparing base (188a3e4) to head (2a3640a).

Files with missing lines Patch % Lines
crates/hyperion/src/egress/player_join/mod.rs 40.00% 32 Missing and 1 partial ⚠️
crates/hyperion/src/ingress/mod.rs 0.00% 23 Missing ⚠️
crates/hyperion-proxy/src/player.rs 0.00% 3 Missing ⚠️
@@            Coverage Diff             @@
##             main     #903      +/-   ##
==========================================
- Coverage   20.84%   20.69%   -0.15%     
==========================================
  Files         161      161              
  Lines       16864    16860       -4     
  Branches      464      465       +1     
==========================================
- Hits         3516     3490      -26     
- Misses      13284    13306      +22     
  Partials       64       64              
Files with missing lines Coverage Δ
crates/hyperion/src/simulation/mod.rs 37.19% <100.00%> (-2.06%) ⬇️
crates/hyperion-proxy/src/player.rs 0.00% <0.00%> (ø)
crates/hyperion/src/ingress/mod.rs 19.66% <0.00%> (-3.18%) ⬇️
crates/hyperion/src/egress/player_join/mod.rs 32.90% <40.00%> (+3.84%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dyc3 dyc3 added this pull request to the merge queue May 20, 2025
@dyc3 dyc3 removed this pull request from the merge queue due to a manual request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants