Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
Map Class Reference

#include <map.h>

+ Inheritance diagram for Map:
+ Collaboration diagram for Map:

Public Member Functions

 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)
 
virtual MapBlockemergeBlock (v3s16 p, bool create_blank=true)
 
const NodeDefManagergetNodeDefManager ()
 
bool isValidPosition (v3s16 p)
 
void setNode (v3s16 p, MapNode n)
 
MapNode getNode (v3s16 p, bool *is_valid_position=NULL)
 
virtual 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)
 
virtual void beginSave ()
 
virtual void endSave ()
 
virtual void save (ModifiedState save_level)
 
virtual bool maySaveBlocks ()
 
virtual bool saveBlock (MapBlock *block)
 
virtual bool deleteBlock (v3s16 blockpos)
 
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)
 
virtual void PrintInfo (std::ostream &out)
 
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)
 

Protected Member Functions

virtual void reportMetrics (u64 save_time_us, u32 saved_blocks, u32 all_blocks)
 
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)
 

Protected Attributes

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

◆ Map()

Map::Map ( IGameDef * gamedef)

◆ ~Map()

Map::~Map ( )
virtual

References m_sectors.

Member Function Documentation

◆ addEventReceiver()

void Map::addEventReceiver ( MapEventReceiver * event_receiver)

References m_event_receivers.

Referenced by ServerEnvironment::init().

+ Here is the caller graph for this function:

◆ addNodeAndUpdate()

void Map::addNodeAndUpdate ( v3s16 p,
MapNode n,
std::map< v3s16, MapBlock * > & modified_blocks,
bool remove_metadata = true )
virtual

Reimplemented in ServerMap.

References CONTENT_AIR, MapBlock::expireIsAirCache(), getBlockNoCreate(), MapNode::getContent(), NodeDefManager::getLightingFlags(), MapNode::getLightRaw(), getNodeBlockPos(), MapBlock::getNodeNoCheck(), LIGHTBANK_DAY, LIGHTBANK_NIGHT, m_gamedef, m_nodedef, MAP_BLOCKSIZE, IGameDef::ndef(), p(), removeNodeMetadata(), IRollbackManager::reportAction(), IGameDef::rollback(), set_node_in_block(), MapNode::setLight(), RollbackAction::setSetNode(), and voxalgo::update_lighting_nodes().

Referenced by Client::addNode(), ServerMap::addNodeAndUpdate(), addNodeWithEvent(), removeNodeAndUpdate(), TEST_CASE(), and TestVoxelAlgorithms::testLighting().

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

◆ addNodeWithEvent()

bool Map::addNodeWithEvent ( v3s16 p,
MapNode n,
bool remove_metadata = true )

References addNodeAndUpdate(), dispatchEvent(), MEET_ADDNODE, MEET_SWAPNODE, p(), and MapEditEvent::type.

Referenced by RollbackAction::applyRevert(), ServerEnvironment::setNode(), and ServerEnvironment::swapNode().

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

◆ beginSave()

virtual void Map::beginSave ( )
inlinevirtual

Reimplemented in ServerMap.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ deleteBlock()

virtual bool Map::deleteBlock ( v3s16 blockpos)
inlinevirtual

Reimplemented in ServerMap.

◆ deleteSectors()

void Map::deleteSectors ( std::vector< v2s16 > & list)

References m_sector_cache, and m_sectors.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ determineAdditionalOcclusionCheck()

bool Map::determineAdditionalOcclusionCheck ( v3s16 pos_camera,
const core::aabbox3d< s16 > & block_bounds,
v3s16 & to_check )
protected

References CLOSEST_EDGE.

Referenced by isBlockOccluded().

+ Here is the caller graph for this function:

◆ DISABLE_CLASS_COPY()

Map::DISABLE_CLASS_COPY ( Map )

◆ dispatchEvent()

◆ emergeBlock()

virtual MapBlock * Map::emergeBlock ( v3s16 p,
bool create_blank = true )
inlinevirtual

Reimplemented in ServerMap.

References getBlockNoCreateNoEx(), and p().

Referenced by RollbackAction::applyRevert(), findNodesWithMetadata(), getNodeMetadata(), getNodeTimer(), MMVManip::initialEmerge(), voxalgo::is_sunlight_above_block(), ModApiEnv::l_load_area(), setNodeMetadata(), setNodeTimer(), TestSAO::testActivate(), TestSAO::testNotSaved(), and TestSAO::testStaticToFalse().

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

◆ emergeSector()

virtual MapSector * Map::emergeSector ( v2s16 p)
inlinevirtual

Reimplemented in ClientMap.

Referenced by Client::handleCommand_BlockData(), and Client::step().

+ Here is the caller graph for this function:

◆ endSave()

virtual void Map::endSave ( )
inlinevirtual

Reimplemented in ServerMap.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ findNodesWithMetadata()

std::vector< v3s16 > Map::findNodesWithMetadata ( v3s16 p1,
v3s16 p2 )

References VoxelArea::contains(), emergeBlock(), NodeMetadataList::getAllKeys(), getBlockNoCreateNoEx(), getNodeBlockPos(), infostream, MapBlock::m_node_metadata, MAP_BLOCKSIZE, p(), sortBoxVerticies(), and verbosestream.

+ Here is the call graph for this function:

◆ forEachNodeInArea()

template<typename F >
void Map::forEachNodeInArea ( v3s16 minp,
v3s16 maxp,
F func )
inline

References CONTENT_IGNORE, getBlockNoCreateNoEx(), getNodeBlockPos(), MapBlock::getNodeNoCheck(), MAP_BLOCKSIZE, p(), and rangelim.

Referenced by ModApiEnv::l_find_nodes_in_area(), TestMap::testForEachNodeInArea(), TestMap::testForEachNodeInAreaBlank(), and TestMap::testForEachNodeInAreaEmpty().

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

◆ getBlockNoCreate()

MapBlock * Map::getBlockNoCreate ( v3s16 p)

References getBlockNoCreateNoEx().

Referenced by addNodeAndUpdate(), and setNode().

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

◆ getBlockNoCreateNoEx()

MapBlock * Map::getBlockNoCreateNoEx ( v3s16 p)

References MapSector::getBlockNoCreateNoEx(), and getSectorNoGenerate().

Referenced by MeshUpdateQueue::addBlock(), Client::addUpdateMeshTask(), Server::AsyncRunStep(), voxalgo::blit_back_with_light(), MMVManip::blitBackAll(), ServerEnvironment::clearObjects(), ABMHandler::countObjects(), ServerEnvironment::deactivateFarObjects(), ServerMap::deleteBlock(), ServerEnvironment::deleteStaticFromBlock(), emergeBlock(), ServerMap::emergeBlock(), findNodesWithMetadata(), voxalgo::finish_bulk_light_update(), ServerMap::finishBlockMake(), EmergeThread::finishGen(), forEachNodeInArea(), getBlockNoCreate(), ServerMap::getBlockOrEmerge(), EmergeThread::getBlockOrStartGen(), ServerEnvironment::getBlockStatus(), RemoteClient::GetNextBlocks(), getNode(), getNodeMetadata(), getNodeTimer(), MMVManip::initialEmerge(), voxalgo::is_sunlight_above(), voxalgo::is_sunlight_above_block(), ClientMap::isMeshOccluded(), isValidPosition(), ServerMap::loadBlock(), ReflowScan::lookupBlock(), voxalgo::propagate_block_sunlight(), removeNodeMetadata(), removeNodeTimer(), voxalgo::repair_block_light(), Server::SendBlock(), Server::SendBlocks(), setNodeMetadata(), setNodeTimer(), ServerEnvironment::setStaticForActiveObjectsInBlock(), voxalgo::spread_light(), ServerEnvironment::step(), TestSAO::testStaticSave(), TestSAO::testStaticToTrue(), ServerMap::transformLiquids(), voxalgo::unspread_light(), voxalgo::update_block_border_lighting(), voxalgo::update_lighting_nodes(), and ClientMap::updateDrawList().

+ Here is the call graph for this function:

◆ getNode()

MapNode Map::getNode ( v3s16 p,
bool * is_valid_position = NULL )

References CONTENT_IGNORE, getBlockNoCreateNoEx(), getNodeBlockPos(), MapBlock::getNodeNoCheck(), MAP_BLOCKSIZE, and p().

Referenced by RollbackNode::RollbackNode(), SmokePuffCSO::SmokePuffCSO(), add_area_node_boxes(), ServerMap::addNodeAndUpdate(), ABMHandler::apply(), RollbackAction::applyRevert(), Pathfinder::calcCost(), Environment::continueRaycast(), Client::CSMGetNode(), Server::findSpawnPos(), ServerEnvironment::findSunlight(), ClientMap::getBackgroundBrightness(), getNeighborConnectingFace(), Pathfinder::getPath(), LocalPlayer::getSlipFactor(), getVisibleBrightness(), LocalPlayer::handleAutojump(), Server::handleCommand_Interact(), Game::handleDigging(), Game::handlePointingAtNode(), GridNodeContainer::initNode(), voxalgo::is_light_locally_correct(), isOccluded(), ModApiEnv::l_find_node_near(), ModApiEnv::l_find_nodes_in_area_under_air(), Environment::line_of_sight(), LocalPlayer::move(), ScriptApiNode::node_on_receive_fields(), ScriptApiNodemeta::nodemeta_inventory_AllowMove(), ScriptApiNodemeta::nodemeta_inventory_AllowPut(), ScriptApiNodemeta::nodemeta_inventory_AllowTake(), ScriptApiNodemeta::nodemeta_inventory_OnMove(), ScriptApiNodemeta::nodemeta_inventory_OnPut(), ScriptApiNodemeta::nodemeta_inventory_OnTake(), Game::nodePlacement(), LocalPlayer::old_move(), ServerEnvironment::removeNode(), ClientMap::renderPostFx(), ServerEnvironment::setNode(), GenericCAO::step(), PlayerSAO::step(), TestMap::testForEachNodeInAreaBlank(), TestVoxelAlgorithms::testLighting(), ServerMap::transformLiquids(), Camera::update(), GameUI::update(), voxalgo::update_lighting_nodes(), ClientMap::updateDrawList(), GenericCAO::updateLight(), Particle::updateLight(), Game::updatePointedThing(), LocalPlayer::updateSneakNode(), Game::updateSound(), ServerMap::updateVManip(), and Pathfinder::walkDownwards().

+ Here is the call graph for this function:

◆ getNodeDefManager()

const NodeDefManager * Map::getNodeDefManager ( )
inline

References m_nodedef.

Referenced by voxalgo::blit_back_with_light(), Environment::continueRaycast(), voxalgo::finish_bulk_light_update(), MapNode::getNeighbors(), voxalgo::repair_block_light(), voxalgo::update_block_border_lighting(), voxalgo::update_lighting_nodes(), and Game::updatePointedThing().

+ Here is the caller graph for this function:

◆ getNodeMetadata()

NodeMetadata * Map::getNodeMetadata ( v3s16 p)

References emergeBlock(), NodeMetadataList::get(), getBlockNoCreateNoEx(), getNodeBlockPos(), infostream, MapBlock::m_node_metadata, MAP_BLOCKSIZE, p(), and warningstream.

Referenced by RollbackNode::RollbackNode(), RollbackAction::applyRevert(), NodeMetadataFormSource::getForm(), Client::getInventory(), ServerInventoryManager::getInventory(), NodeMetaRef::getmeta(), Game::handlePointingAtNode(), ModApiClient::l_get_meta(), NodeMetadataFormSource::resolveText(), and Server::sendMetadataChanged().

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

◆ getNodeTimer()

NodeTimer Map::getNodeTimer ( v3s16 p)

References NodeTimer::elapsed, emergeBlock(), getBlockNoCreateNoEx(), getNodeBlockPos(), MapBlock::getNodeTimer(), infostream, MAP_BLOCKSIZE, p(), NodeTimer::timeout, and warningstream.

Referenced by NodeTimerRef::l_get_elapsed(), NodeTimerRef::l_get_timeout(), and NodeTimerRef::l_is_started().

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

◆ getSectorNoGenerate()

MapSector * Map::getSectorNoGenerate ( v2s16 p2d)

References getSectorNoGenerateNoLock(), and p().

Referenced by ServerMap::createSector(), ServerMap::deleteBlock(), ClientMap::emergeSector(), getBlockNoCreateNoEx(), and ClientMap::updateDrawList().

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

◆ getSectorNoGenerateNoLock()

MapSector * Map::getSectorNoGenerateNoLock ( v2s16 p2d)

References m_sector_cache, m_sector_cache_p, m_sectors, and p().

Referenced by getSectorNoGenerate().

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

◆ isBlockOccluded() [1/2]

bool Map::isBlockOccluded ( MapBlock * block,
v3s16 cam_pos_nodes )
inline

References MapBlock::getPosRelative(), and isBlockOccluded().

Referenced by RemoteClient::GetNextBlocks(), isBlockOccluded(), and ClientMap::isMeshOccluded().

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

◆ isBlockOccluded() [2/2]

bool Map::isBlockOccluded ( v3s16 pos_relative,
v3s16 cam_pos_nodes,
bool simple_check = false )

References BS, determineAdditionalOcclusionCheck(), dir(), MapBlock::getBox(), isOccluded(), MAP_BLOCKSIZE, and myrand_range().

+ Here is the call graph for this function:

◆ isOccluded()

bool Map::isOccluded ( v3s16 pos_camera,
v3s16 pos_target,
float step,
float stepfac,
float start_offset,
float end_offset,
u32 needed_count )
protected

References BS, floatToInt(), NodeDefManager::getLightingFlags(), getNode(), intToFloat(), ContentLightingFlags::light_propagates, and m_nodedef.

Referenced by isBlockOccluded().

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

◆ isValidPosition()

bool Map::isValidPosition ( v3s16 p)

References getBlockNoCreateNoEx(), getNodeBlockPos(), and p().

Referenced by Client::handleCommand_NodemetaChanged().

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

◆ maySaveBlocks()

virtual bool Map::maySaveBlocks ( )
inlinevirtual

Reimplemented in ClientMap, and DummyMap.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ PrintInfo()

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

Reimplemented in ClientMap, and ServerMap.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ removeEventReceiver()

void Map::removeEventReceiver ( MapEventReceiver * event_receiver)

References m_event_receivers.

◆ removeNodeAndUpdate()

void Map::removeNodeAndUpdate ( v3s16 p,
std::map< v3s16, MapBlock * > & modified_blocks )

References addNodeAndUpdate(), CONTENT_AIR, and p().

Referenced by Client::removeNode(), removeNodeWithEvent(), and TEST_CASE().

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

◆ removeNodeMetadata()

void Map::removeNodeMetadata ( v3s16 p)

References getBlockNoCreateNoEx(), getNodeBlockPos(), MapBlock::m_node_metadata, MAP_BLOCKSIZE, p(), NodeMetadataList::remove(), and warningstream.

Referenced by addNodeAndUpdate(), RollbackAction::applyRevert(), and NodeMetaRef::clearMeta().

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

◆ removeNodeTimer()

void Map::removeNodeTimer ( v3s16 p)

References getBlockNoCreateNoEx(), getNodeBlockPos(), MAP_BLOCKSIZE, p(), MapBlock::removeNodeTimer(), and warningstream.

Referenced by NodeTimerRef::l_stop().

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

◆ removeNodeWithEvent()

bool Map::removeNodeWithEvent ( v3s16 p)

References dispatchEvent(), MEET_REMOVENODE, p(), removeNodeAndUpdate(), and MapEditEvent::type.

Referenced by ServerEnvironment::removeNode().

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

◆ reportMetrics()

virtual void Map::reportMetrics ( u64 save_time_us,
u32 saved_blocks,
u32 all_blocks )
inlineprotectedvirtual

Reimplemented in ClientMap, and ServerMap.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ save()

virtual void Map::save ( ModifiedState save_level)
inlinevirtual

Reimplemented in ServerMap.

References FATAL_ERROR.

Referenced by Server::AsyncRunStep().

+ Here is the caller graph for this function:

◆ saveBlock()

virtual bool Map::saveBlock ( MapBlock * block)
inlinevirtual

Reimplemented in ServerMap.

Referenced by timerUpdate().

+ Here is the caller graph for this function:

◆ setNode()

void Map::setNode ( v3s16 p,
MapNode n )

References getBlockNoCreate(), getNodeBlockPos(), m_gamedef, MAP_BLOCKSIZE, IGameDef::ndef(), p(), and set_node_in_block().

Referenced by TestMap::testForEachNodeInArea(), ServerMap::transformLiquids(), and voxalgo::update_lighting_nodes().

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

◆ setNodeMetadata()

bool Map::setNodeMetadata ( v3s16 p,
NodeMetadata * meta )

Sets metadata for a node.

This method sets the metadata for a given node. On success, it returns true and the object pointed to by meta is then managed by the system and should not be deleted by the caller.

In case of failure, the method returns false and the caller is still responsible for deleting the object!

Parameters
pnode coordinates
metapointer to NodeMetadata object
Returns
true on success, false on failure

References emergeBlock(), getBlockNoCreateNoEx(), getNodeBlockPos(), infostream, MapBlock::m_node_metadata, MAP_BLOCKSIZE, p(), NodeMetadataList::set(), and warningstream.

Referenced by RollbackAction::applyRevert(), NodeMetaRef::getmeta(), and Client::handleCommand_NodemetaChanged().

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

◆ setNodeTimer()

void Map::setNodeTimer ( const NodeTimer & t)

References NodeTimer::elapsed, emergeBlock(), getBlockNoCreateNoEx(), getNodeBlockPos(), infostream, MAP_BLOCKSIZE, p(), NodeTimer::position, MapBlock::setNodeTimer(), NodeTimer::timeout, and warningstream.

Referenced by NodeTimerRef::l_set(), and NodeTimerRef::l_start().

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

◆ timerUpdate()

void Map::timerUpdate ( float dtime,
float unload_timeout,
s32 max_loaded_blocks,
std::vector< v3s16 > * unloaded_blocks = NULL )

References Profiler::add(), beginSave(), TimeOrderedMapBlock::block, MapSector::deleteBlock(), deleteSectors(), endSave(), MapSector::getBlocks(), MapBlock::getModified(), MapBlock::getModifiedReasonString(), MapBlock::getPos(), porting::getTimeUs(), infostream, m_sectors, maySaveBlocks(), MOD_STATE_CLEAN, p(), Profiler::print(), PrintInfo(), MapBlock::refGet(), reportMetrics(), saveBlock(), and TimeOrderedMapBlock::sect.

Referenced by Server::AsyncRunStep(), Client::step(), TestSAO::testNotSaved(), TestSAO::testStaticToFalse(), and unloadUnreferencedBlocks().

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

◆ unloadUnreferencedBlocks()

void Map::unloadUnreferencedBlocks ( std::vector< v3s16 > * unloaded_blocks = NULL)

References timerUpdate().

Referenced by ServerEnvironment::clearObjects().

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

Member Data Documentation

◆ m_event_receivers

std::set<MapEventReceiver*> Map::m_event_receivers
protected

◆ m_gamedef

◆ m_nodedef

◆ m_sector_cache

MapSector* Map::m_sector_cache = nullptr
protected

◆ m_sector_cache_p

v2s16 Map::m_sector_cache_p
protected

◆ m_sectors


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