#include <mapblock.h>
Public Member Functions | |
MapBlock (Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy=false) | |
~MapBlock () | |
Map * | getParent () |
void | reallocate () |
MapNode * | getData () |
void | raiseModified (u32 mod, u32 reason=MOD_REASON_UNKNOWN) |
u32 | getModified () |
u32 | getModifiedReason () |
std::string | getModifiedReasonString () |
void | resetModified () |
bool | isDummy () |
void | unDummify () |
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, bool *valid_position) |
MapNode | getNodeNoCheck (v3s16 p, bool *valid_position) |
const MapNode & | getNodeUnsafe (s16 x, s16 y, s16 z) |
const MapNode & | getNodeUnsafe (v3s16 &p) |
void | setNodeNoCheck (s16 x, s16 y, s16 z, MapNode &n) |
void | setNodeNoCheck (v3s16 p, MapNode &n) |
bool | isValidPositionParent (v3s16 p) |
MapNode | getNodeParent (v3s16 p, bool *is_valid_position=NULL) |
void | copyTo (VoxelManipulator &dst) |
void | copyFrom (VoxelManipulator &dst) |
void | actuallyUpdateDayNightDiff () |
void | expireDayNightDiff () |
bool | getDayNightDiff () |
s16 | getGroundLevel (v2s16 p2d) |
void | setTimestamp (u32 time) |
void | setTimestampNoChangedFlag (u32 time) |
u32 | getTimestamp () |
u32 | getDiskTimestamp () |
void | resetUsageTimer () |
void | incrementUsageTimer (float dtime) |
float | getUsageTimer () |
void | refGrab () |
void | refDrop () |
int | refGet () |
NodeTimer | getNodeTimer (const v3s16 &p) |
void | removeNodeTimer (const v3s16 &p) |
void | setNodeTimer (const NodeTimer &t) |
void | clearNodeTimers () |
void | serialize (std::ostream &os, u8 version, bool disk, int compression_level) |
Serialization. More... | |
void | deSerialize (std::istream &is, u8 version, bool disk) |
void | serializeNetworkSpecific (std::ostream &os) |
void | deSerializeNetworkSpecific (std::istream &is) |
Public Attributes | |
MapBlockMesh * | mesh = nullptr |
NodeMetadataList | m_node_metadata |
NodeTimerList | m_node_timers |
StaticObjectList | m_static_objects |
std::unordered_set< content_t > | contents |
bool | contents_cached = false |
bool | do_not_cache_contents = false |
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) |
MapNode & | getNodeRef (s16 x, s16 y, s16 z) |
MapNode & | getNodeRef (v3s16 &p) |
Private Attributes | |
Map * | m_parent |
v3s16 | m_pos |
v3s16 | m_pos_relative |
IGameDef * | m_gamedef |
MapNode * | data = nullptr |
u32 | m_modified = MOD_STATE_WRITE_NEEDED |
u32 | m_modified_reason = MOD_REASON_INITIAL |
bool | is_underground = false |
u16 | m_lighting_complete = 0xFFFF |
bool | m_day_night_differs = false |
bool | m_day_night_differs_expired = true |
bool | m_generated = false |
u32 | m_timestamp = BLOCK_TIMESTAMP_UNDEFINED |
u32 | m_disk_timestamp = BLOCK_TIMESTAMP_UNDEFINED |
float | m_usage_timer = 0 |
int | m_refcount = 0 |
void MapBlock::actuallyUpdateDayNightDiff | ( | ) |
References CONTENT_AIR, CONTENT_IGNORE, data, MapNode::getContent(), MapNode::isLightDayNightEq(), m_day_night_differs, m_day_night_differs_expired, m_gamedef, IGameDef::ndef(), and nodecount.
Referenced by getDayNightDiff().
|
inline |
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, decompressZlib(), NameIdMapping::deSerialize(), StaticObjectList::deSerialize(), NodeMetadataList::deSerialize(), NodeTimerList::deSerialize(), deSerialize_pre22(), MapNode::deSerializeBulk(), getPos(), IGameDef::idef(), is_underground, m_day_night_differs, m_day_night_differs_expired, m_disk_timestamp, m_gamedef, m_generated, m_lighting_complete, m_node_metadata, m_node_timers, m_static_objects, m_timestamp, nodecount, PP, readU16(), readU32(), readU8(), ser_ver_supported(), setTimestampNoChangedFlag(), TRACESTREAM, warningstream, and BaseException::what().
Referenced by Client::handleCommand_BlockData(), and ServerMap::loadBlock().
|
private |
References BLOCK_TIMESTAMP_UNDEFINED, content_mapnode_get_name_id_mapping(), content_nodemeta_deserialize_legacy(), correctBlockNodeIds(), data, decompress(), decompressZlib(), NameIdMapping::deSerialize(), StaticObjectList::deSerialize(), MapNode::deSerialize(), deSerializeString16(), FUNCTION_NAME, NodeDefManager::get(), MapNode::getContent(), NodeDefManager::getId(), MapNode::getParam1(), MapNode::getParam2(), IGameDef::idef(), is_underground, ContentFeatures::legacy_facedir_simple, ContentFeatures::legacy_wallmounted, m_day_night_differs, m_disk_timestamp, m_gamedef, m_generated, 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(), and warningstream.
Referenced by deSerialize().
void MapBlock::deSerializeNetworkSpecific | ( | std::istream & | is | ) |
References readU8(), warningstream, and BaseException::what().
Referenced by Client::handleCommand_BlockData().
void MapBlock::expireDayNightDiff | ( | ) |
References data, m_day_night_differs, and m_day_night_differs_expired.
Referenced by ServerMap::finishBlockMake().
|
inline |
References getPosRelative(), and MAP_BLOCKSIZE.
Referenced by Map::isBlockOccluded().
|
inline |
References data.
Referenced by MeshUpdateQueue::cacheBlock(), and MeshMakeData::fill().
|
inline |
References actuallyUpdateDayNightDiff(), m_day_night_differs, and m_day_night_differs_expired.
Referenced by RemoteClient::GetNextBlocks(), and serialize().
|
inline |
References m_disk_timestamp.
Referenced by ServerEnvironment::step().
s16 MapBlock::getGroundLevel | ( | v2s16 | p2d | ) |
References NodeDefManager::get(), getNodeRef(), isDummy(), m_gamedef, MAP_BLOCKSIZE, IGameDef::ndef(), and ContentFeatures::walkable.
|
inline |
References is_underground.
Referenced by analyze_block(), RemoteClient::GetNextBlocks(), voxalgo::is_sunlight_above(), voxalgo::is_sunlight_above_block(), and Map::isNodeUnderground().
|
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 CONTENT_IGNORE, data, ystride, and zstride.
Referenced by voxalgo::blit_back_with_light(), voxalgo::fill_with_sunlight(), voxalgo::finish_bulk_light_update(), Map::getNode(), getNodeNoCheck(), voxalgo::is_sunlight_above(), voxalgo::is_sunlight_above_block(), ReflowScan::isLiquidFlowableTo(), voxalgo::propagate_block_sunlight(), voxalgo::repair_block_light(), ReflowScan::scanColumn(), Map::setNode(), voxalgo::spread_light(), voxalgo::unspread_light(), voxalgo::update_block_border_lighting(), and voxalgo::update_lighting_nodes().
References getNode(), and p().
Referenced by ServerEnvironment::activateBlock(), analyze_block(), LBMManager::applyLBMs(), and ServerEnvironment::step().
References CONTENT_IGNORE, data, Map::getNode(), getPosRelative(), isValidPosition(), m_parent, p(), ystride, and zstride.
|
inlineprivate |
References data, isValidPosition(), ystride, and zstride.
Referenced by getGroundLevel(), and getNodeRef().
|
inline |
References data, ystride, and zstride.
Referenced by ABMHandler::apply(), and getNodeUnsafe().
|
inline |
References m_parent.
Referenced by MeshMakeData::fill().
|
inline |
References m_pos.
Referenced by ServerEnvironment::activateObjects(), analyze_block(), ABMHandler::countObjects(), MapSector::deleteBlock(), deSerialize(), MeshMakeData::fill(), MapSector::insertBlock(), ClientMap::renderMap(), voxalgo::repair_block_light(), ServerMap::saveBlock(), ReflowScan::scan(), Server::SendBlockNoLock(), Map::timerUpdate(), and voxalgo::update_block_border_lighting().
|
inline |
References m_pos_relative.
Referenced by ServerEnvironment::activateBlock(), ABMHandler::apply(), LBMManager::applyLBMs(), voxalgo::blit_back_with_light(), copyFrom(), copyTo(), getBox(), getNodeParent(), Map::isBlockOccluded(), isValidPositionParent(), ReflowScan::scan(), ServerEnvironment::step(), and voxalgo::update_block_border_lighting().
|
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 data.
Referenced by analyze_block(), ABMHandler::apply(), voxalgo::blit_back_with_light(), ServerMap::createBlock(), ServerMap::emergeBlock(), voxalgo::fill_with_sunlight(), voxalgo::finish_bulk_light_update(), EmergeThread::getBlockOrStartGen(), getGroundLevel(), RemoteClient::GetNextBlocks(), MMVManip::initialEmerge(), voxalgo::is_sunlight_above_block(), voxalgo::propagate_block_sunlight(), voxalgo::repair_block_light(), ServerMap::saveBlock(), unDummify(), and voxalgo::update_lighting_nodes().
|
inline |
References m_generated.
Referenced by analyze_block(), MMVManip::blitBackAll(), EmergeThread::getBlockOrStartGen(), 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 data, and MAP_BLOCKSIZE.
Referenced by ABMHandler::apply(), getNode(), getNodeParent(), getNodeRef(), isValidPosition(), isValidPositionParent(), and setNode().
|
inline |
bool MapBlock::isValidPositionParent | ( | v3s16 | p | ) |
References getPosRelative(), isValidPosition(), Map::isValidPosition(), m_parent, and p().
|
inline |
References contents_cached, m_disk_timestamp, m_modified, m_modified_reason, m_timestamp, MOD_STATE_WRITE_AT_UNLOAD, and MOD_STATE_WRITE_NEEDED.
Referenced by ServerEnvironment::activateObjects(), ServerEnvironment::addActiveObjectRaw(), MMVManip::blitBackAll(), ServerEnvironment::clearObjects(), ServerEnvironment::deleteStaticFromBlock(), ServerMap::finishBlockMake(), reallocate(), ServerEnvironment::removeRemovedObjects(), ServerEnvironment::saveStaticToBlock(), setGenerated(), setIsUnderground(), setLightingComplete(), setNode(), setNodeNoCheck(), setTimestamp(), and ServerEnvironment::step().
|
inline |
References CONTENT_IGNORE, data, MOD_REASON_REALLOCATE, MOD_STATE_WRITE_NEEDED, nodecount, and raiseModified().
Referenced by MapBlock(), and unDummify().
|
inline |
References m_refcount.
Referenced by ServerEnvironment::clearObjects(), and ClientMap::updateDrawList().
|
inline |
References m_refcount.
Referenced by Map::timerUpdate().
|
inline |
References m_refcount.
Referenced by ServerEnvironment::clearObjects().
|
inline |
References m_node_timers, p(), and NodeTimerList::remove().
|
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(), and ServerEnvironment::step().
void MapBlock::serialize | ( | std::ostream & | os, |
u8 | version, | ||
bool | disk, | ||
int | compression_level | ||
) |
Serialization.
References compressZlib(), data, FATAL_ERROR_IF, getBlockNodeIdMapping(), getDayNightDiff(), getTimestamp(), is_underground, 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(), StaticObjectList::serialize(), NameIdMapping::serialize(), NodeMetadataList::serialize(), NodeTimerList::serialize(), MapNode::serializeBulk(), writeU16(), writeU32(), and writeU8().
Referenced by ServerMap::saveBlock(), and Server::SendBlockNoLock().
void MapBlock::serializeNetworkSpecific | ( | std::ostream & | os | ) |
References data, and 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_NEEDED, 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_NO_CHECK, MOD_STATE_WRITE_NEEDED, raiseModified(), ystride, and zstride.
Referenced by voxalgo::fill_with_sunlight(), voxalgo::propagate_block_sunlight(), Map::setNode(), 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 ServerEnvironment::activateBlock(), and ServerEnvironment::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().
|
inline |
References isDummy(), and reallocate().
Referenced by ServerMap::createBlock().
std::unordered_set<content_t> MapBlock::contents |
Referenced by ABMHandler::apply().
bool MapBlock::contents_cached = false |
Referenced by ABMHandler::apply(), and raiseModified().
|
private |
Referenced by ~MapBlock(), actuallyUpdateDayNightDiff(), copyFrom(), copyTo(), deSerialize(), deSerialize_pre22(), expireDayNightDiff(), getData(), getNode(), getNodeNoCheck(), getNodeParent(), getNodeRef(), getNodeUnsafe(), isDummy(), isValidPosition(), reallocate(), serialize(), serializeNetworkSpecific(), 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 actuallyUpdateDayNightDiff(), deSerialize(), deSerialize_pre22(), expireDayNightDiff(), and getDayNightDiff().
|
private |
Referenced by actuallyUpdateDayNightDiff(), deSerialize(), expireDayNightDiff(), and getDayNightDiff().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), getDiskTimestamp(), and raiseModified().
|
private |
Referenced by actuallyUpdateDayNightDiff(), deSerialize(), deSerialize_pre22(), getGroundLevel(), and serialize().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), isGenerated(), serialize(), and setGenerated().
|
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(), and setLightingComplete().
|
private |
Referenced by getModified(), raiseModified(), and resetModified().
|
private |
Referenced by getModifiedReason(), getModifiedReasonString(), raiseModified(), and resetModified().
NodeMetadataList MapBlock::m_node_metadata |
NodeTimerList MapBlock::m_node_timers |
|
private |
Referenced by getNodeParent(), getParent(), and isValidPositionParent().
|
private |
Referenced by getPosRelative().
StaticObjectList MapBlock::m_static_objects |
Referenced by ServerEnvironment::activateBlock(), ServerEnvironment::activateObjects(), ServerEnvironment::addActiveObjectRaw(), ServerEnvironment::clearObjects(), ABMHandler::countObjects(), ServerEnvironment::deactivateFarObjects(), ServerEnvironment::deleteStaticFromBlock(), deSerialize(), deSerialize_pre22(), ServerEnvironment::removeRemovedObjects(), ServerEnvironment::saveStaticToBlock(), serialize(), and ServerEnvironment::setStaticForActiveObjectsInBlock().
|
private |
Referenced by deSerialize(), deSerialize_pre22(), getTimestamp(), raiseModified(), setTimestamp(), and setTimestampNoChangedFlag().
|
private |
Referenced by getUsageTimer(), incrementUsageTimer(), and resetUsageTimer().
MapBlockMesh* MapBlock::mesh = nullptr |
Referenced by ~MapBlock(), ClientMap::renderMap(), and Client::step().
|
static |
|
static |
Referenced by getNode(), getNodeNoCheck(), getNodeParent(), getNodeRef(), getNodeUnsafe(), setNode(), and setNodeNoCheck().
|
static |
Referenced by getNode(), getNodeNoCheck(), getNodeParent(), getNodeRef(), getNodeUnsafe(), setNode(), and setNodeNoCheck().