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

get_player_window_information() returns nil if called when a player joins #14711

Open
Zughy opened this issue May 28, 2024 · 3 comments
Open
Labels
Bug Issues that were confirmed to be a bug @ Script API
Milestone

Comments

@Zughy
Copy link
Member

Zughy commented May 28, 2024

Minetest version

5.8.0, 5.9.0-dev

Operating system and version

Pop!_OS 22.04 LTS

CPU model

i7-7700

GPU model

GeForce GTX 1060

Summary

Title. The minimum elapsed time since the login required to avoid the nil return on my PC seems to be 0.2412

Steps to reproduce

minetest.register_on_joinplayer(function(player)
        -- Decomment to avoid nil
	--minetest.after(0.2412, function()
		minetest.chat_send_all(dump(minetest.get_player_window_information(player:get_player_name())))
	--end)
end)
@Zughy Zughy added Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible @ Script API labels May 28, 2024
@sfan5
Copy link
Member

sfan5 commented May 28, 2024

on_joinplayer is called after Server::StageTwoClientInit which should have made everything ready so that the player actually exists in the environment.
However the peer ID in RemotePlayer is only set later here:

void PlayerSAO::addedToEnvironment(u32 dtime_s)
{
ServerActiveObject::addedToEnvironment(dtime_s);
ServerActiveObject::setBasePosition(m_base_position);
m_player->setPlayerSAO(this);
m_player->setPeerId(m_peer_id_initial);
m_peer_id_initial = PEER_ID_INEXISTENT; // don't try to use it again.
m_last_good_position = m_base_position;
}

probable regression from e7dbd32

unfortunately I don't see an easy fix because the need to get the player id before the sao is ready contradicts the design choice made in that commit

@sfan5 sfan5 added Bug Issues that were confirmed to be a bug and removed Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible labels May 28, 2024
@Zughy
Copy link
Member Author

Zughy commented May 28, 2024

Maybe @SmallJoker can think about something since it was his commit, I don't know

@sfan5 sfan5 added the Regression Something that used to work no longer does. label Jun 2, 2024
@sfan5 sfan5 added this to the 5.9.0 milestone Jun 5, 2024
@grorp
Copy link
Member

grorp commented Jun 18, 2024

Using the code provided by Zughy, I also get nil on Minetest 5.7.0 and 5.8.0, so this doesn't look like a regression to me.

@appgurueu appgurueu changed the title get_player_information() returns nil if called when a player joins get_player_window_information() returns nil if called when a player joins Jun 18, 2024
@Zughy Zughy removed the Regression Something that used to work no longer does. label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Script API
Projects
None yet
Development

No branches or pull requests

3 participants