Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
ServerMap Class Reference

#include <servermap.h>

+ Inheritance diagram for ServerMap:
+ Collaboration diagram for ServerMap:

Public Member Functions

 ServerMap (const std::string &savedir, IGameDef *gamedef, EmergeManager *emerge, MetricsBackend *mb)
 
 ~ServerMap ()
 
MapSectorcreateSector (v2s16 p)
 
bool blockpos_over_mapgen_limit (v3s16 p)
 
bool initBlockMake (v3s16 blockpos, BlockMakeData *data)
 
void finishBlockMake (BlockMakeData *data, std::map< v3s16, MapBlock * > *changed_blocks)
 
MapBlockcreateBlock (v3s16 p)
 
MapBlockemergeBlock (v3s16 p, bool create_blank=true) override
 
MapBlockgetBlockOrEmerge (v3s16 p3d, bool generate)
 
bool isBlockInQueue (v3s16 pos)
 
void addNodeAndUpdate (v3s16 p, MapNode n, std::map< v3s16, MapBlock * > &modified_blocks, bool remove_metadata) override
 
void beginSave () override
 
void endSave () override
 
void save (ModifiedState save_level) override
 
void listAllLoadableBlocks (std::vector< v3s16 > &dst)
 
void listAllLoadedBlocks (std::vector< v3s16 > &dst)
 
MapgenParamsgetMapgenParams ()
 
bool saveBlock (MapBlock *block) override
 
MapBlockloadBlock (v3s16 p)
 
MapBlockloadBlock (const std::string &blob, v3s16 p, bool save_after_load=false)
 Load a block that was already read from disk.
 
bool deleteBlock (v3s16 blockpos) override
 
void deleteDetachedBlocks ()
 
void step ()
 
void updateVManip (v3s16 pos)
 
void PrintInfo (std::ostream &out) override
 
bool isSavingEnabled ()
 
u64 getSeed ()
 
bool repairBlockLight (v3s16 blockpos, std::map< v3s16, MapBlock * > *modified_blocks)
 
void transformLiquids (std::map< v3s16, MapBlock * > &modified_blocks, ServerEnvironment *env)
 
void transforming_liquid_add (v3s16 p)
 
- Public Member Functions inherited from Map
 Map (IGameDef *gamedef)
 
virtual ~Map ()
 
 DISABLE_CLASS_COPY (Map)
 
void addEventReceiver (MapEventReceiver *event_receiver)
 
void removeEventReceiver (MapEventReceiver *event_receiver)
 
void dispatchEvent (const MapEditEvent &event)
 
MapSectorgetSectorNoGenerateNoLock (v2s16 p2d)
 
MapSectorgetSectorNoGenerate (v2s16 p2d)
 
virtual MapSectoremergeSector (v2s16 p)
 
MapBlockgetBlockNoCreate (v3s16 p)
 
MapBlockgetBlockNoCreateNoEx (v3s16 p)
 
const NodeDefManagergetNodeDefManager ()
 
bool isValidPosition (v3s16 p)
 
void setNode (v3s16 p, MapNode n)
 
MapNode getNode (v3s16 p, bool *is_valid_position=NULL)
 
void removeNodeAndUpdate (v3s16 p, std::map< v3s16, MapBlock * > &modified_blocks)
 
bool addNodeWithEvent (v3s16 p, MapNode n, bool remove_metadata=true)
 
bool removeNodeWithEvent (v3s16 p)
 
virtual bool maySaveBlocks ()
 
void timerUpdate (float dtime, float unload_timeout, s32 max_loaded_blocks, std::vector< v3s16 > *unloaded_blocks=NULL)
 
void unloadUnreferencedBlocks (std::vector< v3s16 > *unloaded_blocks=NULL)
 
void deleteSectors (std::vector< v2s16 > &list)
 
std::vector< v3s16findNodesWithMetadata (v3s16 p1, v3s16 p2)
 
NodeMetadatagetNodeMetadata (v3s16 p)
 
bool setNodeMetadata (v3s16 p, NodeMetadata *meta)
 Sets metadata for a node.
 
void removeNodeMetadata (v3s16 p)
 
NodeTimer getNodeTimer (v3s16 p)
 
void setNodeTimer (const NodeTimer &t)
 
void removeNodeTimer (v3s16 p)
 
template<typename F >
void forEachNodeInArea (v3s16 minp, v3s16 maxp, F func)
 
bool isBlockOccluded (MapBlock *block, v3s16 cam_pos_nodes)
 
bool isBlockOccluded (v3s16 pos_relative, v3s16 cam_pos_nodes, bool simple_check=false)
 

Static Public Member Functions

static MapDatabasecreateDatabase (const std::string &name, const std::string &savedir, Settings &conf)
 
static bool saveBlock (MapBlock *block, MapDatabase *db, int compression_level=-1)
 
static void deSerializeBlock (MapBlock *block, std::istream &is)
 

Public Attributes

MapSettingsManager settings_mgr
 

Protected Member Functions

void reportMetrics (u64 save_time_us, u32 saved_blocks, u32 all_blocks) override
 
- Protected Member Functions inherited from Map
bool determineAdditionalOcclusionCheck (v3s16 pos_camera, const core::aabbox3d< s16 > &block_bounds, v3s16 &to_check)
 
bool isOccluded (v3s16 pos_camera, v3s16 pos_target, float step, float stepfac, float start_offset, float end_offset, u32 needed_count)
 

Private Attributes

EmergeManagerm_emerge
 
std::string m_savedir
 
bool m_map_saving_enabled
 
int m_map_compression_level
 
std::set< v3s16m_chunks_in_progress
 
std::vector< std::unique_ptr< MapBlock > > m_detached_blocks
 
UniqueQueue< v3s16m_transforming_liquid
 
f32 m_transforming_liquid_loop_count_multiplier = 1.0f
 
u32 m_unprocessed_count = 0
 
u64 m_inc_trending_up_start_time = 0
 
bool m_queue_size_timer_started = false
 
bool m_map_metadata_changed = true
 
MapDatabaseAccessor m_db
 
MetricGaugePtr m_loaded_blocks_gauge
 
MetricCounterPtr m_save_time_counter
 
MetricCounterPtr m_save_count_counter
 

Friends

class ModApiMapgen
 

Additional Inherited Members

- Protected Attributes inherited from Map
IGameDefm_gamedef
 
std::set< MapEventReceiver * > m_event_receivers
 
std::unordered_map< v2s16, MapSector * > m_sectors
 
MapSectorm_sector_cache = nullptr
 
v2s16 m_sector_cache_p
 
const NodeDefManagerm_nodedef
 

Constructor & Destructor Documentation

◆ ServerMap()

◆ ~ServerMap()

ServerMap::~ServerMap ( )

References MapDatabaseAccessor::dbase, MapDatabaseAccessor::dbase_ro, deleteDetachedBlocks(), errorstream, FUNCTION_NAME, infostream, m_db, m_emerge, m_map_saving_enabled, m_savedir, MOD_STATE_WRITE_AT_UNLOAD, MapDatabaseAccessor::mutex, EmergeManager::resetMap(), save(), and verbosestream.

+ Here is the call graph for this function:

Member Function Documentation

◆ addNodeAndUpdate()

void ServerMap::addNodeAndUpdate ( v3s16 p,
MapNode n,
std::map< v3s16, MapBlock * > & modified_blocks,
bool remove_metadata )
overridevirtual

Reimplemented from Map.

References Map::addNodeAndUpdate(), CONTENT_AIR, dir(), g_7dirs, NodeDefManager::get(), MapNode::getContent(), Map::getNode(), ContentFeatures::isLiquid(), Map::m_nodedef, m_transforming_liquid, p(), and UniqueQueue< Value >::push_back().

+ Here is the call graph for this function:

◆ beginSave()

void ServerMap::beginSave ( )
overridevirtual

Reimplemented from Map.

References Database::beginSave(), MapDatabaseAccessor::dbase, m_db, and MapDatabaseAccessor::mutex.

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blockpos_over_mapgen_limit()

bool ServerMap::blockpos_over_mapgen_limit ( v3s16 p)

References getMapgenParams(), MAP_BLOCKSIZE, MAX_MAP_GENERATION_LIMIT, p(), and rangelim.

Referenced by initBlockMake().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createBlock()

MapBlock * ServerMap::createBlock ( v3s16 p)

References MapSector::createBlankBlock(), createSector(), MapSector::getBlockNoCreateNoEx(), infostream, and p().

Referenced by initBlockMake().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDatabase()

MapDatabase * ServerMap::createDatabase ( const std::string & name,
const std::string & savedir,
Settings & conf )
static

References Settings::getNoEx().

Referenced by ServerMap(), migrate_map_database(), and recompress_map_database().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createSector()

MapSector * ServerMap::createSector ( v2s16 p)

References blockpos_over_max_limit(), Map::getSectorNoGenerate(), Map::m_gamedef, and Map::m_sectors.

Referenced by createBlock(), emergeBlock(), initBlockMake(), and loadBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteBlock()

bool ServerMap::deleteBlock ( v3s16 blockpos)
overridevirtual

Reimplemented from Map.

References MapDatabaseAccessor::dbase, MapDatabase::deleteBlock(), MapSector::detachBlock(), Map::getBlockNoCreateNoEx(), Map::getSectorNoGenerate(), m_db, m_detached_blocks, and MapDatabaseAccessor::mutex.

Referenced by ModApiEnv::l_delete_area().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDetachedBlocks()

void ServerMap::deleteDetachedBlocks ( )

References m_detached_blocks.

Referenced by ~ServerMap(), and step().

+ Here is the caller graph for this function:

◆ deSerializeBlock()

void ServerMap::deSerializeBlock ( MapBlock * block,
std::istream & is )
static

References MapBlock::deSerialize(), g_profiler, PRECISION_MICRO, readU8(), and SPT_AVG.

Referenced by loadBlock(), and recompress_map_database().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emergeBlock()

MapBlock * ServerMap::emergeBlock ( v3s16 p,
bool create_blank = true )
overridevirtual

Reimplemented from Map.

References MapSector::createBlankBlock(), createSector(), Map::getBlockNoCreateNoEx(), loadBlock(), and p().

Referenced by ServerEnvironment::addActiveObjectRaw(), ServerEnvironment::clearObjects(), ServerEnvironment::deactivateFarObjects(), ServerEnvironment::deleteStaticFromBlock(), Server::findSpawnPos(), ServerEnvironment::findSunlight(), initBlockMake(), ServerEnvironment::removeRemovedObjects(), repairBlockLight(), and ServerEnvironment::saveStaticToBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ endSave()

void ServerMap::endSave ( )
overridevirtual

Reimplemented from Map.

References MapDatabaseAccessor::dbase, Database::endSave(), m_db, and MapDatabaseAccessor::mutex.

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ finishBlockMake()

void ServerMap::finishBlockMake ( BlockMakeData * data,
std::map< v3s16, MapBlock * > * changed_blocks )

References MMVManip::blitBackAll(), BlockMakeData::blockpos_max, BlockMakeData::blockpos_min, EMERGE_DBG_OUT, EmergeManager::enable_mapgen_debug_info, MapBlock::expireIsAirCache(), UniqueQueue< Value >::front(), Map::getBlockNoCreateNoEx(), m_chunks_in_progress, m_emerge, m_transforming_liquid, MOD_REASON_EXPIRE_IS_AIR, MOD_STATE_WRITE_NEEDED, UniqueQueue< Value >::pop_front(), UniqueQueue< Value >::push_back(), MapBlock::raiseModified(), MapBlock::setGenerated(), UniqueQueue< Value >::size(), BlockMakeData::transforming_liquid, and BlockMakeData::vmanip.

Referenced by EmergeThread::finishGen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBlockOrEmerge()

MapBlock * ServerMap::getBlockOrEmerge ( v3s16 p3d,
bool generate )

References EmergeManager::enqueueBlockEmerge(), Map::getBlockNoCreateNoEx(), m_emerge, and PEER_ID_INEXISTENT.

Referenced by ServerEnvironment::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMapgenParams()

MapgenParams * ServerMap::getMapgenParams ( )

References MapSettingsManager::mapgen_params, and settings_mgr.

Referenced by blockpos_over_mapgen_limit(), Server::findSpawnPos(), getSeed(), and initBlockMake().

+ Here is the caller graph for this function:

◆ getSeed()

u64 ServerMap::getSeed ( )

References getMapgenParams(), and MapgenParams::seed.

Referenced by Server::acceptAuth(), and initBlockMake().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initBlockMake()

bool ServerMap::initBlockMake ( v3s16 blockpos,
BlockMakeData * data )

References BlockMakeData::blockpos_max, BlockMakeData::blockpos_min, blockpos_over_mapgen_limit(), MapgenParams::chunksize, createBlock(), createSector(), EMERGE_DBG_OUT, emergeBlock(), EmergeManager::enable_mapgen_debug_info, FATAL_ERROR_IF, EmergeManager::getContainingChunk(), getMapgenParams(), getSeed(), MMVManip::initialEmerge(), EmergeManager::isBlockUnderground(), m_chunks_in_progress, m_emerge, Map::m_nodedef, BlockMakeData::nodedef, p(), BlockMakeData::seed, MapBlock::setIsUnderground(), and BlockMakeData::vmanip.

Referenced by EmergeThread::getBlockOrStartGen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBlockInQueue()

bool ServerMap::isBlockInQueue ( v3s16 pos)

References EmergeManager::isBlockInQueue(), and m_emerge.

Referenced by ServerEnvironment::getBlockStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSavingEnabled()

bool ServerMap::isSavingEnabled ( )
inline

References m_map_saving_enabled.

◆ listAllLoadableBlocks()

void ServerMap::listAllLoadableBlocks ( std::vector< v3s16 > & dst)

References MapDatabaseAccessor::dbase, MapDatabaseAccessor::dbase_ro, MapDatabase::listAllLoadableBlocks(), m_db, and MapDatabaseAccessor::mutex.

Referenced by ServerEnvironment::clearObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listAllLoadedBlocks()

void ServerMap::listAllLoadedBlocks ( std::vector< v3s16 > & dst)

References MapSector::getBlocks(), Map::m_sectors, and p().

Referenced by ServerEnvironment::clearObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadBlock() [1/2]

MapBlock * ServerMap::loadBlock ( const std::string & blob,
v3s16 p,
bool save_after_load = false )

Load a block that was already read from disk.

Used by EmergeManager.

Returns
non-null block (but can be blank)

References MapSector::createBlankBlockNoInsert(), createSector(), deSerializeBlock(), Map::dispatchEvent(), errorstream, g_profiler, g_settings, MapSector::getBlockNoCreateNoEx(), Settings::getBool(), MapSector::insertBlock(), m_emerge, m_transforming_liquid, MEET_OTHER, EmergeManager::ndef, PRECISION_MICRO, MapBlock::resetModified(), saveBlock(), ReflowScan::scan(), SPT_AVG, MapEditEvent::type, voxalgo::update_block_border_lighting(), and BaseException::what().

+ Here is the call graph for this function:

◆ loadBlock() [2/2]

MapBlock * ServerMap::loadBlock ( v3s16 p)

References g_profiler, Map::getBlockNoCreateNoEx(), MapDatabaseAccessor::loadBlock(), loadBlock(), m_db, and MapDatabaseAccessor::mutex.

Referenced by emergeBlock(), EmergeThread::getBlockOrStartGen(), and loadBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrintInfo()

void ServerMap::PrintInfo ( std::ostream & out)
overridevirtual

Reimplemented from Map.

Referenced by save().

+ Here is the caller graph for this function:

◆ repairBlockLight()

bool ServerMap::repairBlockLight ( v3s16 blockpos,
std::map< v3s16, MapBlock * > * modified_blocks )

Fixes lighting in one map block. May modify other blocks as well, as light can spread out of the specified block. Returns false if the block is not generated (so nothing changed), true otherwise.

References emergeBlock(), MapBlock::isGenerated(), and voxalgo::repair_block_light().

Referenced by ModApiEnv::l_fix_light().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reportMetrics()

void ServerMap::reportMetrics ( u64 save_time_us,
u32 saved_blocks,
u32 all_blocks )
overrideprotectedvirtual

Reimplemented from Map.

References MetricCounter::increment(), m_loaded_blocks_gauge, m_save_count_counter, m_save_time_counter, and MetricGauge::set().

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

void ServerMap::save ( ModifiedState save_level)
overridevirtual

Reimplemented from Map.

References Profiler::add(), beginSave(), endSave(), MapSector::getBlocks(), porting::getTimeUs(), infostream, m_map_metadata_changed, m_map_saving_enabled, Map::m_sectors, MOD_STATE_CLEAN, Profiler::print(), PrintInfo(), reportMetrics(), saveBlock(), MapSettingsManager::saveMapMeta(), settings_mgr, and warningstream.

Referenced by ~ServerMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveBlock() [1/2]

bool ServerMap::saveBlock ( MapBlock * block)
overridevirtual

Reimplemented from Map.

References MapDatabaseAccessor::dbase, m_db, m_map_compression_level, MapDatabaseAccessor::mutex, and saveBlock().

Referenced by Client::handleCommand_BlockData(), loadBlock(), save(), and saveBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveBlock() [2/2]

bool ServerMap::saveBlock ( MapBlock * block,
MapDatabase * db,
int compression_level = -1 )
static

References MapBlock::getPos(), MapBlock::resetModified(), MapDatabase::saveBlock(), SER_FMT_VER_HIGHEST_WRITE, and MapBlock::serialize().

+ Here is the call graph for this function:

◆ step()

void ServerMap::step ( )

References deleteDetachedBlocks().

Referenced by Server::AsyncRunStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transforming_liquid_add()

void ServerMap::transforming_liquid_add ( v3s16 p)

References m_transforming_liquid, p(), and UniqueQueue< Value >::push_back().

+ Here is the call graph for this function:

◆ transformLiquids()

void ServerMap::transformLiquids ( std::map< v3s16, MapBlock * > & modified_blocks,
ServerEnvironment * env )

References ScriptApiEnv::check_for_falling(), CONTENT_AIR, CONTENT_IGNORE, ContentFeatures::floats, ContentFeatures::floodable, UniqueQueue< Value >::front(), g_settings, NodeDefManager::get(), get_max_liquid_level(), Map::getBlockNoCreateNoEx(), MapNode::getContent(), NodeDefManager::getLightingFlags(), Map::getNode(), getNodeBlockPos(), Settings::getS32(), ServerEnvironment::getScriptIface(), IRollbackManager::getSuspect(), porting::getTimeMs(), Settings::getU16(), infostream, LIGHTBANK_DAY, LIGHTBANK_NIGHT, liquid_6dirs, ContentFeatures::liquid_alternative_flowing_id, ContentFeatures::liquid_alternative_source_id, LIQUID_FLOW_DOWN_MASK, LIQUID_FLOWING, LIQUID_LEVEL_MASK, LIQUID_LEVEL_MAX, LIQUID_LEVEL_SOURCE, LIQUID_NONE, ContentFeatures::liquid_range, ContentFeatures::liquid_renewable, LIQUID_SOURCE, ContentFeatures::liquid_type, ContentFeatures::liquid_viscosity, LiquidType_END, Map::m_gamedef, m_inc_trending_up_start_time, Map::m_nodedef, m_queue_size_timer_started, m_transforming_liquid, m_unprocessed_count, NodeNeighbor::n, NEIGHBOR_LOWER, NEIGHBOR_SAME_LEVEL, NEIGHBOR_UPPER, ScriptApiNode::node_on_flood(), ScriptApiEnv::on_liquid_transformed(), NodeNeighbor::p, p(), MapNode::param2, UniqueQueue< Value >::pop_front(), UniqueQueue< Value >::push_back(), IRollbackManager::reportAction(), IGameDef::rollback(), MapNode::setContent(), MapNode::setLight(), Map::setNode(), RollbackAction::setSetNode(), UniqueQueue< Value >::size(), NodeNeighbor::t, and voxalgo::update_lighting_nodes().

Referenced by Server::AsyncRunStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateVManip()

void ServerMap::updateVManip ( v3s16 pos)

References VoxelArea::contains(), EmergeManager::getCurrentMapgen(), Map::getNode(), idx, VoxelArea::index(), VoxelManipulator::m_area, VoxelManipulator::m_data, m_emerge, VoxelManipulator::m_flags, MMVManip::m_is_dirty, and Mapgen::vm.

Referenced by ServerEnvironment::removeNode(), ServerEnvironment::setNode(), and ServerEnvironment::swapNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ModApiMapgen

friend class ModApiMapgen
friend

Member Data Documentation

◆ m_chunks_in_progress

std::set<v3s16> ServerMap::m_chunks_in_progress
private

Referenced by finishBlockMake(), and initBlockMake().

◆ m_db

◆ m_detached_blocks

std::vector<std::unique_ptr<MapBlock> > ServerMap::m_detached_blocks
private

◆ m_emerge

◆ m_inc_trending_up_start_time

u64 ServerMap::m_inc_trending_up_start_time = 0
private

Referenced by transformLiquids().

◆ m_loaded_blocks_gauge

MetricGaugePtr ServerMap::m_loaded_blocks_gauge
private

Referenced by ServerMap(), and reportMetrics().

◆ m_map_compression_level

int ServerMap::m_map_compression_level
private

Referenced by ServerMap(), and saveBlock().

◆ m_map_metadata_changed

bool ServerMap::m_map_metadata_changed = true
private

Referenced by save().

◆ m_map_saving_enabled

bool ServerMap::m_map_saving_enabled
private

◆ m_queue_size_timer_started

bool ServerMap::m_queue_size_timer_started = false
private

Referenced by transformLiquids().

◆ m_save_count_counter

MetricCounterPtr ServerMap::m_save_count_counter
private

Referenced by ServerMap(), and reportMetrics().

◆ m_save_time_counter

MetricCounterPtr ServerMap::m_save_time_counter
private

Referenced by ServerMap(), and reportMetrics().

◆ m_savedir

std::string ServerMap::m_savedir
private

Referenced by ServerMap(), and ~ServerMap().

◆ m_transforming_liquid

UniqueQueue<v3s16> ServerMap::m_transforming_liquid
private

◆ m_transforming_liquid_loop_count_multiplier

f32 ServerMap::m_transforming_liquid_loop_count_multiplier = 1.0f
private

◆ m_unprocessed_count

u32 ServerMap::m_unprocessed_count = 0
private

Referenced by transformLiquids().

◆ settings_mgr

MapSettingsManager ServerMap::settings_mgr

Referenced by ServerMap(), getMapgenParams(), and save().


The documentation for this class was generated from the following files: