mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-21 20:05:45 +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:
@@ -124,7 +124,7 @@ Inventory *ServerInventoryManager::createDetachedInventory(
|
||||
RemotePlayer *p = m_env->getPlayer(name.c_str());
|
||||
|
||||
// if player is connected, send him the inventory
|
||||
if (p && p->getPeerId() != PEER_ID_INEXISTENT) {
|
||||
if (p) {
|
||||
m_env->getGameDef()->sendDetachedInventory(
|
||||
inv, name, p->getPeerId());
|
||||
}
|
||||
@@ -152,7 +152,7 @@ bool ServerInventoryManager::removeDetachedInventory(const std::string &name)
|
||||
if (m_env) {
|
||||
RemotePlayer *player = m_env->getPlayer(owner.c_str());
|
||||
|
||||
if (player && player->getPeerId() != PEER_ID_INEXISTENT)
|
||||
if (player)
|
||||
m_env->getGameDef()->sendDetachedInventory(
|
||||
nullptr, name, player->getPeerId());
|
||||
}
|
||||
|
Reference in New Issue
Block a user