@@ -2522,7 +2522,7 @@ void Server::RespawnPlayer(u16 peer_id)
2522
2522
2523
2523
bool repositioned = m_script->on_respawnplayer (playersao);
2524
2524
if (!repositioned){
2525
- v3f pos = findSpawnPos (m_env-> getServerMap () );
2525
+ v3f pos = findSpawnPos ();
2526
2526
// setPos will send the new position to client
2527
2527
playersao->setPos (pos);
2528
2528
}
@@ -3179,23 +3179,24 @@ std::string Server::getBuiltinLuaPath()
3179
3179
return porting::path_share + DIR_DELIM + " builtin" ;
3180
3180
}
3181
3181
3182
- v3f findSpawnPos (ServerMap &map )
3182
+ v3f Server:: findSpawnPos ()
3183
3183
{
3184
- // return v3f(50,50,50)*BS;
3184
+ ServerMap &map = m_env->getServerMap ();
3185
+ v3f nodeposf;
3186
+ if (g_settings->getV3FNoEx (" static_spawnpoint" , nodeposf)) {
3187
+ return nodeposf * BS;
3188
+ }
3185
3189
3186
- v3s16 nodepos;
3190
+ // Default position is static_spawnpoint
3191
+ // We will return it if we don't found a good place
3192
+ v3s16 nodepos (nodeposf.X , nodeposf.Y , nodeposf.Z );
3187
3193
3188
- #if 0
3189
- nodepos = v2s16(0,0);
3190
- groundheight = 20;
3191
- #endif
3192
-
3193
- #if 1
3194
3194
s16 water_level = map.getWaterLevel ();
3195
3195
3196
+ bool is_good = false ;
3197
+
3196
3198
// Try to find a good place a few times
3197
- for (s32 i=0 ; i<1000 ; i++)
3198
- {
3199
+ for (s32 i = 0 ; i < 1000 && !is_good; i++) {
3199
3200
s32 range = 1 + i;
3200
3201
// We're going to try to throw the player to this position
3201
3202
v2s16 nodepos2d = v2s16 (
@@ -3210,7 +3211,7 @@ v3f findSpawnPos(ServerMap &map)
3210
3211
continue ;
3211
3212
3212
3213
nodepos = v3s16 (nodepos2d.X , groundheight, nodepos2d.Y );
3213
- bool is_good = false ;
3214
+
3214
3215
s32 air_count = 0 ;
3215
3216
for (s32 i = 0 ; i < 10 ; i++) {
3216
3217
v3s16 blockpos = getNodeBlockPos (nodepos);
@@ -3225,13 +3226,7 @@ v3f findSpawnPos(ServerMap &map)
3225
3226
}
3226
3227
nodepos.Y ++;
3227
3228
}
3228
- if (is_good){
3229
- // Found a good place
3230
- // infostream<<"Searched through "<<i<<" places."<<std::endl;
3231
- break ;
3232
- }
3233
3229
}
3234
- #endif
3235
3230
3236
3231
return intToFloat (nodepos, BS);
3237
3232
}
@@ -3274,7 +3269,7 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id)
3274
3269
// Set player position
3275
3270
infostream<<" Server: Finding spawn place for player \" "
3276
3271
<<name<<" \" " <<std::endl;
3277
- v3f pos = findSpawnPos (m_env-> getServerMap () );
3272
+ v3f pos = findSpawnPos ();
3278
3273
player->setPosition (pos);
3279
3274
3280
3275
// Make sure the player is saved
0 commit comments