mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-18 18:55:29 +02:00
ServerEnv: Clean up object lifecycle handling (#6414)
* ServerEnv: Clean up object lifecycle handling
This commit is contained in:
@@ -59,7 +59,7 @@ public:
|
||||
m_age += dtime;
|
||||
if(m_age > 10)
|
||||
{
|
||||
m_removed = true;
|
||||
m_pending_removal = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,12 +397,11 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
|
||||
{
|
||||
ServerMap *map = dynamic_cast<ServerMap *>(&m_env->getMap());
|
||||
assert(map);
|
||||
if (!m_pending_deactivation &&
|
||||
if (!m_pending_removal &&
|
||||
map->saoPositionOverLimit(m_base_position)) {
|
||||
infostream << "Remove SAO " << m_id << "(" << m_init_name
|
||||
infostream << "Removing SAO " << m_id << "(" << m_init_name
|
||||
<< "), outside of limits" << std::endl;
|
||||
m_pending_deactivation = true;
|
||||
m_removed = true;
|
||||
m_pending_removal = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -550,9 +549,9 @@ int LuaEntitySAO::punch(v3f dir,
|
||||
ServerActiveObject *puncher,
|
||||
float time_from_last_punch)
|
||||
{
|
||||
if (!m_registered){
|
||||
if (!m_registered) {
|
||||
// Delete unknown LuaEntities when punched
|
||||
m_removed = true;
|
||||
m_pending_removal = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -596,12 +595,10 @@ int LuaEntitySAO::punch(v3f dir,
|
||||
}
|
||||
|
||||
if (getHP() == 0) {
|
||||
m_removed = true;
|
||||
m_pending_removal = true;
|
||||
m_env->getScriptIface()->luaentity_on_death(m_id, puncher);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result.wear;
|
||||
}
|
||||
|
||||
@@ -1353,11 +1350,10 @@ void PlayerSAO::setWieldIndex(int i)
|
||||
}
|
||||
}
|
||||
|
||||
// Erase the peer id and make the object for removal
|
||||
void PlayerSAO::disconnected()
|
||||
{
|
||||
m_peer_id = 0;
|
||||
m_removed = true;
|
||||
m_pending_removal = true;
|
||||
}
|
||||
|
||||
void PlayerSAO::unlinkPlayerSessionAndSave()
|
||||
|
Reference in New Issue
Block a user