Skip to content

Commit

Permalink
pos
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Jul 24, 2024
1 parent 17f3a36 commit c05cb2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ if(ENABLE_TIFF AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/libtiff/CMakeList
set(TIFF_LIRARY TIFF::tiff)
set(TIFF_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/libtiff/libtiff ${CMAKE_CURRENT_SOURCE_DIR}/external/libtiff/libtiff)
include_directories(BEFORE SYSTEM ${TIFF_INCLUDE_DIR})
message(STATUS "Using tiff: ${TIFF_INCLUDE_DIR} ${TIFF_LIRARY}")
set(USE_TIFF 1)
endif()

Expand Down
31 changes: 15 additions & 16 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ void Server::onMapEditEvent(const MapEditEvent &event)
}

/* delete:
void Server::SetBlocksNotSent(std::map<v3s16, MapBlock *>& block)
void Server::SetBlocksNotSent(std::map<v3pos_t, MapBlock *>& block)
{
SetBlocksNotSent();
}
Expand Down Expand Up @@ -4272,7 +4272,7 @@ v3f Server::findSpawnPos(const std::string &player_name)
v3f nodeposf;

pos_t find = 0;
g_settings->getS16NoEx("static_spawnpoint_find", find);
g_settings->getPosNoEx("static_spawnpoint_find", find);
if (g_settings->getV3FNoEx("static_spawnpoint_" + player_name, nodeposf)) {
if (!find)
return nodeposf * BS;
Expand All @@ -4282,7 +4282,7 @@ v3f Server::findSpawnPos(const std::string &player_name)
}

pos_t min_air_height = 3;
g_settings->getS16NoEx("static_spawnpoint_find_height", min_air_height);
g_settings->getPosNoEx("static_spawnpoint_find_height", min_air_height);

bool is_good = false;
// Limit spawn range to mapgen edges (determined by 'mapgen_limit')
Expand All @@ -4298,7 +4298,7 @@ v3f Server::findSpawnPos(const std::string &player_name)
nodeposf.Z
-range + myrand_range(0, range*2));
// Get spawn level at point
s16 spawn_level = nodeposf.Y ? nodeposf.Y : m_emerge->getSpawnLevelAtPoint(nodepos2d);
auto spawn_level = nodeposf.Y ? nodeposf.Y : m_emerge->getSpawnLevelAtPoint(nodepos2d);
// Continue if MAX_MAP_GENERATION_LIMIT was returned by the mapgen to
// signify an unsuitable spawn position, or if outside limits.
if (spawn_level >= MAX_MAP_GENERATION_LIMIT ||
Expand Down Expand Up @@ -4361,39 +4361,39 @@ v3f Server::findSpawnPos(const std::string &player_name)
}
#endif

#if 0
#if 0
//fmtodo?

v3f Server::findSpawnPos()
{
ServerMap &map = m_env->getServerMap();
v3f nodeposf;
POS find = 0;
g_settings->getS16NoEx("static_spawnpoint_find", find);
pos_t find = 0;
g_settings->getPosNoEx("static_spawnpoint_find", find);
if (g_settings->getV3FNoEx("static_spawnpoint", nodeposf) && !find) {
return nodeposf * BS;
}

// todo: remove
//s16 water_level = map.getWaterLevel();
s16 water_level = m_emerge->getSpawnLevelAtPoint(v2s16(nodeposf.X, nodeposf.Z));
s16 vertical_spawn_range = g_settings->getS16("vertical_spawn_range");
//auto water_level = map.getWaterLevel();
auto water_level = m_emerge->getSpawnLevelAtPoint(v2pos_t(nodeposf.X, nodeposf.Z));
auto vertical_spawn_range = g_settings->getPos("vertical_spawn_range");
//============
auto cache_block_before_spawn = g_settings->getBool("cache_block_before_spawn");

bool is_good = false;
POS min_air_height = 3;
g_settings->getS16NoEx("static_spawnpoint_find_height", min_air_height);
pos_t min_air_height = 3;
g_settings->getPosNoEx("static_spawnpoint_find_height", min_air_height);

// Try to find a good place a few times
for (s32 i = 0; i < 4000 && !is_good; i++) {
s32 range = 1 + i;
// We're going to try to throw the player to this position
v2s16 nodepos2d = v2s16(nodeposf.X - range + (myrand() % (range * 2)),
auto nodepos2d = v2pos_t(nodeposf.X - range + (myrand() % (range * 2)),
nodeposf.Z - range + (myrand() % (range * 2)));
// FM version:
// Get ground height at point
s16 spawn_level = map.findGroundLevel(nodepos2d, cache_block_before_spawn);
auto spawn_level = map.findGroundLevel(nodepos2d, cache_block_before_spawn);

//DUMP(i, is_good, nodepos2d.X, nodepos2d.Y, spawn_level);

Expand All @@ -4415,11 +4415,10 @@ v3f Server::findSpawnPos()
s32 air_count = 0;
for (s32 ii = (vertical_spawn_range > 0) ? 0 : vertical_spawn_range - 50;
ii < vertical_spawn_range; ii++) {
v3s16 blockpos = getNodeBlockPos(nodepos);
auto blockpos = getNodeBlockPos(nodepos);
if (!map.emergeBlock(blockpos, false))
continue;
content_t c = map.getNode(nodepos).getContent();
DUMP(ii, c, air_count, nodepos.Y, is_good);
if (c == CONTENT_AIR /*|| c == CONTENT_IGNORE*/) {
air_count++;
if (air_count >= min_air_height) {
Expand Down

0 comments on commit c05cb2a

Please sign in to comment.