aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
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/server.cpp
parenta9f02ab51cd4b92a98d7b6dffe6d2838796ba9cc (diff)
downloadminetest-842acbfad2b70550c562f6429d02c980912d2273.tar.gz
minetest-842acbfad2b70550c562f6429d02c980912d2273.tar.bz2
minetest-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/server.cpp')
-rw-r--r--src/server.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 179147637..4d7947919 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3523,10 +3523,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)),