diff options
author | paramat <paramat@users.noreply.github.com> | 2017-06-04 22:28:32 +0100 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2018-06-03 17:31:59 +0200 |
commit | 7aa52fe4e195ad9d66f0bda51688b81d31391346 (patch) | |
tree | add64962f2b2f6397cf32d5b9aac58d558b7e6af /src/server.cpp | |
parent | 0664b5f77226b7a2308e85898295378e04158923 (diff) | |
download | minetest-7aa52fe4e195ad9d66f0bda51688b81d31391346.tar.gz minetest-7aa52fe4e195ad9d66f0bda51688b81d31391346.tar.bz2 minetest-7aa52fe4e195ad9d66f0bda51688b81d31391346.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/server.cpp')
-rw-r--r-- | src/server.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp index a0c4e30d8..83022e95b 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3516,10 +3516,12 @@ v3f Server::findSpawnPos() } bool is_good = false; + // Limit spawn range to mapgen edges (determined by 'mapgen_limit') + s32 range_max = map.getMapgenParams()->getSpawnRangeMax(); // Try to find a good place a few times for(s32 i = 0; i < 4000 && !is_good; i++) { - s32 range = 1 + i; + s32 range = MYMIN(1 + i, range_max); // We're going to try to throw the player to this position v2s16 nodepos2d = v2s16( -range + (myrand() % (range * 2)), |