QtCraft API C++ classes QML types Handbook

QcChunkLinks Class

Which loaded chunks a circuit or machine connects across their border (decision E-375), kept up to date as chunks arrive and blocks are set, never computed per tick. More...

Header: #include <server/chunks/QcChunkLinks.h>

Public Types

enum class Side { East, West, South, North }

Public Functions

quint64 changes() const
void forgetChunk(QcChunkPos chunk)
quint16 marksOf(QcChunkPos chunk) const
quint16 marksOf(const QcChunk &chunk) const
void noteBlock(QcBlockPos pos, QcBlockId before, QcBlockId after)
void noteChunk(const QcChunk &chunk)

Static Public Members

bool linked(quint16 marks, quint16 neighbourMarks, QcChunkLinks::Side side)
QcChunkPos neighbour(QcChunkPos chunk, QcChunkLinks::Side side)
QcChunkLinks::Side opposite(QcChunkLinks::Side side)
const int pistonReach
const int sideCount
const std::array<QcChunkLinks::Side, sideCount> sides
const int stripWidth

Detailed Description

A chunk has a mark per side (east +x, west -x, south +z, north -z):

Two neighbouring chunks are linked when both have a strip towards each other or either reaches into the other. The marks of a chunk are saved with it (QcChunkStore::Stored::marks), so the links of chunks that are not loaded are known without reading them; linked chunks form a group that loads and unloads as a whole (QcChunkGroups).

Member Type Documentation

enum class QcChunkLinks::Side

The sides of a chunk; the value is the side's bit in the marks (strip; reach four bits higher), so it is part of the saved marks (QcChunkStore::Stored::marks).

ConstantValueDescription
QcChunkLinks::Side::East0Towards +x.
QcChunkLinks::Side::West1Towards -x.
QcChunkLinks::Side::South2Towards +z.
QcChunkLinks::Side::North3Towards -z.

Member Function Documentation

quint64 QcChunkLinks::changes() const

Returns the count of changes of the marks of loaded chunks (QcChunkLoading looks at groups again on a change).

void QcChunkLinks::forgetChunk(QcChunkPos chunk)

chunk left the world: its marks are forgotten.

[static] bool QcChunkLinks::linked(quint16 marks, quint16 neighbourMarks, QcChunkLinks::Side side)

Returns whether a chunk with marks and its neighbour with neighbourMarks are linked across side of the first one.

quint16 QcChunkLinks::marksOf(QcChunkPos chunk) const

Returns the marks of the loaded chunk (0 for one without).

quint16 QcChunkLinks::marksOf(const QcChunk &chunk) const

Returns the marks of any chunk, counted from its blocks.

[static] QcChunkPos QcChunkLinks::neighbour(QcChunkPos chunk, QcChunkLinks::Side side)

Returns the neighbour of chunk across side.

void QcChunkLinks::noteBlock(QcBlockPos pos, QcBlockId before, QcBlockId after)

The block at pos changed from before to after in a loaded chunk.

void QcChunkLinks::noteChunk(const QcChunk &chunk)

chunk entered the world: counts its circuit parts near its sides and its pistons.

[static constexpr] QcChunkLinks::Side QcChunkLinks::opposite(QcChunkLinks::Side side)

Returns the side that faces back across side.

Member Variable Documentation

const int QcChunkLinks::pistonReach

A piston pushes up to 12 blocks one cell on: blocks up to 13 cells ahead move.

const int QcChunkLinks::sideCount

The number of sides of a chunk.

const std::array<QcChunkLinks::Side, sideCount> QcChunkLinks::sides

All sides of a chunk, in the order of their bits.

const int QcChunkLinks::stripWidth

A circuit part this many cells or fewer from a side marks its strip.