-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
TestingPlant
wants to merge
5
commits into
main
Choose a base branch
from
testingplant/refactor-player-join
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: player join #903
+173
−113
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Benchmark Results for general
Comparing to 188a3e4 |
Codecov ReportAttention: Patch coverage is
@@ 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
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
dyc3
approved these changes
May 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This fixes the player join code to reduce the number of possible errors. The rationale of each change is explained in each commit message.