Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
MapBlock Class Reference

#include <mapblock.h>

+ Collaboration diagram for MapBlock:

Public Member Functions

 MapBlock (v3s16 pos, IGameDef *gamedef)
 
 ~MapBlock ()
 
bool isOrphan () const
 
void makeOrphan ()
 
void reallocate ()
 
MapNodegetData ()
 
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

MapBlockMeshmesh = nullptr
 
u8 solid_sides = 0
 
bool do_not_cache_contents = false
 
std::vector< content_tcontents
 
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
 
IGameDefm_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
 

Constructor & Destructor Documentation

◆ MapBlock()

MapBlock::MapBlock ( v3s16 pos,
IGameDef * gamedef )

References m_modified, MOD_STATE_CLEAN, and reallocate().

+ Here is the call graph for this function:

◆ ~MapBlock()

MapBlock::~MapBlock ( )

References data, mesh, nodecount, and porting::TrackFreedMemory().

+ Here is the call graph for this function:

Member Function Documentation

◆ actuallyUpdateIsAir()

void MapBlock::actuallyUpdateIsAir ( )

References CONTENT_AIR, data, MapNode::getContent(), m_is_air, m_is_air_expired, and nodecount.

Referenced by isAir().

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

◆ clearNodeTimers()

void MapBlock::clearNodeTimers ( )
inline

References NodeTimerList::clear(), and m_node_timers.

+ Here is the call graph for this function:

◆ clearObjects()

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().

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

◆ copyFrom()

void MapBlock::copyFrom ( VoxelManipulator & dst)

References VoxelManipulator::copyTo(), data, getPosRelative(), and MAP_BLOCKSIZE.

Referenced by MMVManip::blitBackAll().

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

◆ copyTo()

void MapBlock::copyTo ( VoxelManipulator & dst)

References VoxelManipulator::copyFrom(), data, getPosRelative(), and MAP_BLOCKSIZE.

Referenced by MMVManip::initialEmerge().

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

◆ deSerialize()

◆ deSerialize_pre22()

◆ deSerializeNetworkSpecific()

void MapBlock::deSerializeNetworkSpecific ( std::istream & is)

References readU8(), warningstream, and BaseException::what().

Referenced by Client::handleCommand_BlockData().

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

◆ expireIsAirCache()

void MapBlock::expireIsAirCache ( )

References m_is_air_expired.

Referenced by Map::addNodeAndUpdate(), MMVManip::blitBackAll(), and ServerMap::finishBlockMake().

+ Here is the caller graph for this function:

◆ getBox() [1/2]

core::aabbox3d< s16 > MapBlock::getBox ( )
inline

References getBox(), and getPosRelative().

Referenced by getBox(), and Map::isBlockOccluded().

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

◆ getBox() [2/2]

static core::aabbox3d< s16 > MapBlock::getBox ( const v3s16 & pos_relative)
inlinestatic

References MAP_BLOCKSIZE.

◆ getData()

MapNode * MapBlock::getData ( )
inline

References data.

Referenced by MeshUpdateQueue::fillDataFromMapBlocks(), and TestMapBlock::testSave29().

+ Here is the caller graph for this function:

◆ getDiskTimestamp()

u32 MapBlock::getDiskTimestamp ( )
inline

References m_disk_timestamp.

Referenced by ServerEnvironment::step().

+ Here is the caller graph for this function:

◆ getIsUnderground()

bool MapBlock::getIsUnderground ( )
inline

References is_underground.

Referenced by analyze_block(), voxalgo::is_sunlight_above(), and voxalgo::is_sunlight_above_block().

+ Here is the caller graph for this function:

◆ getLightingComplete()

u16 MapBlock::getLightingComplete ( )
inline

References m_lighting_complete.

Referenced by analyze_block().

+ Here is the caller graph for this function:

◆ getModified()

u32 MapBlock::getModified ( )
inline

References m_modified.

Referenced by analyze_block(), and Map::timerUpdate().

+ Here is the caller graph for this function:

◆ getModifiedReason()

u32 MapBlock::getModifiedReason ( )
inline

References m_modified_reason.

◆ getModifiedReasonString()

std::string MapBlock::getModifiedReasonString ( )

References ARRLEN, m_modified_reason, modified_reason_strings, and MYMIN.

Referenced by Map::timerUpdate().

+ Here is the caller graph for this function:

◆ getNode() [1/2]

MapNode MapBlock::getNode ( s16 x,
s16 y,
s16 z,
bool * valid_position )
inline

References CONTENT_IGNORE, data, isValidPosition(), ystride, and zstride.

Referenced by getNode(), and getNodeNoEx().

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

◆ getNode() [2/2]

MapNode MapBlock::getNode ( v3s16 p,
bool * valid_position )
inline

References getNode(), and p().

+ Here is the call graph for this function:

◆ getNodeNoCheck() [1/2]

◆ getNodeNoCheck() [2/2]

MapNode MapBlock::getNodeNoCheck ( v3s16 p)
inline

References getNodeNoCheck(), and p().

+ Here is the call graph for this function:

◆ getNodeNoEx()

MapNode MapBlock::getNodeNoEx ( v3s16 p)
inline

References getNode(), and p().

Referenced by analyze_block(), and step().

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

◆ getNodeTimer()

NodeTimer MapBlock::getNodeTimer ( v3s16 p)
inline

References NodeTimerList::get(), m_node_timers, and p().

Referenced by Map::getNodeTimer().

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

◆ getPos()

◆ getPosRelative()

◆ getTimestamp()

u32 MapBlock::getTimestamp ( )
inline

References m_timestamp.

Referenced by ServerEnvironment::activateBlock(), serialize(), and ServerEnvironment::step().

+ Here is the caller graph for this function:

◆ getUsageTimer()

float MapBlock::getUsageTimer ( )
inline

References m_usage_timer.

Referenced by TimeOrderedMapBlock::operator<().

+ Here is the caller graph for this function:

◆ incrementUsageTimer()

void MapBlock::incrementUsageTimer ( float dtime)
inline

References m_usage_timer.

◆ isAir()

bool MapBlock::isAir ( )
inline

References actuallyUpdateIsAir(), m_is_air, and m_is_air_expired.

Referenced by RemoteClient::GetNextBlocks(), and serialize().

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

◆ isGenerated()

bool MapBlock::isGenerated ( )
inline

References m_generated.

Referenced by analyze_block(), MMVManip::blitBackAll(), RemoteClient::GetNextBlocks(), voxalgo::is_sunlight_above_block(), and ServerMap::repairBlockLight().

+ Here is the caller graph for this function:

◆ isLightingComplete()

bool MapBlock::isLightingComplete ( LightBank bank,
u8 direction )
inline

References LIGHTBANK_NIGHT, and m_lighting_complete.

Referenced by voxalgo::update_block_border_lighting().

+ Here is the caller graph for this function:

◆ isOrphan()

bool MapBlock::isOrphan ( ) const
inline

References m_orphan.

Referenced by ServerEnvironment::activateBlock(), ServerEnvironment::activateObjects(), ABMHandler::apply(), and LBMManager::applyLBMs().

+ Here is the caller graph for this function:

◆ isValidPosition() [1/2]

bool MapBlock::isValidPosition ( s16 x,
s16 y,
s16 z )
inline

References MAP_BLOCKSIZE.

Referenced by ABMHandler::apply(), getNode(), isValidPosition(), and setNode().

+ Here is the caller graph for this function:

◆ isValidPosition() [2/2]

bool MapBlock::isValidPosition ( v3s16 p)
inline

References isValidPosition(), and p().

+ Here is the call graph for this function:

◆ makeOrphan()

void MapBlock::makeOrphan ( )
inline

References m_orphan.

Referenced by MapSector::detachBlock().

+ Here is the caller graph for this function:

◆ onObjectsActivation()

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().

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

◆ raiseModified()

◆ reallocate()

void MapBlock::reallocate ( )
inline

References CONTENT_IGNORE, data, MOD_REASON_REALLOCATE, MOD_STATE_WRITE_NEEDED, nodecount, and raiseModified().

Referenced by MapBlock().

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

◆ refDrop()

void MapBlock::refDrop ( )
inline

References m_refcount.

Referenced by ServerEnvironment::clearObjects(), Client::step(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().

+ Here is the caller graph for this function:

◆ refGet()

short MapBlock::refGet ( )
inline

References m_refcount.

Referenced by Map::timerUpdate().

+ Here is the caller graph for this function:

◆ refGrab()

void MapBlock::refGrab ( )
inline

References m_refcount.

Referenced by MeshUpdateQueue::addBlock(), ServerEnvironment::clearObjects(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().

+ Here is the caller graph for this function:

◆ removeNodeTimer()

void MapBlock::removeNodeTimer ( v3s16 p)
inline

References m_node_timers, p(), and NodeTimerList::remove().

Referenced by Map::removeNodeTimer().

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

◆ resetModified()

void MapBlock::resetModified ( )
inline

References m_modified, m_modified_reason, and MOD_STATE_CLEAN.

Referenced by ServerMap::loadBlock(), and ServerMap::saveBlock().

+ Here is the caller graph for this function:

◆ resetUsageTimer()

void MapBlock::resetUsageTimer ( )
inline

References m_usage_timer.

Referenced by ServerEnvironment::activateBlock(), RemoteClient::GetNextBlocks(), ServerEnvironment::step(), ClientMap::touchMapBlocks(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow().

+ Here is the caller graph for this function:

◆ saveStaticObject()

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().

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

◆ serialize()

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().

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

◆ serializeNetworkSpecific()

void MapBlock::serializeNetworkSpecific ( std::ostream & os)

References writeU8().

Referenced by Server::SendBlockNoLock().

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

◆ setGenerated()

void MapBlock::setGenerated ( bool b)
inline

References m_generated, MOD_REASON_SET_GENERATED, MOD_STATE_WRITE_NEEDED, and raiseModified().

Referenced by ServerMap::finishBlockMake().

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

◆ setIsUnderground()

void MapBlock::setIsUnderground ( bool a_is_underground)
inline

References is_underground, MOD_REASON_SET_IS_UNDERGROUND, MOD_STATE_WRITE_NEEDED, and raiseModified().

Referenced by ServerMap::initBlockMake().

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

◆ setLightingComplete() [1/2]

void MapBlock::setLightingComplete ( LightBank bank,
u8 direction,
bool is_complete )
inline

References LIGHTBANK_NIGHT, m_lighting_complete, and setLightingComplete().

+ Here is the call graph for this function:

◆ setLightingComplete() [2/2]

void MapBlock::setLightingComplete ( u16 newflags)
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().

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

◆ setNode() [1/2]

void MapBlock::setNode ( s16 x,
s16 y,
s16 z,
MapNode n )
inline

References data, isValidPosition(), MOD_REASON_SET_NODE, MOD_STATE_WRITE_NEEDED, raiseModified(), ystride, and zstride.

Referenced by setNode().

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

◆ setNode() [2/2]

void MapBlock::setNode ( v3s16 p,
MapNode n )
inline

References p(), and setNode().

+ Here is the call graph for this function:

◆ setNodeNoCheck() [1/2]

void MapBlock::setNodeNoCheck ( s16 x,
s16 y,
s16 z,
MapNode n )
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().

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

◆ setNodeNoCheck() [2/2]

void MapBlock::setNodeNoCheck ( v3s16 p,
MapNode n )
inline

References p(), and setNodeNoCheck().

+ Here is the call graph for this function:

◆ setNodeTimer()

void MapBlock::setNodeTimer ( const NodeTimer & t)
inline

References m_node_timers, and NodeTimerList::set().

Referenced by Map::setNodeTimer(), and step().

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

◆ setTimestamp()

void MapBlock::setTimestamp ( u32 time)
inline

References m_timestamp, MOD_REASON_SET_TIMESTAMP, MOD_STATE_WRITE_AT_UNLOAD, and raiseModified().

Referenced by ServerEnvironment::step().

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

◆ setTimestampNoChangedFlag()

void MapBlock::setTimestampNoChangedFlag ( u32 time)
inline

References m_timestamp.

Referenced by ServerEnvironment::activateBlock(), deSerialize(), deSerialize_pre22(), and ServerEnvironment::step().

+ Here is the caller graph for this function:

◆ step()

void MapBlock::step ( float dtime,
const std::function< bool(v3s16, MapNode, f32)> & on_timer_cb )

References getNodeNoEx(), getPosRelative(), m_node_timers, p(), setNodeTimer(), and NodeTimerList::step().

Referenced by ServerEnvironment::activateBlock(), and ServerEnvironment::step().

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

◆ storeActiveObject()

bool MapBlock::storeActiveObject ( u16 id)

References m_static_objects, MOD_REASON_REMOVE_OBJECTS_DEACTIVATE, MOD_STATE_WRITE_NEEDED, raiseModified(), and StaticObjectList::storeActiveObject().

+ Here is the call graph for this function:

Member Data Documentation

◆ contents

std::vector<content_t> MapBlock::contents

Referenced by ABMHandler::apply(), and raiseModified().

◆ data

◆ do_not_cache_contents

bool MapBlock::do_not_cache_contents = false

Referenced by ABMHandler::apply().

◆ is_underground

bool MapBlock::is_underground = false
private

◆ m_disk_timestamp

u32 MapBlock::m_disk_timestamp = BLOCK_TIMESTAMP_UNDEFINED
private

◆ m_gamedef

IGameDef* MapBlock::m_gamedef
private

◆ m_generated

bool MapBlock::m_generated = false
private

◆ m_is_air

bool MapBlock::m_is_air = false
private

◆ m_is_air_expired

bool MapBlock::m_is_air_expired = true
private

◆ m_lighting_complete

u16 MapBlock::m_lighting_complete = 0xFFFF
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().

◆ m_modified

u16 MapBlock::m_modified = MOD_STATE_CLEAN
private

◆ m_modified_reason

u32 MapBlock::m_modified_reason = 0
private

◆ m_node_metadata

◆ m_node_timers

◆ m_orphan

bool MapBlock::m_orphan = false
private

Referenced by isOrphan(), and makeOrphan().

◆ m_pos

v3s16 MapBlock::m_pos
private

Referenced by getPos().

◆ m_pos_relative

v3s16 MapBlock::m_pos_relative
private

Referenced by getPosRelative().

◆ m_refcount

short MapBlock::m_refcount = 0
private

Referenced by refDrop(), refGet(), and refGrab().

◆ m_static_objects

◆ m_timestamp

◆ m_usage_timer

float MapBlock::m_usage_timer = 0
private

◆ mesh

◆ nodecount

◆ solid_sides

u8 MapBlock::solid_sides = 0

◆ ystride

const u32 MapBlock::ystride = MAP_BLOCKSIZE
static

◆ zstride

const u32 MapBlock::zstride = MAP_BLOCKSIZE * MAP_BLOCKSIZE
static

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