m_peer_id(peer_id_),
m_is_singleplayer(is_singleplayer)
{
- assert(m_peer_id != 0); // pre-condition
+ SANITY_CHECK(m_peer_id != PEER_ID_INEXISTENT);
m_prop.hp_max = PLAYER_MAX_HP_DEFAULT;
m_prop.breath_max = PLAYER_MAX_BREATH_DEFAULT;
void PlayerSAO::disconnected()
{
- m_peer_id = 0;
+ m_peer_id = PEER_ID_INEXISTENT;
m_pending_removal = true;
}
return NULL;
if (obj->getType() != ACTIVEOBJECT_TYPE_LUAENTITY)
return NULL;
+ if (obj->isGone())
+ return NULL;
return (LuaEntitySAO*)obj;
}
return NULL;
if (obj->getType() != ACTIVEOBJECT_TYPE_PLAYER)
return NULL;
+ if (obj->isGone())
+ return NULL;
return (PlayerSAO*)obj;
}
void Server::SendPlayerHP(session_t peer_id)
{
PlayerSAO *playersao = getPlayerSAO(peer_id);
- // In some rare case if the player is disconnected
- // while Lua call l_punch, for example, this can be NULL
- if (!playersao)
- return;
+ assert(playersao);
SendHP(peer_id, playersao->getHP());
m_script->player_event(playersao,"health_changed");
void Server::DiePlayer(session_t peer_id, const PlayerHPChangeReason &reason)
{
PlayerSAO *playersao = getPlayerSAO(peer_id);
- // In some rare cases this can be NULL -- if the player is disconnected
- // when a Lua function modifies l_punch, for example
- if (!playersao)
- return;
+ assert(playersao);
infostream << "Server::DiePlayer(): Player "
<< playersao->getPlayer()->getName()