diff options
author | Weblate <42@minetest.ru> | 2013-04-22 22:37:16 +0200 |
---|---|---|
committer | Weblate <42@minetest.ru> | 2013-04-22 22:37:16 +0200 |
commit | 418c2e7a446f8f0aca9f8bd23005a5896869ef7e (patch) | |
tree | 8c5e67eb5bc538174e768002c5419e86600c0623 /src/server.cpp | |
parent | 4117ab473bcc393f6081277df96dd27c898c90ad (diff) | |
parent | 58ded5cd27dd6e5ba740b22d8a3b0917f3d98150 (diff) | |
download | minetest-418c2e7a446f8f0aca9f8bd23005a5896869ef7e.tar.gz minetest-418c2e7a446f8f0aca9f8bd23005a5896869ef7e.tar.bz2 minetest-418c2e7a446f8f0aca9f8bd23005a5896869ef7e.zip |
Merge remote branch 'origin/master'
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/server.cpp b/src/server.cpp index 241826ba2..7fad623c2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4951,36 +4951,28 @@ v3f findSpawnPos(ServerMap &map) { 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))); - //v2s16 sectorpos = getNodeSectorPos(nodepos2d); - // Get ground height at point (fallbacks to heightmap function) + 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 - if(groundheight <= water_level) - { - //infostream<<"-> Underwater"<<std::endl; + if (groundheight <= water_level) // Don't go underwater continue; - } - // Don't go to high places - if(groundheight > water_level + 6) - { - //infostream<<"-> Underwater"<<std::endl; + if (groundheight > water_level + 6) // Don't go to high places continue; - } - nodepos = v3s16(nodepos2d.X, groundheight-2, nodepos2d.Y); + nodepos = v3s16(nodepos2d.X, groundheight, nodepos2d.Y); bool is_good = false; s32 air_count = 0; - for(s32 i=0; i<10; i++){ + for (s32 i = 0; i < 10; i++) { v3s16 blockpos = getNodeBlockPos(nodepos); map.emergeBlock(blockpos, true); - MapNode n = map.getNodeNoEx(nodepos); - if(n.getContent() == CONTENT_AIR){ + content_t c = map.getNodeNoEx(nodepos).getContent(); + if (c == CONTENT_AIR || c == CONTENT_IGNORE) { air_count++; - if(air_count >= 2){ + if (air_count >= 2){ is_good = true; - nodepos.Y -= 1; break; } } |