Skip to content

Commit daddd37

Browse files
committedApr 21, 2013
Fix findSpawnPos()
1 parent 14ba94a commit daddd37

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed
 

‎src/server.cpp

+12-20
Original file line numberDiff line numberDiff line change
@@ -4951,36 +4951,28 @@ v3f findSpawnPos(ServerMap &map)
49514951
{
49524952
s32 range = 1 + i;
49534953
// We're going to try to throw the player to this position
4954-
v2s16 nodepos2d = v2s16(-range + (myrand()%(range*2)),
4955-
-range + (myrand()%(range*2)));
4956-
//v2s16 sectorpos = getNodeSectorPos(nodepos2d);
4957-
// Get ground height at point (fallbacks to heightmap function)
4954+
v2s16 nodepos2d = v2s16(
4955+
-range + (myrand() % (range * 2)),
4956+
-range + (myrand() % (range * 2)));
4957+
4958+
// Get ground height at point
49584959
s16 groundheight = map.findGroundLevel(nodepos2d);
4959-
// Don't go underwater
4960-
if(groundheight <= water_level)
4961-
{
4962-
//infostream<<"-> Underwater"<<std::endl;
4960+
if (groundheight <= water_level) // Don't go underwater
49634961
continue;
4964-
}
4965-
// Don't go to high places
4966-
if(groundheight > water_level + 6)
4967-
{
4968-
//infostream<<"-> Underwater"<<std::endl;
4962+
if (groundheight > water_level + 6) // Don't go to high places
49694963
continue;
4970-
}
49714964

4972-
nodepos = v3s16(nodepos2d.X, groundheight-2, nodepos2d.Y);
4965+
nodepos = v3s16(nodepos2d.X, groundheight, nodepos2d.Y);
49734966
bool is_good = false;
49744967
s32 air_count = 0;
4975-
for(s32 i=0; i<10; i++){
4968+
for (s32 i = 0; i < 10; i++) {
49764969
v3s16 blockpos = getNodeBlockPos(nodepos);
49774970
map.emergeBlock(blockpos, true);
4978-
MapNode n = map.getNodeNoEx(nodepos);
4979-
if(n.getContent() == CONTENT_AIR){
4971+
content_t c = map.getNodeNoEx(nodepos).getContent();
4972+
if (c == CONTENT_AIR || c == CONTENT_IGNORE) {
49804973
air_count++;
4981-
if(air_count >= 2){
4974+
if (air_count >= 2){
49824975
is_good = true;
4983-
nodepos.Y -= 1;
49844976
break;
49854977
}
49864978
}

0 commit comments

Comments
 (0)
Please sign in to comment.