mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
Server: Fix Server::Send exception caused by leaving players
Leaving players will have PEER_ID_INVALID for database saving purposes.
This patch clarifies that, and properly protects the batch send function.
Bug introduced by 5f5ea132
.
This commit is contained in:
parent
274d8a7c65
commit
499f2284bd
3 changed files with 5 additions and 2 deletions
|
@ -123,7 +123,8 @@ public:
|
||||||
|
|
||||||
bool inventory_formspec_overridden = false;
|
bool inventory_formspec_overridden = false;
|
||||||
|
|
||||||
/// returns PEER_ID_INEXISTENT when PlayerSAO is not ready
|
/// returns PEER_ID_INEXISTENT when PlayerSAO is either
|
||||||
|
/// not yet present or about to be removed (e.g. leave).
|
||||||
session_t getPeerId() const { return m_peer_id; }
|
session_t getPeerId() const { return m_peer_id; }
|
||||||
|
|
||||||
void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
|
void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
|
||||||
|
|
|
@ -1618,7 +1618,7 @@ void Server::SendSpawnParticles(RemotePlayer *player,
|
||||||
const float radius_sq = radius * radius;
|
const float radius_sq = radius * radius;
|
||||||
|
|
||||||
PlayerSAO *sao = player->getPlayerSAO();
|
PlayerSAO *sao = player->getPlayerSAO();
|
||||||
if (!sao)
|
if (!sao || sao->isGone())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::ostringstream particle_batch_data(std::ios_base::binary);
|
std::ostringstream particle_batch_data(std::ios_base::binary);
|
||||||
|
|
|
@ -50,6 +50,8 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t p
|
||||||
m_armor_groups["immortal"] = 1;
|
m_armor_groups["immortal"] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PlayerSAO::~PlayerSAO(): eventually deleted by `ActiveObjectMgr::removeObject`
|
||||||
|
|
||||||
void PlayerSAO::finalize(RemotePlayer *player, const std::set<std::string> &privs)
|
void PlayerSAO::finalize(RemotePlayer *player, const std::set<std::string> &privs)
|
||||||
{
|
{
|
||||||
assert(player);
|
assert(player);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue