Page 1 of 1

Player spawning C++?

PostPosted: Fri Jan 11, 2013 03:08
by 0gb.us
This is going to sound odd, but does anyone know where in the C++ (or Lua, but I think this is in the C++) the player spawn range is set? I found the static spawn point code, but I can't find the code for when there is no static spawn point enabled.

Thanks for the help!

PostPosted: Fri Jan 11, 2013 04:30
by hdastwb
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
v3f findSpawnPos(ServerMap &map)


implemented on line 4786 of server.cpp.

It looks like there isn't exactly a spawn range, though; from my interpretation of the code it looks like the function fans out from a 2x2 to a 2000x2000 range as it goes along…

PostPosted: Fri Jan 11, 2013 05:45
by 0gb.us
hdastwb wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
v3f findSpawnPos(ServerMap &map)


implemented on line 4786 of server.cpp.

It looks like there isn't exactly a spawn range, though; from my interpretation of the code it looks like the function fans out from a 2x2 to a 2000x2000 range as it goes along…


Thanks a lot, that's just what I needed!

Some of that function seems cryptic to me, as I've never worked in C++, but I see what you mean about it fanning out. I've never noticed myself spawning as far as 1000 nodes away from 0,0, but it looks like it's possible.

I also sow some other interesting stuff there. I've seen that the game doesn't like to spawn players in deep water or inside solid rock, but apparently it doesn't like spawning players on top of high mountains either. Maybe this is to prevent players from spawning on top of those really high pillars you see occasionally, with no way down.

PostPosted: Fri Jan 11, 2013 08:03
by Jordach
In the past it used to be stupid and made players spawn underground.

PostPosted: Fri Jan 11, 2013 11:21
by rarkenin
It still seems to spawn me within rock, but only one layer in.