QcSectionMarks Class
Per loaded chunk and block trait, a bit for each section that may hold a block with that trait. More...
| Header: | #include <server/chunks/QcSectionMarks.h> |
Public Types
Public Functions
| QcSectionMarks() | |
| QcSectionMarks(std::vector<QcSectionMarks::Traits> traits) | |
| qsizetype | chunkCount(QcBlockTrait trait) const |
| void | forgetChunk(QcChunkPos pos) |
| bool | isEmpty(QcBlockTrait trait) const |
| bool | isMarked(QcBlockId block, QcBlockTrait trait) const |
| void | noteBlock(QcBlockPos pos, QcBlockId block) |
| void | noteChunk(QcChunkPos pos, const QcChunk &chunk) |
| const QList<QcChunkPos> & | orderedChunks(QcBlockTrait trait) const |
| quint32 | sectionsOf(QcChunkPos pos, QcBlockTrait trait) const |
| QcSectionMarks::Traits | traitsOf(QcBlockId block) const |
Static Public Members
| QcSectionMarks::Traits | bit(QcBlockTrait trait) |
| QcSectionMarks::Traits | traitsOf(const QcBlockDefinition &block) |
Related Non-Members
| enum class | QcBlockTrait { ContactDamage, RandomTicks, Circuit, Plate, BlockEntity, …, Rail } |
| const int | qcBlockTraitCount |
Detailed Description
A bit is set when its chunk arrives or such a block is placed and only cleared when the chunk is noted again or forgotten, so it means "maybe": callers still look at the blocks. Chunks without any marked section are missing, so a tick over the marked sections costs nothing in a world without such blocks. One object marks every trait in one pass over the palettes and forgets a chunk with one call.
Member Function Documentation
[constexpr noexcept default] QcSectionMarks::QcSectionMarks()
Default-constructs an instance of QcSectionMarks.
[explicit] QcSectionMarks::QcSectionMarks(std::vector<QcSectionMarks::Traits> traits)
traits is indexed by block state id.
[static constexpr] QcSectionMarks::Traits QcSectionMarks::bit(QcBlockTrait trait)
Returns the bit of trait.
qsizetype QcSectionMarks::chunkCount(QcBlockTrait trait) const
Returns the number of chunks with sections marked for trait.
void QcSectionMarks::forgetChunk(QcChunkPos pos)
Forgets the bits of the chunk pos that left the world.
bool QcSectionMarks::isEmpty(QcBlockTrait trait) const
Returns whether no loaded chunk may hold a block with trait.
bool QcSectionMarks::isMarked(QcBlockId block, QcBlockTrait trait) const
Returns whether the state block has trait.
void QcSectionMarks::noteBlock(QcBlockPos pos, QcBlockId block)
Sets the bits of the section block was placed in at pos for its traits.
void QcSectionMarks::noteChunk(QcChunkPos pos, const QcChunk &chunk)
Replaces the bits of chunk at pos that entered the world from its section palettes.
const QList<QcChunkPos> &QcSectionMarks::orderedChunks(QcBlockTrait trait) const
Returns the chunks with sections marked for trait, sorted by x, then z: an order that does not depend on the hash of the process (QcPlantGrowth draws its random cells in it). Sorted again only after chunks gained or lost the trait, not on every call. The returned reference is only valid until the next noteChunk, noteBlock or forgetChunk (copy it to hold it across changes).
quint32 QcSectionMarks::sectionsOf(QcChunkPos pos, QcBlockTrait trait) const
Returns the bits of the chunk pos for trait (bit n: section n), 0 for a chunk without such sections.
[static] QcSectionMarks::Traits QcSectionMarks::traitsOf(const QcBlockDefinition &block)
Returns the traits of block from its data.
QcSectionMarks::Traits QcSectionMarks::traitsOf(QcBlockId block) const
Returns the traits of the state block.
Related Non-Members
enum class QcBlockTrait
Properties of blocks that the server finds by section instead of scanning the world (decision E-359).
Each comes from the block data (QcSectionMarks::traitsOf).
| Constant | Value | Description |
|---|---|---|
QcSectionMarks::QcBlockTrait::ContactDamage | 0 | Hurts what touches it (lava, magma). |
QcSectionMarks::QcBlockTrait::RandomTicks | 1 | Gets random ticks: growing plants, crops, soil. |
QcSectionMarks::QcBlockTrait::Circuit | 2 | A Signal Dust component other than a hopper (decision E-335; hoppers react only to power, which comes from components that are marked themselves, decision E-344). |
QcSectionMarks::QcBlockTrait::Plate | 3 | A pressure plate or tripwire: only bodies in its sections are checked for pressing one. |
QcSectionMarks::QcBlockTrait::BlockEntity | 4 | Holds a block entity created with the block: a container or a machine (decision E-357). |
QcSectionMarks::QcBlockTrait::Fire | 5 | Fire (decision E-392): a chunk that arrives is searched for fire blocks only in these sections. |
QcSectionMarks::QcBlockTrait::Spawner | 6 | A monster spawner (decision E-520): a chunk that arrives is searched for spawners only here. |
QcSectionMarks::QcBlockTrait::Rail | 7 | A rail: a chunk that arrives without one gets no minecart from its generator (decision E-570). |
const int qcBlockTraitCount
The number of block traits.