From 04839f233f37faa9af406ea66fc6c199127781eb Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 15 Sep 2017 12:19:01 +0200 Subject: ServerEnv: Clean up object lifecycle handling (#6414) * ServerEnv: Clean up object lifecycle handling --- src/content_sao.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/content_sao.cpp') diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 2a2384b3d..f0004da01 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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(&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() -- cgit v1.2.3