mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
FindSpawnPos: Let mapgens decide what spawn altitude is suitable
To avoid spawn search failing in new specialised mapgens Increase spawn search range to 4000 nodes Add getSpawnLevelAtPoint() functions to EmergeManager, class Mapgen and all mapgens Remove getGroundLevelAtPoint() functions from all mapgens except mgv6 (possibly to be re-added later in the correct form to return actual ground level) Make mgvalleys flag names consistent with other mapgens Remove now unused 'vertical spawn range' setting
This commit is contained in:
parent
38e7122600
commit
4adbd69a37
19 changed files with 122 additions and 77 deletions
|
@ -3383,26 +3383,24 @@ v3f Server::findSpawnPos()
|
|||
return nodeposf * BS;
|
||||
}
|
||||
|
||||
s16 water_level = map.getWaterLevel();
|
||||
s16 vertical_spawn_range = g_settings->getS16("vertical_spawn_range");
|
||||
bool is_good = false;
|
||||
|
||||
// Try to find a good place a few times
|
||||
for(s32 i = 0; i < 1000 && !is_good; i++) {
|
||||
for(s32 i = 0; i < 4000 && !is_good; i++) {
|
||||
s32 range = 1 + i;
|
||||
// We're going to try to throw the player to this position
|
||||
v2s16 nodepos2d = v2s16(
|
||||
-range + (myrand() % (range * 2)),
|
||||
-range + (myrand() % (range * 2)));
|
||||
|
||||
// Get ground height at point
|
||||
s16 groundheight = map.findGroundLevel(nodepos2d);
|
||||
// Don't go underwater or to high places
|
||||
if (groundheight <= water_level ||
|
||||
groundheight > water_level + vertical_spawn_range)
|
||||
// Get spawn level at point
|
||||
s16 spawn_level = m_emerge->getSpawnLevelAtPoint(nodepos2d);
|
||||
// Continue if MAX_MAP_GENERATION_LIMIT was returned by
|
||||
// the mapgen to signify an unsuitable spawn position
|
||||
if (spawn_level == MAX_MAP_GENERATION_LIMIT)
|
||||
continue;
|
||||
|
||||
v3s16 nodepos(nodepos2d.X, groundheight, nodepos2d.Y);
|
||||
v3s16 nodepos(nodepos2d.X, spawn_level, nodepos2d.Y);
|
||||
|
||||
s32 air_count = 0;
|
||||
for (s32 i = 0; i < 10; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue