#include <mapblock.h>
Public Member Functions | |
MapBlock (v3s16 pos, IGameDef *gamedef) | |
~MapBlock () | |
bool | isOrphan () const |
void | makeOrphan () |
void | reallocate () |
MapNode * | getData () |
void | raiseModified (u32 mod, u32 reason=MOD_REASON_UNKNOWN) |
u32 | getModified () |
u32 | getModifiedReason () |
std::string | getModifiedReasonString () |
void | resetModified () |
bool | getIsUnderground () |
void | setIsUnderground (bool a_is_underground) |
void | setLightingComplete (u16 newflags) |
u16 | getLightingComplete () |
void | setLightingComplete (LightBank bank, u8 direction, bool is_complete) |
bool | isLightingComplete (LightBank bank, u8 direction) |
bool | isGenerated () |
void | setGenerated (bool b) |
v3s16 | getPos () |
v3s16 | getPosRelative () |
core::aabbox3d< s16 > | getBox () |
bool | isValidPosition (s16 x, s16 y, s16 z) |
bool | isValidPosition (v3s16 p) |
MapNode | getNode (s16 x, s16 y, s16 z, bool *valid_position) |
MapNode | getNode (v3s16 p, bool *valid_position) |
MapNode | getNodeNoEx (v3s16 p) |
void | setNode (s16 x, s16 y, s16 z, MapNode n) |
void | setNode (v3s16 p, MapNode n) |
MapNode | getNodeNoCheck (s16 x, s16 y, s16 z) |
MapNode | getNodeNoCheck (v3s16 p) |
void | setNodeNoCheck (s16 x, s16 y, s16 z, MapNode n) |
void | setNodeNoCheck (v3s16 p, MapNode n) |
void | copyTo (VoxelManipulator &dst) |
void | copyFrom (VoxelManipulator &dst) |
void | actuallyUpdateIsAir () |
void | expireIsAirCache () |
bool | isAir () |
bool | onObjectsActivation () |
bool | saveStaticObject (u16 id, const StaticObject &obj, u32 reason) |
void | step (float dtime, const std::function< bool(v3s16, MapNode, f32)> &on_timer_cb) |
void | setTimestamp (u32 time) |
void | setTimestampNoChangedFlag (u32 time) |
u32 | getTimestamp () |
u32 | getDiskTimestamp () |
void | resetUsageTimer () |
void | incrementUsageTimer (float dtime) |
float | getUsageTimer () |
void | refGrab () |
void | refDrop () |
short | refGet () |
NodeTimer | getNodeTimer (v3s16 p) |
void | removeNodeTimer (v3s16 p) |
void | setNodeTimer (const NodeTimer &t) |
void | clearNodeTimers () |
void | serialize (std::ostream &result, u8 version, bool disk, int compression_level) |
Serialization. | |
void | deSerialize (std::istream &is, u8 version, bool disk) |
void | serializeNetworkSpecific (std::ostream &os) |
void | deSerializeNetworkSpecific (std::istream &is) |
bool | storeActiveObject (u16 id) |
u32 | clearObjects () |
Static Public Member Functions | |
static core::aabbox3d< s16 > | getBox (const v3s16 &pos_relative) |
Public Attributes | |
MapBlockMesh * | mesh = nullptr |
u8 | solid_sides = 0 |
bool | do_not_cache_contents = false |
std::vector< content_t > | contents |
NodeMetadataList | m_node_metadata |
StaticObjectList | m_static_objects |
Static Public Attributes | |
static const u32 | ystride = MAP_BLOCKSIZE |
static const u32 | zstride = MAP_BLOCKSIZE * MAP_BLOCKSIZE |
static const u32 | nodecount = MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE |
Private Member Functions | |
void | deSerialize_pre22 (std::istream &is, u8 version, bool disk) |
Private Attributes | |
bool | m_orphan = false |
v3s16 | m_pos |
v3s16 | m_pos_relative |
short | m_refcount = 0 |
MapNode *const | data |
IGameDef * | m_gamedef |
float | m_usage_timer = 0 |
bool | m_is_air = false |
bool | m_is_air_expired = true |
u16 | m_modified = MOD_STATE_CLEAN |
u32 | m_modified_reason = 0 |
u32 | m_timestamp = BLOCK_TIMESTAMP_UNDEFINED |
u32 | m_disk_timestamp = BLOCK_TIMESTAMP_UNDEFINED |
u16 | m_lighting_complete = 0xFFFF |
bool | m_generated = false |
bool | is_underground = false |
NodeTimerList | m_node_timers |
MapBlock::~MapBlock | ( | ) |
References data, mesh, nodecount, and porting::TrackFreedMemory().
void MapBlock::actuallyUpdateIsAir | ( | ) |
References CONTENT_AIR, data, MapNode::getContent(), m_is_air, m_is_air_expired, and nodecount.
Referenced by isAir().
|
inline |
u32 MapBlock::clearObjects | ( | ) |
References StaticObjectList::clear(), m_static_objects, MOD_REASON_CLEAR_ALL_OBJECTS, MOD_STATE_WRITE_NEEDED, raiseModified(), and StaticObjectList::size().
Referenced by ServerEnvironment::clearObjects().
void MapBlock::copyFrom | ( | VoxelManipulator & | dst | ) |
References VoxelManipulator::copyTo(), data, getPosRelative(), and MAP_BLOCKSIZE.
Referenced by MMVManip::blitBackAll().
void MapBlock::copyTo | ( | VoxelManipulator & | dst | ) |
References VoxelManipulator::copyFrom(), data, getPosRelative(), and MAP_BLOCKSIZE.
Referenced by MMVManip::initialEmerge().
void MapBlock::deSerialize | ( | std::istream & | is, |
u8 | version, | ||
bool | disk ) |
References content_nodemeta_deserialize_legacy(), correctBlockNodeIds(), data, decompress(), NameIdMapping::deSerialize(), NodeMetadataList::deSerialize(), NodeTimerList::deSerialize(), StaticObjectList::deSerialize(), deSerialize_pre22(), MapNode::deSerializeBulk(), NameIdMapping::getId(), getPos(), IGameDef::idef(), is_underground, m_disk_timestamp, m_gamedef, m_generated, m_is_air, m_is_air_expired, m_lighting_complete, m_node_metadata, m_node_timers, m_static_objects, m_timestamp, nodecount, readU16(), readU32(), readU8(), ser_ver_supported(), setTimestampNoChangedFlag(), NameIdMapping::size(), TRACESTREAM, warningstream, and BaseException::what().
Referenced by ServerMap::deSerializeBlock(), Client::handleCommand_BlockData(), TestMapBlock::testLoad20(), TestMapBlock::testLoad29(), TestMapBlock::testLoadNonStd(), and TestMapBlock::testSaveLoad().
|
private |
References BLOCK_TIMESTAMP_UNDEFINED, content_mapnode_get_name_id_mapping(), content_nodemeta_deserialize_legacy(), correctBlockNodeIds(), data, decompress(), decompressZlib(), MapNode::deSerialize(), NameIdMapping::deSerialize(), StaticObjectList::deSerialize(), deSerializeString16(), FUNCTION_NAME, NodeDefManager::get(), MapNode::getContent(), NameIdMapping::getId(), NodeDefManager::getId(), MapNode::getParam1(), MapNode::getParam2(), IGameDef::idef(), is_underground, ContentFeatures::legacy_facedir_simple, ContentFeatures::legacy_wallmounted, m_disk_timestamp, m_gamedef, m_generated, m_is_air, m_is_air_expired, m_lighting_complete, m_node_metadata, m_node_timers, m_static_objects, m_timestamp, IGameDef::ndef(), nodecount, readU16(), readU32(), MapNode::serializedLength(), MapNode::setContent(), MapNode::setParam1(), MapNode::setParam2(), setTimestampNoChangedFlag(), NameIdMapping::size(), and warningstream.
Referenced by deSerialize().
void MapBlock::deSerializeNetworkSpecific | ( | std::istream & | is | ) |
References readU8(), warningstream, and BaseException::what().
Referenced by Client::handleCommand_BlockData().
void MapBlock::expireIsAirCache | ( | ) |
References m_is_air_expired.
Referenced by Map::addNodeAndUpdate(), MMVManip::blitBackAll(), and ServerMap::finishBlockMake().
|
inline |
References getBox(), and getPosRelative().
Referenced by getBox(), and Map::isBlockOccluded().
|
inlinestatic |
References MAP_BLOCKSIZE.
|
inline |
References data.
Referenced by MeshUpdateQueue::fillDataFromMapBlocks(), and TestMapBlock::testSave29().
|
inline |
References m_disk_timestamp.
Referenced by ServerEnvironment::step().
|
inline |
References is_underground.
Referenced by analyze_block(), voxalgo::is_sunlight_above(), and voxalgo::is_sunlight_above_block().
|
inline |
References m_lighting_complete.
Referenced by analyze_block().
|
inline |
References m_modified.
Referenced by analyze_block(), and Map::timerUpdate().
|
inline |
References m_modified_reason.
std::string MapBlock::getModifiedReasonString | ( | ) |
References ARRLEN, m_modified_reason, modified_reason_strings, and MYMIN.
Referenced by Map::timerUpdate().
|
inline |
References CONTENT_IGNORE, data, isValidPosition(), ystride, and zstride.
Referenced by getNode(), and getNodeNoEx().
|
inline |
References data, ystride, and zstride.
Referenced by Map::addNodeAndUpdate(), ABMHandler::apply(), LBMManager::applyLBMs(), voxalgo::blit_back_with_light(), voxalgo::fill_with_sunlight(), voxalgo::finish_bulk_light_update(), Map::forEachNodeInArea(), Map::getNode(), getNodeNoCheck(), voxalgo::is_sunlight_above(), voxalgo::is_sunlight_above_block(), ReflowScan::isLiquidFlowableTo(), voxalgo::propagate_block_sunlight(), voxalgo::repair_block_light(), ReflowScan::scanColumn(), set_node_in_block(), voxalgo::spread_light(), voxalgo::unspread_light(), voxalgo::update_block_border_lighting(), and voxalgo::update_lighting_nodes().
References getNode(), and p().
Referenced by analyze_block(), and step().
References NodeTimerList::get(), m_node_timers, and p().
Referenced by Map::getNodeTimer().
|
inline |
References m_pos.
Referenced by ServerEnvironment::activateObjects(), analyze_block(), ABMHandler::countObjects(), deSerialize(), MapSector::detachBlock(), ClientMap::isMeshOccluded(), onObjectsActivation(), voxalgo::repair_block_light(), ServerMap::saveBlock(), saveStaticObject(), ReflowScan::scan(), Server::SendBlockNoLock(), set_node_in_block(), Map::timerUpdate(), voxalgo::update_block_border_lighting(), ClientMap::updateDrawList(), ClientMap::updateDrawListShadow(), and ClientMap::updateTransparentMeshBuffers().
|
inline |
References m_pos_relative.
Referenced by ABMHandler::apply(), voxalgo::blit_back_with_light(), copyFrom(), copyTo(), getBox(), Map::isBlockOccluded(), ClientMap::isMeshOccluded(), ClientMap::renderMap(), ReflowScan::scan(), step(), ClientMap::touchMapBlocks(), ScriptApiEnv::triggerLBM(), voxalgo::update_block_border_lighting(), ClientMap::updateDrawList(), ClientMap::updateDrawListShadow(), and ClientMap::updateTransparentMeshBuffers().
|
inline |
References m_timestamp.
Referenced by ServerEnvironment::activateBlock(), serialize(), and ServerEnvironment::step().
|
inline |
References m_usage_timer.
Referenced by TimeOrderedMapBlock::operator<().
|
inline |
References m_usage_timer.
|
inline |
References actuallyUpdateIsAir(), m_is_air, and m_is_air_expired.
Referenced by RemoteClient::GetNextBlocks(), and serialize().
|
inline |
References m_generated.
Referenced by analyze_block(), MMVManip::blitBackAll(), RemoteClient::GetNextBlocks(), voxalgo::is_sunlight_above_block(), and ServerMap::repairBlockLight().
|
inline |
References LIGHTBANK_NIGHT, and m_lighting_complete.
Referenced by voxalgo::update_block_border_lighting().
|
inline |
References m_orphan.
Referenced by ServerEnvironment::activateBlock(), ServerEnvironment::activateObjects(), ABMHandler::apply(), and LBMManager::applyLBMs().
|
inline |
References MAP_BLOCKSIZE.
Referenced by ABMHandler::apply(), getNode(), isValidPosition(), and setNode().
|
inline |
|
inline |
References m_orphan.
Referenced by MapSector::detachBlock().
bool MapBlock::onObjectsActivation | ( | ) |
References StaticObjectList::clearStored(), errorstream, g_settings, StaticObjectList::getAllStored(), getPos(), StaticObjectList::getStoredSize(), Settings::getU16(), m_static_objects, MOD_REASON_TOO_MANY_OBJECTS, MOD_STATE_WRITE_NEEDED, raiseModified(), and verbosestream.
Referenced by ServerEnvironment::activateObjects().
|
inline |
References contents, m_disk_timestamp, m_modified, m_modified_reason, m_timestamp, MOD_STATE_WRITE_AT_UNLOAD, and MOD_STATE_WRITE_NEEDED.
Referenced by ServerEnvironment::addActiveObjectRaw(), MMVManip::blitBackAll(), clearObjects(), ServerEnvironment::deleteStaticFromBlock(), ServerMap::finishBlockMake(), onObjectsActivation(), reallocate(), saveStaticObject(), setGenerated(), setIsUnderground(), setLightingComplete(), setNode(), setNodeNoCheck(), setTimestamp(), ServerEnvironment::step(), and storeActiveObject().
|
inline |
References CONTENT_IGNORE, data, MOD_REASON_REALLOCATE, MOD_STATE_WRITE_NEEDED, nodecount, and raiseModified().
Referenced by MapBlock().
|
inline |
References m_refcount.
Referenced by ServerEnvironment::clearObjects(), Client::step(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().
|
inline |
References m_refcount.
Referenced by Map::timerUpdate().
|
inline |
References m_refcount.
Referenced by MeshUpdateQueue::addBlock(), ServerEnvironment::clearObjects(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().
|
inline |
References m_node_timers, p(), and NodeTimerList::remove().
Referenced by Map::removeNodeTimer().
|
inline |
References m_modified, m_modified_reason, and MOD_STATE_CLEAN.
Referenced by ServerMap::loadBlock(), and ServerMap::saveBlock().
|
inline |
References m_usage_timer.
Referenced by ServerEnvironment::activateBlock(), RemoteClient::GetNextBlocks(), ServerEnvironment::step(), ClientMap::touchMapBlocks(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().
bool MapBlock::saveStaticObject | ( | u16 | id, |
const StaticObject & | obj, | ||
u32 | reason ) |
References g_settings, getPos(), StaticObjectList::getStoredSize(), Settings::getU16(), StaticObjectList::insert(), m_static_objects, MOD_REASON_UNKNOWN, MOD_STATE_WRITE_NEEDED, raiseModified(), and warningstream.
Referenced by ServerEnvironment::saveStaticToBlock().
void MapBlock::serialize | ( | std::ostream & | result, |
u8 | version, | ||
bool | disk, | ||
int | compression_level ) |
Serialization.
References compress(), data, FATAL_ERROR_IF, getBlockNodeIdMapping(), Buffer< T >::getSize(), getTimestamp(), is_underground, isAir(), m_gamedef, m_generated, m_lighting_complete, m_node_metadata, m_node_timers, m_static_objects, IGameDef::ndef(), nodecount, SER_FMT_VER_LOWEST_WRITE, ser_ver_supported(), NameIdMapping::serialize(), NodeMetadataList::serialize(), NodeTimerList::serialize(), StaticObjectList::serialize(), MapNode::serializeBulk(), writeU16(), writeU32(), and writeU8().
Referenced by recompress_map_database(), ServerMap::saveBlock(), and Server::SendBlockNoLock().
void MapBlock::serializeNetworkSpecific | ( | std::ostream & | os | ) |
References writeU8().
Referenced by Server::SendBlockNoLock().
|
inline |
References m_generated, MOD_REASON_SET_GENERATED, MOD_STATE_WRITE_NEEDED, and raiseModified().
Referenced by ServerMap::finishBlockMake().
|
inline |
References is_underground, MOD_REASON_SET_IS_UNDERGROUND, MOD_STATE_WRITE_NEEDED, and raiseModified().
Referenced by ServerMap::initBlockMake().
|
inline |
References LIGHTBANK_NIGHT, m_lighting_complete, and setLightingComplete().
|
inline |
References m_lighting_complete, MOD_REASON_SET_LIGHTING_COMPLETE, MOD_STATE_WRITE_AT_UNLOAD, and raiseModified().
Referenced by setLightingComplete(), voxalgo::spread_light(), voxalgo::unspread_light(), and voxalgo::update_block_border_lighting().
|
inline |
References data, isValidPosition(), MOD_REASON_SET_NODE, MOD_STATE_WRITE_NEEDED, raiseModified(), ystride, and zstride.
Referenced by setNode().
|
inline |
References data, MOD_REASON_SET_NODE, MOD_STATE_WRITE_NEEDED, raiseModified(), ystride, and zstride.
Referenced by voxalgo::fill_with_sunlight(), voxalgo::propagate_block_sunlight(), set_node_in_block(), setNodeNoCheck(), voxalgo::spread_light(), voxalgo::unspread_light(), voxalgo::update_block_border_lighting(), and voxalgo::update_lighting_nodes().
|
inline |
References m_node_timers, and NodeTimerList::set().
Referenced by Map::setNodeTimer(), and step().
|
inline |
References m_timestamp, MOD_REASON_SET_TIMESTAMP, MOD_STATE_WRITE_AT_UNLOAD, and raiseModified().
Referenced by ServerEnvironment::step().
|
inline |
References m_timestamp.
Referenced by ServerEnvironment::activateBlock(), deSerialize(), deSerialize_pre22(), and ServerEnvironment::step().
References getNodeNoEx(), getPosRelative(), m_node_timers, p(), setNodeTimer(), and NodeTimerList::step().
Referenced by ServerEnvironment::activateBlock(), and ServerEnvironment::step().
bool MapBlock::storeActiveObject | ( | u16 | id | ) |
References m_static_objects, MOD_REASON_REMOVE_OBJECTS_DEACTIVATE, MOD_STATE_WRITE_NEEDED, raiseModified(), and StaticObjectList::storeActiveObject().
std::vector<content_t> MapBlock::contents |
Referenced by ABMHandler::apply(), and raiseModified().
|
private |
Referenced by ~MapBlock(), actuallyUpdateIsAir(), copyFrom(), copyTo(), deSerialize(), deSerialize_pre22(), getData(), getNode(), getNodeNoCheck(), reallocate(), serialize(), setNode(), and setNodeNoCheck().
bool MapBlock::do_not_cache_contents = false |
Referenced by ABMHandler::apply().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), getIsUnderground(), serialize(), and setIsUnderground().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), getDiskTimestamp(), and raiseModified().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), and serialize().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), isGenerated(), serialize(), and setGenerated().
|
private |
Referenced by actuallyUpdateIsAir(), deSerialize(), deSerialize_pre22(), and isAir().
|
private |
Referenced by actuallyUpdateIsAir(), deSerialize(), deSerialize_pre22(), expireIsAirCache(), and isAir().
|
private |
Each bit indicates if light spreading was finished in a direction. (Because the neighbor could also be unloaded.) Bits (most significant first): nothing, nothing, nothing, nothing, night X-, night Y-, night Z-, night Z+, night Y+, night X+, day X-, day Y-, day Z-, day Z+, day Y+, day X+.
Referenced by deSerialize(), deSerialize_pre22(), getLightingComplete(), isLightingComplete(), serialize(), setLightingComplete(), and setLightingComplete().
|
private |
Referenced by MapBlock(), getModified(), raiseModified(), and resetModified().
|
private |
Referenced by getModifiedReason(), getModifiedReasonString(), raiseModified(), and resetModified().
NodeMetadataList MapBlock::m_node_metadata |
|
private |
Referenced by clearNodeTimers(), deSerialize(), deSerialize_pre22(), getNodeTimer(), removeNodeTimer(), serialize(), setNodeTimer(), and step().
|
private |
Referenced by isOrphan(), and makeOrphan().
|
private |
Referenced by getPosRelative().
StaticObjectList MapBlock::m_static_objects |
Referenced by ServerEnvironment::activateBlock(), ServerEnvironment::activateObjects(), ServerEnvironment::addActiveObjectRaw(), assert_active_in_block(), clearObjects(), ABMHandler::countObjects(), ServerEnvironment::deleteStaticFromBlock(), deSerialize(), deSerialize_pre22(), onObjectsActivation(), saveStaticObject(), serialize(), ServerEnvironment::setStaticForActiveObjectsInBlock(), and storeActiveObject().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), getTimestamp(), raiseModified(), setTimestamp(), and setTimestampNoChangedFlag().
|
private |
Referenced by getUsageTimer(), incrementUsageTimer(), and resetUsageTimer().
MapBlockMesh* MapBlock::mesh = nullptr |
|
static |
u8 MapBlock::solid_sides = 0 |
Referenced by Client::step(), and ClientMap::updateDrawList().
|
static |
Referenced by getNode(), getNodeNoCheck(), setNode(), and setNodeNoCheck().
|
static |
Referenced by getNode(), getNodeNoCheck(), setNode(), and setNodeNoCheck().