Navigation Menu

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 #12189

Closed
wants to merge 1 commit into from

Conversation

SmallJoker
Copy link
Member

Before

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

After

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

Fixes the root issue of minetest-mods/playeranim#3

To do

This PR is Ready for Review.

How to test

  1. https://github.com/minetest-mods/playeranim commit 9dab03f
  2. This code:
-- Ensure the callbacks are run
minetest.register_on_newplayer(function(p)
	print("newplayer", p:get_player_name())
end)
minetest.register_on_joinplayer(function(p)
	print("joinplayer", p:get_player_name())
end)
  1. Any other mod you'd like to test.
  2. Host a server and attempt to join with a same-named player

@sfan5
Copy link
Member

sfan5 commented May 1, 2022

This is not the same issue as #12073, is it?

@SmallJoker
Copy link
Member Author

Actually yes, it seems to be the same issue.

@sfan5
Copy link
Member

sfan5 commented May 1, 2022

The other report came from a faulty third party client causing the engine to become confused. If this one is reproducible in the normal client then it's not the same issue.

@SmallJoker
Copy link
Member Author

It is the same as in #12073 (comment) but reproducible at a chance with the official Minetest client.

@sfan5
Copy link
Member

sfan5 commented May 18, 2022

FYI I haven't reviewed this yet because I'm unsure whether this is a good idea (especially the setNewPlayer feels wrong) but haven't had time to investigate alternatives.

@Zughy Zughy added the Rebase needed The PR needs to be rebased by its author. label Jun 12, 2022
@Zughy
Copy link
Member

Zughy commented Jun 12, 2022

@SmallJoker rebase needed

@SmallJoker SmallJoker removed the Rebase needed The PR needs to be rebased by its author. label Jun 12, 2022
@rubenwardy rubenwardy requested a review from sfan5 July 2, 2022 18:55
@SmallJoker SmallJoker added the Rebase needed The PR needs to be rebased by its author. label Jan 10, 2023
@sfan5 sfan5 removed their request for review March 5, 2023 18:48
@Zughy
Copy link
Member

Zughy commented Mar 5, 2023

IRC discussion: https://irc.minetest.net/minetest-dev/2023-03-05#i_6060589 (in short, it'll wait a bit)

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 removed the Rebase needed The PR needs to be rebased by its author. label Mar 6, 2023
@SmallJoker
Copy link
Member Author

For some reason I can no longer reproduce the bug in master, even though the relevant code does not seem to have changed in any meaningful way. This PR no longer seems to be necessary.

@SmallJoker SmallJoker closed this Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug @ Script API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants