mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Reorder client initialization (#15554)
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
This commit is contained in:
parent
c49ff76955
commit
d1dd044455
5 changed files with 41 additions and 40 deletions
|
@ -667,13 +667,13 @@ void ServerEnvironment::savePlayer(RemotePlayer *player)
|
|||
}
|
||||
}
|
||||
|
||||
PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
|
||||
session_t peer_id, bool is_singleplayer)
|
||||
std::unique_ptr<PlayerSAO> ServerEnvironment::loadPlayer(RemotePlayer *player, session_t peer_id)
|
||||
{
|
||||
auto playersao = std::make_unique<PlayerSAO>(this, player, peer_id, is_singleplayer);
|
||||
auto playersao = std::make_unique<PlayerSAO>(this, player, peer_id, m_server->isSingleplayer());
|
||||
// Create player if it doesn't exist
|
||||
if (!m_player_database->loadPlayer(player, playersao.get())) {
|
||||
*new_player = true;
|
||||
playersao->setNewPlayer();
|
||||
|
||||
// Set player position
|
||||
infostream << "Server: Finding spawn place for player \""
|
||||
<< player->getName() << "\"" << std::endl;
|
||||
|
@ -692,20 +692,10 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
|
|||
}
|
||||
}
|
||||
|
||||
// Add player to environment
|
||||
addPlayer(player);
|
||||
|
||||
/* Clean up old HUD elements from previous sessions */
|
||||
player->clearHud();
|
||||
|
||||
/* Add object to environment */
|
||||
PlayerSAO *ret = playersao.get();
|
||||
addActiveObject(std::move(playersao));
|
||||
|
||||
// Update active blocks quickly for a bit so objects in those blocks appear on the client
|
||||
m_fast_active_block_divider = 10;
|
||||
|
||||
return ret;
|
||||
return playersao;
|
||||
}
|
||||
|
||||
void ServerEnvironment::saveMeta()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue