QtCraft API C++ classes QML types Handbook

QcChunkSaveState Class

What the storage holds of the chunks and how the loaded chunks stand towards it (part of QcServerWorld, decision E-716): the catalog of stored chunks, the loaded chunks whose blocks changed since they were last kept or differ from what the generator makes, and the chunks whose stored data is damaged (decision E-373). More...

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

Public Types

Stored

Public Functions

bool differsFromGenerated(QcChunkPos pos) const
bool hasStored(QcChunkPos pos) const
bool isQuarantined(QcChunkPos pos) const
void noteArrived(QcChunkPos pos)
void noteChanged(QcChunkPos pos)
void noteKept(const QcChunkIo::Departure &departure)
bool noteLeft(QcChunkPos pos)
void noteRegenerated(QcChunkPos pos)
void quarantine(QcChunkPos pos, const QString &error)
void setStorage(QcChunkIo *io, QHash<QcChunkPos, QcChunkSaveState::Stored> catalog)
QcChunkIo *storage() const
std::optional<QcChunkSaveState::Stored> stored(QcChunkPos pos) const
qsizetype storedChunkCount() const
QList<QcChunkPos> storedChunks() const
quint16 storedMarks(QcChunkPos pos) const
bool takeChanged(QcChunkPos pos)
QList<QcChunkPos> takeNewlyQuarantined()

Detailed Description

Quarantined chunks play as generated and are never kept, until /regenerate replaces their stored data.

Member Type Documentation

[alias] QcChunkSaveState::Stored

What the storage holds of a chunk.

Member Function Documentation

bool QcChunkSaveState::differsFromGenerated(QcChunkPos pos) const

Returns whether the blocks of the loaded chunk pos differ from what the generator makes (changed while loaded or read from storage).

bool QcChunkSaveState::hasStored(QcChunkPos pos) const

Returns whether the storage holds data of the chunk pos (none without a storage).

bool QcChunkSaveState::isQuarantined(QcChunkPos pos) const

Returns whether the stored data of the chunk pos is damaged.

void QcChunkSaveState::noteArrived(QcChunkPos pos)

The chunk pos entered the world: it differs from the generated one when its stored blocks were read.

void QcChunkSaveState::noteChanged(QcChunkPos pos)

The blocks of the loaded chunk pos changed (a block was set, the chunk was put in as changed).

void QcChunkSaveState::noteKept(const QcChunkIo::Departure &departure)

departure was handed to the storage for a chunk (keeps stored() up to date).

bool QcChunkSaveState::noteLeft(QcChunkPos pos)

The chunk pos left the world. Returns true when its blocks changed since they were last kept and may be kept (not quarantined).

void QcChunkSaveState::noteRegenerated(QcChunkPos pos)

The loaded chunk pos was generated again: its damaged data is given up, and what plays now replaces the stored copy in the next save.

void QcChunkSaveState::quarantine(QcChunkPos pos, const QString &error)

The stored data of the chunk pos cannot be read (error): logged, and the chunk plays as generated.

void QcChunkSaveState::setStorage(QcChunkIo *io, QHash<QcChunkPos, QcChunkSaveState::Stored> catalog)

Reads and writes stored chunks through io (none: chunks are only generated); catalog is what the storage holds. Does not own io.

See also storage().

QcChunkIo *QcChunkSaveState::storage() const

Returns the storage; nullptr when chunks are only generated.

See also setStorage().

std::optional<QcChunkSaveState::Stored> QcChunkSaveState::stored(QcChunkPos pos) const

Returns what the storage holds of the chunk pos, as far as the server knows (kept up to date by noteKept()).

qsizetype QcChunkSaveState::storedChunkCount() const

Returns the number of stored chunks.

QList<QcChunkPos> QcChunkSaveState::storedChunks() const

Returns the stored chunks.

quint16 QcChunkSaveState::storedMarks(QcChunkPos pos) const

Returns the circuit marks of the stored chunk pos (zero for one never stored).

bool QcChunkSaveState::takeChanged(QcChunkPos pos)

Takes the changed mark of the chunk pos that is kept now (a save). Returns false when there is nothing to keep (unchanged or quarantined).

QList<QcChunkPos> QcChunkSaveState::takeNewlyQuarantined()

Returns the chunks found damaged since the last call (the server tells the operators).