QtCraft API C++ classes QML types Handbook

QcBlockMirror Class

The blocks of the loaded chunks as the client shows them (decision E-853): what the server's world messages say and, on top, the local player's predicted block changes. More...

Header: #include <clientcore/session/QcBlockMirror.h>

Public Types

struct Change
Changed

Public Functions

const std::shared_ptr<const QcContentRegistry> &content() const
std::optional<QcBlockMirror::Change> handle(const QcMessage &message)
bool isPredicted(QcBlockPos pos) const
QList<QcBlockMirror::Changed> predict(quint32 sequence, const QList<QcMsg::BlockUpdate> &blocks)
qsizetype predictedCount() const
std::optional<QcBlockId> serverBlock(QcBlockPos pos) const
const QcClientWorld *world() const

Detailed Description

A prediction sets its cells at once and remembers per cell the newest action that set it and the block the server sent there last; while a cell waits, the server's blocks for it are only remembered. The acknowledgement of an action (QcMsg::BlockAck) ends the waiting of every cell no later action set: the cell shows the server's block again, so a refused action is rolled back and a confirmed one changes nothing. The session's world mirror (QcWorldMirror) and its tick core (QcSessionCore) each keep one; both see the same messages and predictions in the same order.

Member Type Documentation

[alias] QcBlockMirror::Changed

A cell that changed and the block it held before.

Member Function Documentation

const std::shared_ptr<const QcContentRegistry> &QcBlockMirror::content() const

Returns the content the server sent; null until it arrived.

std::optional<QcBlockMirror::Change> QcBlockMirror::handle(const QcMessage &message)

Returns the change message made when it is a content, chunk, block or acknowledgement message; none for other messages.

bool QcBlockMirror::isPredicted(QcBlockPos pos) const

Returns whether the cell pos shows a prediction that waits for its acknowledgement.

QList<QcBlockMirror::Changed> QcBlockMirror::predict(quint32 sequence, const QList<QcMsg::BlockUpdate> &blocks)

Shows the blocks the action numbered sequence is expected to set (cells of chunks that are not loaded are left out) and returns the cells that changed.

qsizetype QcBlockMirror::predictedCount() const

Returns the number of cells that show a prediction waiting for its acknowledgement.

std::optional<QcBlockId> QcBlockMirror::serverBlock(QcBlockPos pos) const

Returns the block the server sent last for the cell pos, also while it shows a prediction; none where no chunk is loaded.

const QcClientWorld *QcBlockMirror::world() const

Returns the blocks of the loaded chunks; null until the content arrived.