aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen.h
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2017-06-04 22:28:32 +0100
committerparamat <mat.gregory@virginmedia.com>2017-06-11 02:11:08 +0100
commit842acbfad2b70550c562f6429d02c980912d2273 (patch)
tree8c17ebc69f973dcbf6bbd641251a9242dc010b83 /src/mapgen.h
parenta9f02ab51cd4b92a98d7b6dffe6d2838796ba9cc (diff)
downloadhax-minetest-server-842acbfad2b70550c562f6429d02c980912d2273.tar.gz
hax-minetest-server-842acbfad2b70550c562f6429d02c980912d2273.zip
(Re)spawn players within 'mapgen_limit'
Previously, findSpawnPos() did not take the 'mapgen_limit' setting into account, a small limit often resulted in a spawn out in the void. Use the recently added 'calcMapgenEdges()' to get max spawn range through a new mapgenParams function 'getSpawnRangeMax()'. Previously, when a player respawned into a world, 'objectpos_over_limit()' was used as a check, which was inaccurate. Use the recently added 'saoPosOverLimit()' to get exact mapgen edges. Also fix default value of 'm_sao_limit_min'.
Diffstat (limited to 'src/mapgen.h')
-rw-r--r--src/mapgen.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mapgen.h b/src/mapgen.h
index f5f21388c..ddc676e39 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -131,6 +131,9 @@ struct MapgenParams {
BiomeParams *bparams;
+ s16 mapgen_edge_min;
+ s16 mapgen_edge_max;
+
MapgenParams() :
mgtype(MAPGEN_DEFAULT),
chunksize(5),
@@ -139,9 +142,12 @@ struct MapgenParams {
mapgen_limit(MAX_MAP_GENERATION_LIMIT),
flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS),
bparams(NULL),
- m_sao_limit_min(MAX_MAP_GENERATION_LIMIT * BS),
+
+ 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_sao_limit_calculated(false)
+ m_mapgen_edges_calculated(false)
{
}
@@ -151,12 +157,14 @@ struct MapgenParams {
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_sao_limit_calculated;
+ bool m_mapgen_edges_calculated;
};