aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2018-02-20 19:32:24 +0000
committerSmallJoker <mk939@ymail.com>2018-06-03 17:32:00 +0200
commit8aaf526730a621ae6d8d2839730437b605d892e7 (patch)
treed23cf65c6cb1e30f774b008c251f65ad8b435558
parentc683e050d45285f38f822f04eeb65ad6c604c119 (diff)
downloadminetest-8aaf526730a621ae6d8d2839730437b605d892e7.tar.gz
minetest-8aaf526730a621ae6d8d2839730437b605d892e7.tar.bz2
minetest-8aaf526730a621ae6d8d2839730437b605d892e7.zip
SAO limits: Allow SAOs to exist outside the set 'mapgen limit'
-rw-r--r--src/content_sao.cpp14
-rw-r--r--src/map.cpp5
-rw-r--r--src/map.h2
-rw-r--r--src/mapgen.cpp26
-rw-r--r--src/mapgen.h5
-rw-r--r--src/serverenvironment.cpp3
6 files changed, 5 insertions, 50 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 1234e3915..c22e341a9 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -406,20 +406,6 @@ 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_pending_removal = true;
- return;
- }
- }
-
if(send_recommended == false)
return;
diff --git a/src/map.cpp b/src/map.cpp
index 0c57d6a8a..128971442 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1378,11 +1378,6 @@ s16 ServerMap::getWaterLevel()
return getMapgenParams()->water_level;
}
-bool ServerMap::saoPositionOverLimit(const v3f &p)
-{
- return getMapgenParams()->saoPosOverLimit(p);
-}
-
bool ServerMap::blockpos_over_mapgen_limit(v3s16 p)
{
const s16 mapgen_limit_bp = rangelim(
diff --git a/src/map.h b/src/map.h
index 4b6e08f96..5123a7ec1 100644
--- a/src/map.h
+++ b/src/map.h
@@ -377,8 +377,6 @@ public:
*/
ServerMapSector *createSector(v2s16 p);
- bool saoPositionOverLimit(const v3f &p);
-
/*
Blocks are generated by using these and makeBlock().
*/
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index f4165f5cd..cb0100722 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -1058,13 +1058,11 @@ void MapgenParams::writeParams(Settings *settings) const
bparams->writeParams(settings);
}
-// Calculate edges of outermost generated mapchunks (less than
-// 'mapgen_limit'), and corresponding exact limits for SAO entities.
+
+// Calculate exact edges of the outermost mapchunks that are within the
+// set 'mapgen_limit'.
void MapgenParams::calcMapgenEdges()
{
- if (m_mapgen_edges_calculated)
- return;
-
// Central chunk offset, in blocks
s16 ccoff_b = -chunksize / 2;
// Chunksize, in nodes
@@ -1089,31 +1087,15 @@ void MapgenParams::calcMapgenEdges()
// Mapgen edges, in nodes
mapgen_edge_min = ccmin - numcmin * csize_n;
mapgen_edge_max = ccmax + numcmax * csize_n;
- // SAO position limits, in Irrlicht units
- m_sao_limit_min = mapgen_edge_min * BS - 3.0f;
- m_sao_limit_max = mapgen_edge_max * BS + 3.0f;
m_mapgen_edges_calculated = true;
}
-bool MapgenParams::saoPosOverLimit(const v3f &p)
+s32 MapgenParams::getSpawnRangeMax()
{
if (!m_mapgen_edges_calculated)
calcMapgenEdges();
- return p.X < m_sao_limit_min ||
- p.X > m_sao_limit_max ||
- p.Y < m_sao_limit_min ||
- p.Y > m_sao_limit_max ||
- p.Z < m_sao_limit_min ||
- p.Z > m_sao_limit_max;
-}
-
-
-s32 MapgenParams::getSpawnRangeMax()
-{
- calcMapgenEdges();
-
return MYMIN(-mapgen_edge_min, mapgen_edge_max);
}
diff --git a/src/mapgen.h b/src/mapgen.h
index 9bfdb22de..d1845d598 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -145,8 +145,6 @@ struct MapgenParams {
mapgen_edge_min(-MAX_MAP_GENERATION_LIMIT),
mapgen_edge_max(MAX_MAP_GENERATION_LIMIT),
- m_sao_limit_min(-MAX_MAP_GENERATION_LIMIT * BS),
- m_sao_limit_max(MAX_MAP_GENERATION_LIMIT * BS),
m_mapgen_edges_calculated(false)
{
}
@@ -156,14 +154,11 @@ struct MapgenParams {
virtual void readParams(const Settings *settings);
virtual void writeParams(Settings *settings) const;
- bool saoPosOverLimit(const v3f &p);
s32 getSpawnRangeMax();
private:
void calcMapgenEdges();
- float m_sao_limit_min;
- float m_sao_limit_max;
bool m_mapgen_edges_calculated;
};
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp
index e4fcf626d..8a66d4dfa 100644
--- a/src/serverenvironment.cpp
+++ b/src/serverenvironment.cpp
@@ -579,8 +579,7 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
// If the player exists, ensure that they respawn inside legal bounds
// This fixes an assert crash when the player can't be added
// to the environment
- ServerMap &map = getServerMap();
- if (map.getMapgenParams()->saoPosOverLimit(playersao->getBasePosition())) {
+ if (objectpos_over_limit(playersao->getBasePosition())) {
actionstream << "Respawn position for player \""
<< player->getName() << "\" outside limits, resetting" << std::endl;
playersao->setBasePosition(m_server->findSpawnPos());