1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

(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'.
This commit is contained in:
paramat 2017-06-04 22:28:32 +01:00 committed by paramat
parent a9f02ab51c
commit 842acbfad2
4 changed files with 33 additions and 13 deletions

View file

@ -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)),