Skip to content
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

Reorder client initialization (rebased) #15554

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

SmallJoker
Copy link
Contributor

Fixes the root issue of:

This reopens #12189 (thanks grorp for pointing it out)

Before

core.get_connected_players occasionally returns object references of yet-not-joined players, for example in core.register_globalstep callbacks. This is a problem because core.register_on_joinplayer was not called yet.
Mods rely on joinplayer to initialize their API entries, which causes unpredictable and unreliable code paths.

After

core.get_connected_players includes the player reference only after (and including) core.register_on_newplayer, followed by core.register_on_joinplayer.

To do

This PR is Ready for Review.

How to test

  1. I have no idea

Previously, ServerEnv created a player instance before they're fully initialized.
This commit moves all initialization steps and callbacks into TOSERVER_CLIENT_READY
^ which includes StageTwoClientInit for player loading or creation
@SmallJoker SmallJoker added @ Script API Bugfix 🐛 PRs that fix a bug labels Dec 14, 2024
Copy link
Collaborator

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks sensible, not tested

@sfan5 sfan5 merged commit d1dd044 into luanti-org:master Dec 24, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants