diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-06-03 19:57:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-03 19:57:02 +0200 |
commit | c6d54411056da2dd563015c9f90c4c5c0863bc71 (patch) | |
tree | 5d3b6fcedf46ce066022dd575b9570352a50a0c1 /src/content_sao.cpp | |
parent | 72eec0f6f55b8515606de05d88717a78e978dd2a (diff) | |
download | minetest-c6d54411056da2dd563015c9f90c4c5c0863bc71.tar.gz minetest-c6d54411056da2dd563015c9f90c4c5c0863bc71.tar.bz2 minetest-c6d54411056da2dd563015c9f90c4c5c0863bc71.zip |
Properly remove SAO when worldedges are overtaken (#5889)
* LuaEntitySAO: Remove beyond outermost mapchunk edges
Based on a commit by, and with help from, nerzhul.
Add 2 functions to class Mapgen:
A function to calculate actual mapgen edges, called from the Mapgen constructor.
A function called indirectly from content_sao.cpp per entity step to check SAO
position is within mapgen edges.
* Calculate borders from params not mapgen, which is not available everytime
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r-- | src/content_sao.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index f435fe938..be1c52fe6 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -406,6 +406,20 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) m_env->getScriptIface()->luaentity_Step(m_id, dtime); } + // Remove LuaEntity beyond terrain edges + { + ServerMap *map = dynamic_cast<ServerMap *>(&m_env->getMap()); + assert(map); + if (!m_pending_deactivation && + map->saoPositionOverLimit(m_base_position)) { + infostream << "Remove SAO " << m_id << "(" << m_init_name + << "), outside of limits" << std::endl; + m_pending_deactivation = true; + m_removed = true; + return; + } + } + if(send_recommended == false) return; |