mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00: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:
parent
02a893d613
commit
32f68f35cf
6 changed files with 24 additions and 31 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue