Minetest  5.4.0
ServerMap Class Reference

#include <map.h>

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

Public Member Functions

 ServerMap (const std::string &savedir, IGameDef *gamedef, EmergeManager *emerge, MetricsBackend *mb)
 
 ~ServerMap ()
 
s32 mapType () const
 
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)
 
MapBlockgetBlockOrEmerge (v3s16 p3d)
 
void beginSave ()
 
void endSave ()
 
void save (ModifiedState save_level)
 
void listAllLoadableBlocks (std::vector< v3s16 > &dst)
 
void listAllLoadedBlocks (std::vector< v3s16 > &dst)
 
MapgenParamsgetMapgenParams ()
 
bool saveBlock (MapBlock *block)
 
MapBlockloadBlock (v3s16 p)
 
void loadBlock (std::string *blob, v3s16 p3d, MapSector *sector, bool save_after_load=false)
 
bool deleteBlock (v3s16 blockpos)
 
void updateVManip (v3s16 pos)
 
virtual void PrintInfo (std::ostream &out)
 
bool isSavingEnabled ()
 
u64 getSeed ()
 
bool repairBlockLight (v3s16 blockpos, std::map< v3s16, MapBlock * > *modified_blocks)
 
- Public Member Functions inherited from Map
 Map (IGameDef *gamedef)
 
virtual ~Map ()
 
 DISABLE_CLASS_COPY (Map)
 
virtual void drop ()
 
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 isNodeUnderground (v3s16 p)
 
bool isValidPosition (v3s16 p)
 
void setNode (v3s16 p, MapNode &n)
 
MapNode getNode (v3s16 p, bool *is_valid_position=NULL)
 
void addNodeAndUpdate (v3s16 p, MapNode n, std::map< v3s16, MapBlock * > &modified_blocks, bool remove_metadata=true)
 
void removeNodeAndUpdate (v3s16 p, std::map< v3s16, MapBlock * > &modified_blocks)
 
bool addNodeWithEvent (v3s16 p, MapNode n, bool remove_metadata=true)
 
bool removeNodeWithEvent (v3s16 p)
 
void timerUpdate (float dtime, float unload_timeout, u32 max_loaded_blocks, std::vector< v3s16 > *unloaded_blocks=NULL)
 
void unloadUnreferencedBlocks (std::vector< v3s16 > *unloaded_blocks=NULL)
 
void deleteSectors (std::vector< v2s16 > &list)
 
void transformLiquids (std::map< v3s16, MapBlock * > &modified_blocks, ServerEnvironment *env)
 
std::vector< v3s16findNodesWithMetadata (v3s16 p1, v3s16 p2)
 
NodeMetadatagetNodeMetadata (v3s16 p)
 
bool setNodeMetadata (v3s16 p, NodeMetadata *meta)
 Sets metadata for a node. More...
 
void removeNodeMetadata (v3s16 p)
 
NodeTimer getNodeTimer (v3s16 p)
 
void setNodeTimer (const NodeTimer &t)
 
void removeNodeTimer (v3s16 p)
 
void transforming_liquid_add (v3s16 p)
 
bool isBlockOccluded (MapBlock *block, v3s16 cam_pos_nodes)
 

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)
 

Public Attributes

MapSettingsManager settings_mgr
 

Private Attributes

EmergeManagerm_emerge
 
std::string m_savedir
 
bool m_map_saving_enabled
 
int m_map_compression_level
 
std::set< v3s16m_chunks_in_progress
 
bool m_map_metadata_changed = true
 
MapDatabasedbase = nullptr
 
MapDatabasedbase_ro = nullptr
 
MetricCounterPtr m_save_time_counter
 

Additional Inherited Members

- Protected Member Functions inherited from Map
bool determineAdditionalOcclusionCheck (const v3s16 &pos_camera, const core::aabbox3d< s16 > &block_bounds, v3s16 &check)
 
bool isOccluded (const v3s16 &pos_camera, const v3s16 &pos_target, float step, float stepfac, float start_offset, float end_offset, u32 needed_count)
 
- Protected Attributes inherited from Map
IGameDefm_gamedef
 
std::set< MapEventReceiver * > m_event_receivers
 
std::map< v2s16, MapSector * > m_sectors
 
MapSectorm_sector_cache = nullptr
 
v2s16 m_sector_cache_p
 
UniqueQueue< v3s16m_transforming_liquid
 
const NodeDefManagerm_nodedef
 

Constructor & Destructor Documentation

◆ ServerMap()

◆ ~ServerMap()

ServerMap::~ServerMap ( )

References dbase, dbase_ro, FUNCTION_NAME, infostream, m_map_saving_enabled, m_savedir, MOD_STATE_WRITE_AT_UNLOAD, save(), and verbosestream.

+ Here is the call graph for this function:

Member Function Documentation

◆ beginSave()

void ServerMap::beginSave ( )
virtual

Reimplemented from Map.

References Database::beginSave(), and dbase.

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 blockpos_over_max_limit(), MapSector::createBlankBlock(), createSector(), MapSector::getBlockNoCreateNoEx(), infostream, MapBlock::isDummy(), p(), and MapBlock::unDummify().

Referenced by initBlockMake(), and MMVManip::initialEmerge().

+ 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(), and migrate_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 Map::getSectorNoGenerate(), Map::m_gamedef, Map::m_sectors, MAP_BLOCKSIZE, and MAX_MAP_GENERATION_LIMIT.

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)
virtual

Reimplemented from Map.

References dbase, MapDatabase::deleteBlock(), MapSector::deleteBlock(), Map::getBlockNoCreateNoEx(), and Map::getSectorNoGenerate().

Referenced by ModApiEnvMod::l_delete_area().

+ 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 
)
virtual

Reimplemented from Map.

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

Referenced by ServerEnvironment::addActiveObjectRaw(), ServerEnvironment::clearObjects(), ServerEnvironment::deactivateFarObjects(), ServerEnvironment::deleteStaticFromBlock(), Server::findSpawnPos(), ServerEnvironment::findSunlight(), initBlockMake(), MMVManip::initialEmerge(), voxalgo::is_sunlight_above_block(), 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 ( )
virtual

Reimplemented from Map.

References dbase, and Database::endSave().

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 
)

◆ getBlockOrEmerge()

MapBlock * ServerMap::getBlockOrEmerge ( v3s16  p3d)

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(), Server::init(), 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(), PP, 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:

◆ isSavingEnabled()

bool ServerMap::isSavingEnabled ( )
inline

References m_map_saving_enabled.

◆ listAllLoadableBlocks()

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

References dbase, dbase_ro, and MapDatabase::listAllLoadableBlocks().

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]

void ServerMap::loadBlock ( std::string *  blob,
v3s16  p3d,
MapSector sector,
bool  save_after_load = false 
)

◆ loadBlock() [2/2]

MapBlock * ServerMap::loadBlock ( v3s16  p)

References createSector(), dbase, dbase_ro, Map::dispatchEvent(), Map::getBlockNoCreateNoEx(), MapDatabase::loadBlock(), MEET_OTHER, MapEditEvent::type, and voxalgo::update_block_border_lighting().

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

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

◆ mapType()

s32 ServerMap::mapType ( ) const
inlinevirtual

Reimplemented from Map.

References MAPTYPE_SERVER.

◆ PrintInfo()

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

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 ModApiEnvMod::l_fix_light().

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

◆ save()

void ServerMap::save ( ModifiedState  save_level)
virtual

Reimplemented from Map.

References Profiler::add(), beginSave(), endSave(), MapSector::getBlocks(), porting::getTimeNs(), infostream, m_map_metadata_changed, m_map_saving_enabled, m_save_time_counter, Map::m_sectors, MOD_STATE_CLEAN, Profiler::print(), PrintInfo(), 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)
virtual

Reimplemented from Map.

References dbase, and m_map_compression_level.

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

+ 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::isDummy(), PP, MapBlock::resetModified(), MapDatabase::saveBlock(), SER_FMT_VER_HIGHEST_WRITE, MapBlock::serialize(), and warningstream.

+ Here is the call 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, Mapgen::vm, and VOXELFLAG_NO_DATA.

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:

Member Data Documentation

◆ dbase

◆ dbase_ro

MapDatabase* ServerMap::dbase_ro = nullptr
private

◆ m_chunks_in_progress

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

Referenced by finishBlockMake(), and initBlockMake().

◆ m_emerge

EmergeManager* ServerMap::m_emerge
private

◆ 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_save_time_counter

MetricCounterPtr ServerMap::m_save_time_counter
private

Referenced by ServerMap(), and save().

◆ m_savedir

std::string ServerMap::m_savedir
private

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

◆ settings_mgr

MapSettingsManager ServerMap::settings_mgr

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