forked from Mirrorlandia_minetest/minetest
SAO limits: Allow SAOs to exist outside the set 'mapgen limit'
This commit is contained in:
parent
88a7160ad8
commit
359a940dde
@ -395,19 +395,6 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
|
|||||||
m_env->getScriptIface()->luaentity_Step(m_id, dtime);
|
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_removal &&
|
|
||||||
map->saoPositionOverLimit(m_base_position)) {
|
|
||||||
infostream << "Removing SAO " << m_id << "(" << m_init_name
|
|
||||||
<< "), outside of limits" << std::endl;
|
|
||||||
m_pending_removal = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!send_recommended)
|
if (!send_recommended)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1261,11 +1261,6 @@ s16 ServerMap::getWaterLevel()
|
|||||||
return getMapgenParams()->water_level;
|
return getMapgenParams()->water_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerMap::saoPositionOverLimit(const v3f &p)
|
|
||||||
{
|
|
||||||
return getMapgenParams()->saoPosOverLimit(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ServerMap::blockpos_over_mapgen_limit(v3s16 p)
|
bool ServerMap::blockpos_over_mapgen_limit(v3s16 p)
|
||||||
{
|
{
|
||||||
const s16 mapgen_limit_bp = rangelim(
|
const s16 mapgen_limit_bp = rangelim(
|
||||||
|
@ -350,8 +350,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
MapSector *createSector(v2s16 p);
|
MapSector *createSector(v2s16 p);
|
||||||
|
|
||||||
bool saoPositionOverLimit(const v3f &p);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Blocks are generated by using these and makeBlock().
|
Blocks are generated by using these and makeBlock().
|
||||||
*/
|
*/
|
||||||
|
@ -1079,13 +1079,11 @@ void MapgenParams::writeParams(Settings *settings) const
|
|||||||
bparams->writeParams(settings);
|
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()
|
void MapgenParams::calcMapgenEdges()
|
||||||
{
|
{
|
||||||
if (m_mapgen_edges_calculated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Central chunk offset, in blocks
|
// Central chunk offset, in blocks
|
||||||
s16 ccoff_b = -chunksize / 2;
|
s16 ccoff_b = -chunksize / 2;
|
||||||
// Chunksize, in nodes
|
// Chunksize, in nodes
|
||||||
@ -1110,31 +1108,15 @@ void MapgenParams::calcMapgenEdges()
|
|||||||
// Mapgen edges, in nodes
|
// Mapgen edges, in nodes
|
||||||
mapgen_edge_min = ccmin - numcmin * csize_n;
|
mapgen_edge_min = ccmin - numcmin * csize_n;
|
||||||
mapgen_edge_max = ccmax + numcmax * 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;
|
m_mapgen_edges_calculated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MapgenParams::saoPosOverLimit(const v3f &p)
|
s32 MapgenParams::getSpawnRangeMax()
|
||||||
{
|
{
|
||||||
if (!m_mapgen_edges_calculated)
|
if (!m_mapgen_edges_calculated)
|
||||||
calcMapgenEdges();
|
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);
|
return MYMIN(-mapgen_edge_min, mapgen_edge_max);
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,10 @@ struct MapgenParams {
|
|||||||
virtual void readParams(const Settings *settings);
|
virtual void readParams(const Settings *settings);
|
||||||
virtual void writeParams(Settings *settings) const;
|
virtual void writeParams(Settings *settings) const;
|
||||||
|
|
||||||
bool saoPosOverLimit(const v3f &p);
|
|
||||||
s32 getSpawnRangeMax();
|
s32 getSpawnRangeMax();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void calcMapgenEdges();
|
void calcMapgenEdges();
|
||||||
|
|
||||||
float m_sao_limit_min = -MAX_MAP_GENERATION_LIMIT * BS;
|
|
||||||
float m_sao_limit_max = MAX_MAP_GENERATION_LIMIT * BS;
|
|
||||||
bool m_mapgen_edges_calculated = false;
|
bool m_mapgen_edges_calculated = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -567,8 +567,7 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
|
|||||||
// If the player exists, ensure that they respawn inside legal bounds
|
// If the player exists, ensure that they respawn inside legal bounds
|
||||||
// This fixes an assert crash when the player can't be added
|
// This fixes an assert crash when the player can't be added
|
||||||
// to the environment
|
// to the environment
|
||||||
ServerMap &map = getServerMap();
|
if (objectpos_over_limit(playersao->getBasePosition())) {
|
||||||
if (map.getMapgenParams()->saoPosOverLimit(playersao->getBasePosition())) {
|
|
||||||
actionstream << "Respawn position for player \""
|
actionstream << "Respawn position for player \""
|
||||||
<< player->getName() << "\" outside limits, resetting" << std::endl;
|
<< player->getName() << "\" outside limits, resetting" << std::endl;
|
||||||
playersao->setBasePosition(m_server->findSpawnPos());
|
playersao->setBasePosition(m_server->findSpawnPos());
|
||||||
|
Loading…
Reference in New Issue
Block a user