mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
RemotePlayer: make peer ID always reflect the validity of PlayerSAO (#14317)
Upon disconnect, RemotePlayer still had a peer ID assigned even though the PlayerSAO object was maked as gone (for removal). This commit makes that the following always holds true: (!sao || sao->isGone()) === (peer_id == PEER_ID_INEXISTENT)
This commit is contained in:
parent
893594d81a
commit
e7dbd325d2
10 changed files with 86 additions and 61 deletions
|
@ -625,13 +625,6 @@ bool ServerEnvironment::removePlayerFromDatabase(const std::string &name)
|
|||
return m_player_database->removePlayer(name);
|
||||
}
|
||||
|
||||
void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,
|
||||
const std::string &str_reason, bool reconnect)
|
||||
{
|
||||
for (RemotePlayer *player : m_players)
|
||||
m_server->DenyAccess(player->getPeerId(), reason, str_reason, reconnect);
|
||||
}
|
||||
|
||||
void ServerEnvironment::saveLoadedPlayers(bool force)
|
||||
{
|
||||
for (RemotePlayer *player : m_players) {
|
||||
|
@ -1643,9 +1636,8 @@ void ServerEnvironment::step(float dtime)
|
|||
if (player->getPeerId() == PEER_ID_INEXISTENT)
|
||||
continue;
|
||||
|
||||
PlayerSAO *sao = player->getPlayerSAO();
|
||||
if (sao && player->inventory.checkModified())
|
||||
m_server->SendInventory(sao, true);
|
||||
if (player->inventory.checkModified())
|
||||
m_server->SendInventory(player, true);
|
||||
}
|
||||
|
||||
// Send outdated detached inventories
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue