mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Avoid packets getting sent to disconnected players (#14444)
Many functions expect RemotePlayer to have a valid peer ID, this however is not the case immediately after disconnecting where the object is still alive and pending for removal. ServerEnvironment::getPlayer(const char *, bool) now only returns players that are connected unless forced to.
This commit is contained in:
@@ -584,13 +584,17 @@ RemotePlayer *ServerEnvironment::getPlayer(const session_t peer_id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RemotePlayer *ServerEnvironment::getPlayer(const char* name)
|
||||
RemotePlayer *ServerEnvironment::getPlayer(const char* name, bool match_invalid_peer)
|
||||
{
|
||||
for (RemotePlayer *player : m_players) {
|
||||
if (strcmp(player->getName(), name) == 0)
|
||||
if (strcmp(player->getName(), name) != 0)
|
||||
continue;
|
||||
|
||||
if (match_invalid_peer || player->getPeerId() != PEER_ID_INEXISTENT)
|
||||
return player;
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ServerEnvironment::addPlayer(RemotePlayer *player)
|
||||
|
Reference in New Issue
Block a user