#include <map.h>
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) |
MapSector * | getSectorNoGenerateNoLock (v2s16 p2d) |
MapSector * | getSectorNoGenerate (v2s16 p2d) |
virtual MapSector * | emergeSector (v2s16 p) |
MapBlock * | getBlockNoCreate (v3s16 p) |
MapBlock * | getBlockNoCreateNoEx (v3s16 p) |
virtual MapBlock * | emergeBlock (v3s16 p, bool create_blank=true) |
const NodeDefManager * | getNodeDefManager () |
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< v3s16 > | findNodesWithMetadata (v3s16 p1, v3s16 p2) |
NodeMetadata * | getNodeMetadata (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 | |
IGameDef * | m_gamedef |
std::set< MapEventReceiver * > | m_event_receivers |
std::unordered_map< v2s16, MapSector * > | m_sectors |
MapSector * | m_sector_cache = nullptr |
v2s16 | m_sector_cache_p |
const NodeDefManager * | m_nodedef |
Map::Map | ( | IGameDef * | gamedef | ) |
|
virtual |
References m_sectors.
void Map::addEventReceiver | ( | MapEventReceiver * | event_receiver | ) |
References m_event_receivers.
Referenced by ServerEnvironment::init().
|
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().
References addNodeAndUpdate(), dispatchEvent(), MEET_ADDNODE, MEET_SWAPNODE, p(), and MapEditEvent::type.
Referenced by RollbackAction::applyRevert(), ServerEnvironment::setNode(), and ServerEnvironment::swapNode().
|
inlinevirtual |
Reimplemented in ServerMap.
Referenced by timerUpdate().
void Map::deleteSectors | ( | std::vector< v2s16 > & | list | ) |
References m_sector_cache, and m_sectors.
Referenced by timerUpdate().
|
protected |
References CLOSEST_EDGE.
Referenced by isBlockOccluded().
Map::DISABLE_CLASS_COPY | ( | Map | ) |
void Map::dispatchEvent | ( | const MapEditEvent & | event | ) |
References m_event_receivers.
Referenced by addNodeWithEvent(), RollbackAction::applyRevert(), Server::AsyncRunStep(), ModApiEnv::l_delete_area(), ModApiEnv::l_fix_light(), LuaVoxelManip::l_write_to_map(), ServerMap::loadBlock(), Schematic::placeOnMap(), removeNodeWithEvent(), NodeMetaRef::reportMetadataChange(), EmergeThread::run(), ServerInventoryManager::setInventoryModified(), and treegen::spawn_ltree().
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().
Reimplemented in ClientMap.
Referenced by Client::handleCommand_BlockData(), and Client::step().
|
inlinevirtual |
Reimplemented in ServerMap.
Referenced by timerUpdate().
References VoxelArea::contains(), emergeBlock(), NodeMetadataList::getAllKeys(), getBlockNoCreateNoEx(), getNodeBlockPos(), infostream, MapBlock::m_node_metadata, MAP_BLOCKSIZE, p(), sortBoxVerticies(), and verbosestream.
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().
References getBlockNoCreateNoEx().
Referenced by addNodeAndUpdate(), and setNode().
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().
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().
|
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().
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().
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().
References getSectorNoGenerateNoLock(), and p().
Referenced by ServerMap::createSector(), ServerMap::deleteBlock(), ClientMap::emergeSector(), getBlockNoCreateNoEx(), and ClientMap::updateDrawList().
References m_sector_cache, m_sector_cache_p, m_sectors, and p().
Referenced by getSectorNoGenerate().
References MapBlock::getPosRelative(), and isBlockOccluded().
Referenced by RemoteClient::GetNextBlocks(), isBlockOccluded(), and ClientMap::isMeshOccluded().
References BS, determineAdditionalOcclusionCheck(), dir(), MapBlock::getBox(), isOccluded(), MAP_BLOCKSIZE, and myrand_range().
|
protected |
References BS, floatToInt(), NodeDefManager::getLightingFlags(), getNode(), intToFloat(), ContentLightingFlags::light_propagates, and m_nodedef.
Referenced by isBlockOccluded().
bool Map::isValidPosition | ( | v3s16 | p | ) |
References getBlockNoCreateNoEx(), getNodeBlockPos(), and p().
Referenced by Client::handleCommand_NodemetaChanged().
|
inlinevirtual |
Reimplemented in ClientMap, and DummyMap.
Referenced by timerUpdate().
|
virtual |
Reimplemented in ClientMap, and ServerMap.
Referenced by timerUpdate().
void Map::removeEventReceiver | ( | MapEventReceiver * | event_receiver | ) |
References m_event_receivers.
References addNodeAndUpdate(), CONTENT_AIR, and p().
Referenced by Client::removeNode(), removeNodeWithEvent(), and TEST_CASE().
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().
void Map::removeNodeTimer | ( | v3s16 | p | ) |
References getBlockNoCreateNoEx(), getNodeBlockPos(), MAP_BLOCKSIZE, p(), MapBlock::removeNodeTimer(), and warningstream.
Referenced by NodeTimerRef::l_stop().
bool Map::removeNodeWithEvent | ( | v3s16 | p | ) |
References dispatchEvent(), MEET_REMOVENODE, p(), removeNodeAndUpdate(), and MapEditEvent::type.
Referenced by ServerEnvironment::removeNode().
|
inlineprotectedvirtual |
Reimplemented in ClientMap, and ServerMap.
Referenced by timerUpdate().
|
inlinevirtual |
Reimplemented in ServerMap.
References FATAL_ERROR.
Referenced by Server::AsyncRunStep().
|
inlinevirtual |
Reimplemented in ServerMap.
Referenced by timerUpdate().
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().
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!
p | node coordinates |
meta | pointer to NodeMetadata object |
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().
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().
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().
void Map::unloadUnreferencedBlocks | ( | std::vector< v3s16 > * | unloaded_blocks = NULL | ) |
References timerUpdate().
Referenced by ServerEnvironment::clearObjects().
|
protected |
Referenced by addEventReceiver(), dispatchEvent(), and removeEventReceiver().
|
protected |
Referenced by addNodeAndUpdate(), ServerMap::createSector(), ClientMap::emergeSector(), setNode(), and ServerMap::transformLiquids().
|
protected |
|
protected |
Referenced by deleteSectors(), and getSectorNoGenerateNoLock().
|
protected |
Referenced by getSectorNoGenerateNoLock().
Referenced by DummyMap::DummyMap(), ~Map(), ServerMap::createSector(), deleteSectors(), ClientMap::emergeSector(), getSectorNoGenerateNoLock(), ServerMap::listAllLoadedBlocks(), ServerMap::save(), timerUpdate(), ClientMap::touchMapBlocks(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().