Skip to content

Commit

Permalink
Per player spawn point
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Feb 8, 2024
1 parent f7922d4 commit 7778e63
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/content_abm_grow_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class GrowTree : public ActiveBlockModifier
auto &nb = nbh[i];
const bool allow_grow_by_light =
(!nb.top || (nb.light <= params.tree_grow_light_max &&
!myrand_range(0, LIGHT_MAX - nb.light)));
myrand_range(0, LIGHT_MAX - nb.light) <= 3));
bool up_all_leaves = true;
//DUMP("gr", i, nb.top, nb.bottom, allow_grow_by_light, nb.water_level, nb.is_leaves, nb.is_tree, nb.is_liquid, nb.is_soil);

Expand Down
6 changes: 4 additions & 2 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3308,7 +3308,7 @@ void Server::RespawnPlayer(session_t peer_id)
bool repositioned = m_script->on_respawnplayer(playersao);
if (!repositioned) {
// setPos will send the new position to client
playersao->setPos(findSpawnPos());
playersao->setPos(findSpawnPos(playersao->getPlayer()->getName()));
}

playersao->m_ms_from_last_respawn = 0;
Expand Down Expand Up @@ -4247,7 +4247,7 @@ void Server::addShutdownError(const ModError &e)
}

#if 1
v3f Server::findSpawnPos()
v3f Server::findSpawnPos(const std::string &player_name)
{
ServerMap &map = m_env->getServerMap();
v3f nodeposf;
Expand All @@ -4256,6 +4256,8 @@ v3f Server::findSpawnPos()
g_settings->getS16NoEx("static_spawnpoint_find", find);
if (g_settings->getV3FNoEx("static_spawnpoint", nodeposf) && !find) {
return nodeposf * BS;
} else if (g_settings->getV3FNoEx("static_spawnpoint_" + player_name, nodeposf) && !find) {
return nodeposf * BS;
}

pos_t min_air_height = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Server : public con::PeerHandler, public MapEventReceiver,
bool showFormspec(const char *name, const std::string &formspec, const std::string &formname);
Map & getMap() { return m_env->getMap(); }
ServerEnvironment & getEnv() { return *m_env; }
v3f findSpawnPos();
v3f findSpawnPos(const std::string &player_name);

u32 hudAdd(RemotePlayer *player, HudElement *element);
bool hudRemove(RemotePlayer *player, u32 id);
Expand Down
4 changes: 2 additions & 2 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
// Set player position
infostream << "Server: Finding spawn place for player \""
<< player->getName() << "\"" << std::endl;
playersao->setBasePosition(m_server->findSpawnPos());
playersao->setBasePosition(m_server->findSpawnPos(player->getName()));

// Make sure the player is saved
player->setModified(true);
Expand All @@ -725,7 +725,7 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
if (objectpos_over_limit(playersao->getBasePosition())) {
actionstream << "Respawn position for player \""
<< player->getName() << "\" outside limits, resetting" << std::endl;
playersao->setBasePosition(m_server->findSpawnPos());
playersao->setBasePosition(m_server->findSpawnPos(player->getName()));
}
}

Expand Down

0 comments on commit 7778e63

Please sign in to comment.