QcCircuitState Struct
The work of the circuits of a world between ticks (decision E-335): block changes near circuits not yet looked at, positions waiting for chunks to load and comparators to read again. More...
| Header: | #include <server/signal/QcCircuitState.h> |
Public Types
Public Functions
| void | chunkLoaded(const QcServerWorld &world, QcChunkPos chunk) |
| void | clear() |
| void | forgetChunk(QcChunkPos chunk) |
| bool | isNearCircuit(const QcServerWorld &world, QcBlockPos pos) const |
| void | lookAgain(QcBlockPos pos, bool signal) |
| void | noteChange(const QcServerWorld &world, QcBlockPos pos, QcBlockId before, QcBlockId after) |
| void | noteContents(const QcServerWorld &world, QcBlockPos pos) |
| QHash<QcChunkPos, QcCircuitState::Pending> | pendingByChunk() const |
| QcCircuitState::Pending | takeChunk(QcChunkPos chunk) |
| void | takeReaders(const QcServerWorld &world) |
| QSet<QcChunkPos> | takeTicketWishes() |
| void | waitOn(QcChunkPos chunk, QcBlockPos pos, bool signal = false) |
| void | wake(const QcServerWorld &world, QcBlockPos pos) |
Public Variables
| QList<QcCircuitState::Change> | changes |
| quint64 | droppedChanges |
| qsizetype | maxPendingChanges |
| QSet<QcBlockPos> | readers |
| QSet<QcBlockPos> | signalWaits |
| QSet<QcChunkPos> | ticketWishes |
| QHash<QcChunkPos, QList<QcBlockPos>> | waiting |
| QHash<QcChunkPos, QList<QcBlockPos>> | waitingOn |
Static Public Members
| const quint64 | droppedReportInterval |
| QList<QcBlockPos> | readersOf(const QcServerWorld &world, QcBlockPos pos) |
Detailed Description
What components remember at their position and their scheduled ticks are block entities (QcBlockEntities, decision E-357). Lives in QcServerState; the waiting positions are saved with their chunk.
Member Function Documentation
void QcCircuitState::chunkLoaded(const QcServerWorld &world, QcChunkPos chunk)
Moves what waited for the chunks around chunk of world, newly loaded, into the changes when they are all loaded now, and lets the components along its borders with loaded chunks look at each other (a lamp loaded next to powered dust lights). Pistons there are left alone: they wait for a block update as always.
void QcCircuitState::clear()
Forgets all work.
void QcCircuitState::forgetChunk(QcChunkPos chunk)
Forgets the work of chunk, which was generated again.
bool QcCircuitState::isNearCircuit(const QcServerWorld &world, QcBlockPos pos) const
Returns whether a circuit component of world may lie within two blocks of pos (or the block there is one).
void QcCircuitState::lookAgain(QcBlockPos pos, bool signal)
Takes pos, a position from a chunk's record that the circuits were going to look at: a change of itself in the next step, a signal on its way or a look (decision E-374).
void QcCircuitState::noteChange(const QcServerWorld &world, QcBlockPos pos, QcBlockId before, QcBlockId after)
Remembers the change of the block at pos of world from before to after if a circuit component may lie within two blocks of it (or the block is one); changes far from any circuit cost nothing.
void QcCircuitState::noteContents(const QcServerWorld &world, QcBlockPos pos)
The contents of the container or machine at pos of world changed: the comparators that read it (behind them, or two behind through a block) look again in the next tick, each once (decision E-343). Without such a comparator it costs the circuits nothing.
QHash<QcChunkPos, QcCircuitState::Pending> QcCircuitState::pendingByChunk() const
Returns every position waiting for some chunk or change, by the chunk it lies in (saved with that chunk; read back as positions to look at once their chunk and the eight around it are loaded).
[static] QList<QcBlockPos> QcCircuitState::readersOf(const QcServerWorld &world, QcBlockPos pos)
Returns the comparators of world at pos + face or pos + 2 face that look away from pos (it lies behind them).
QcCircuitState::Pending QcCircuitState::takeChunk(QcChunkPos chunk)
Returns the Pending positions of chunk, which leaves the world, and takes them out.
void QcCircuitState::takeReaders(const QcServerWorld &world)
Moves the comparators of world whose readings may have changed into the changes, as changes of themselves; clears them.
QSet<QcChunkPos> QcCircuitState::takeTicketWishes()
Returns the chunks signals wait for since the last call.
void QcCircuitState::waitOn(QcChunkPos chunk, QcBlockPos pos, bool signal = false)
Looks at pos again once chunk is loaded; a signal waiting there asks for a load ticket of chunk (decision E-376).
void QcCircuitState::wake(const QcServerWorld &world, QcBlockPos pos)
Makes the circuits of world look at pos as if its block had just been placed (a demo of the world's setup, a change from a save), now or once its chunk and the eight around it are loaded, so a circuit across a chunk border starts whole.
Member Variable Documentation
QList<QcCircuitState::Change> QcCircuitState::changes
Block changes near circuits not yet looked at.
quint64 QcCircuitState::droppedChanges
Changes dropped beyond maxPendingChanges.
const quint64 QcCircuitState::droppedReportInterval
Dropped changes are logged with the first one and then every this many.
qsizetype QcCircuitState::maxPendingChanges
Pending changes beyond this many are dropped; the circuits around them are looked at again with the next change nearby (QcServerLimits::signalMaxPendingChanges, set by QcServerState).
QSet<QcBlockPos> QcCircuitState::readers
Comparators to look at again because what they read changed its contents.
QHash<QcChunkPos, QList<QcBlockPos>> QcCircuitState::waiting
Positions to look at once their chunk is loaded.
QHash<QcChunkPos, QList<QcBlockPos>> QcCircuitState::waitingOn
Positions to look at once a chunk next to them is loaded (they read into it).