QcServerWorld Class
Authoritative block world of the server. More...
| Header: | #include <server/core/QcServerWorld.h> |
| Inherits: | QcBlockAccess |
Public Types
Public Functions
| QcServerWorld(const QcServerWorld &) | |
| QcServerWorld(QcServerWorld &&) | |
| virtual | ~QcServerWorld() override |
| void | admit(QcServerWorld::Arrival &&arrival) |
| void | adoptStoredChunks(const QHash<QcChunkPos, std::shared_ptr<QcChunk>> &chunks) |
| quint64 | blockChanges() const |
| QcBlockEntities & | blockEntities() |
| const QcBlockEntities & | blockEntities() const |
| QcBlockEntityExtras & | blockEntityExtras() |
| const QcBlockEntityExtras & | blockEntityExtras() const |
| int | blockLight(QcBlockPos pos) const |
| QcCampfires & | campfires() |
| const QcCampfires & | campfires() const |
| std::shared_ptr<const QcChunk> | chunk(QcChunkPos pos) const |
| std::vector<QcServerWorld::Arrival> | collectArrivals() |
| QList<QcChunkPos> | collectGeneratedChunks() |
| QcFireQueue & | fires() |
| const QcFireQueue & | fires() const |
| const QcWorldGenerator & | generator() const |
| QcBlockIndex & | hoppers() |
| const QcBlockIndex & | hoppers() const |
| bool | isRequested(QcChunkPos pos) const |
| quint64 | lastChangeIn(QcChunkPos pos) const |
| const QcLightEngine & | light() const |
| quint16 | linkMarksOf(QcChunkPos pos) const |
| const QcChunkLinks & | links() const |
| std::shared_ptr<const QcChunk> | loadChunk(QcChunkPos pos) |
| qsizetype | loadedChunkCount() const |
| QList<QcChunkPos> | loadedChunks() const |
| quint64 | loadedEpoch() const |
| QcChunkLoaders & | loaders() |
| const QcChunkLoaders & | loaders() const |
| const QcSectionMarks & | marks() const |
| qsizetype | pendingGenerationCount() const |
| void | planStructureSitesInBackground(QcBlockPos from, int reach) |
| QcServerWorld::Arrival | produceNow(QcChunkPos pos) |
| bool | regenerateChunk(QcChunkPos pos) |
| std::shared_ptr<const QcChunk> | remove(QcChunkPos pos) |
| void | requestChunk(QcChunkPos pos) |
| QcChunkSaveState & | saves() |
| const QcChunkSaveState & | saves() const |
| void | setArrivalHandler(QcServerWorld::ArrivalHandler handler) |
| bool | setBlock(QcBlockPos pos, QcBlockId block) |
| void | setGroupLoader(QcServerWorld::GroupLoader loader) |
| void | setStorage(QcChunkIo *io, QHash<QcChunkPos, QcServerWorld::Stored> catalog) |
| QcSignTexts & | signs() |
| const QcSignTexts & | signs() const |
| int | skyLight(QcBlockPos pos) const |
| QcSpawners & | spawners() |
| const QcSpawners & | spawners() const |
| std::shared_ptr<const QcChunk> | takeChanged(QcChunkPos pos) |
| std::shared_ptr<QcChunk> | takeChunk(QcChunkPos pos) |
| QList<QcChunkPos> | takeNewlyLoaded() |
| void | unloadChunk(QcChunkPos pos) |
| QcVillages & | villages() |
| const QcVillages & | villages() const |
| QcServerWorld & | operator=(QcServerWorld &&) |
| QcServerWorld & | operator=(const QcServerWorld &) |
Reimplemented Public Functions
| virtual std::optional<QcBlockId> | blockAt(QcBlockPos pos) const override |
| virtual const QcContentRegistry & | content() const override |
| virtual bool | mayHaveLightSourceNear(QcBlockPos pos, int reach) const override |
Detailed Description
Chunks handed out as const snapshots stay immutable: modifying a chunk that is still shared copies it first.
Chunks come into the world generated or read from the world's storage (QcChunkIo, decision E-373): requestChunk() starts that in the background, collectArrivals() hands over what is ready and admit() puts a chunk into the world, at once (loadChunk() does all three and waits). What was kept of a chunk's block entities and entities goes to the arrival handler (QcChunkLoading). Chunks leave the world through remove() (QcChunkLoading, decision E-374), which hands their blocks back when they changed since they were last kept.
Member Type Documentation
[alias] QcServerWorld::Arrival
A chunk as read or generated, not yet in the world.
[alias] QcServerWorld::ArrivalHandler
Takes what was kept of a chunk that enters the world.
[alias] QcServerWorld::GroupLoader
Loads a chunk now with the chunks of its group (QcChunkLoading::loadGroupNow); loadChunk() asks it when set, so a chunk loaded at once (spawn, commands) never comes without its group.
[alias] QcServerWorld::Stored
What the storage holds of a chunk.
Member Function Documentation
[delete] QcServerWorld::QcServerWorld(const QcServerWorld &)
Copy-constructs an instance of QcServerWorld. This function is deleted.
[delete] QcServerWorld::QcServerWorld(QcServerWorld &&)
Move-constructs an instance of QcServerWorld. This function is deleted.
[override virtual noexcept default] QcServerWorld::~QcServerWorld()
Destroys the instance of QcServerWorld. This destructor is virtual.
void QcServerWorld::admit(QcServerWorld::Arrival &&arrival)
Puts arrival, an arrived chunk, into the world and passes what was kept of it to the arrival handler.
void QcServerWorld::adoptStoredChunks(const QHash<QcChunkPos, std::shared_ptr<QcChunk>> &chunks)
Puts chunks into the world as changed (tests).
[override virtual] std::optional<QcBlockId> QcServerWorld::blockAt(QcBlockPos pos) const
Reimplements: QcBlockAccess::blockAt(QcBlockPos pos) const.
quint64 QcServerWorld::blockChanges() const
Returns the count of block changes of the world (decision E-920): every changed block and every chunk that entered the world or was generated again.
QcBlockEntities &QcServerWorld::blockEntities()
Returns the state that belongs to single blocks (decision E-357), kept in step with every block set here, every chunk that arrives and every chunk generated again.
const QcBlockEntities &QcServerWorld::blockEntities() const
Returns the state that belongs to single blocks, read-only.
QcBlockEntityExtras &QcServerWorld::blockEntityExtras()
Returns which loaded chunks were furnished and the parts of their saved block entities this version does not read (decisions E-520, E-440); kept in step with every block set here.
const QcBlockEntityExtras &QcServerWorld::blockEntityExtras() const
Returns the furnished chunks and the kept parts of block entities, read-only.
int QcServerWorld::blockLight(QcBlockPos pos) const
Returns the block light at pos.
QcCampfires &QcServerWorld::campfires()
Returns the items cooking on the campfires of the loaded chunks (decision E-772), kept in step like the spawners.
const QcCampfires &QcServerWorld::campfires() const
Returns the items cooking on the campfires, read-only.
std::shared_ptr<const QcChunk> QcServerWorld::chunk(QcChunkPos pos) const
Returns the loaded chunk pos; null when it is not loaded.
std::vector<QcServerWorld::Arrival> QcServerWorld::collectArrivals()
Returns the chunks read or generated in the background since the last call; not yet in the world (admit).
QList<QcChunkPos> QcServerWorld::collectGeneratedChunks()
Moves every finished background chunk into the world at once (worlds without groups: tests). Returns their positions.
[override virtual] const QcContentRegistry &QcServerWorld::content() const
Reimplements: QcBlockAccess::content() const.
QcFireQueue &QcServerWorld::fires()
Returns the burning fires of the loaded chunks and their next steps (decision E-392), kept in step with every block set here and every chunk that arrives, leaves or is generated again.
const QcFireQueue &QcServerWorld::fires() const
Returns the burning fires, read-only.
const QcWorldGenerator &QcServerWorld::generator() const
Returns the world generator.
QcBlockIndex &QcServerWorld::hoppers()
Returns the loaded Signal Hoppers and the cells changed next to them (decision E-344).
const QcBlockIndex &QcServerWorld::hoppers() const
Returns the loaded Signal Hoppers, read-only.
bool QcServerWorld::isRequested(QcChunkPos pos) const
Returns whether the chunk pos is being read or generated in the background.
quint64 QcServerWorld::lastChangeIn(QcChunkPos pos) const
Returns the count of blockChanges() when a block of the chunk pos last changed or the chunk entered the world; the largest count there is for a chunk that is not loaded. A resting boat compares it with the count when it came to rest instead of reading its blocks every tick.
const QcLightEngine &QcServerWorld::light() const
Returns the block and sky light of the loaded chunks (decision E-389), kept in step with every block set here and every chunk that enters or leaves the world.
quint16 QcServerWorld::linkMarksOf(QcChunkPos pos) const
Returns the circuit marks of the chunk pos: of a loaded one as it is, of another one as stored.
const QcChunkLinks &QcServerWorld::links() const
Returns the circuits' links across chunk borders (decision E-375).
std::shared_ptr<const QcChunk> QcServerWorld::loadChunk(QcChunkPos pos)
Returns the chunk pos, reading or generating it synchronously when needed (spawn, commands, tests).
qsizetype QcServerWorld::loadedChunkCount() const
Returns the number of loaded chunks.
QList<QcChunkPos> QcServerWorld::loadedChunks() const
Returns the loaded chunks.
quint64 QcServerWorld::loadedEpoch() const
Returns a count that changes whenever a chunk enters or leaves the world (QcEntities::settle).
QcChunkLoaders &QcServerWorld::loaders()
Returns the chunk loader blocks of the world, loaded or not (decision E-377).
const QcChunkLoaders &QcServerWorld::loaders() const
Returns the chunk loader blocks, read-only.
const QcSectionMarks &QcServerWorld::marks() const
Returns the sections of the loaded chunks that may hold blocks with a trait (decision E-359): contact damage (QcContactDamage), growing plants, circuit components (block changes far from any circuit cost the signal engine nothing), pressure plates, block entities.
[override virtual] bool QcServerWorld::mayHaveLightSourceNear(QcBlockPos pos, int reach) const
Reimplements: QcBlockAccess::mayHaveLightSourceNear(QcBlockPos pos, int reach) const.
qsizetype QcServerWorld::pendingGenerationCount() const
Returns the chunks being read or generated in the background.
void QcServerWorld::planStructureSitesInBackground(QcBlockPos from, int reach)
Plans the generator's guardian zones and spawn areas within reach of from on a generation thread, so the tick thread finds them planned (QcWorldGenerator::plannedStructureSitesNear, QcGuardians, QcSpawnAreas); one such job at a time, a call while one runs is dropped.
QcServerWorld::Arrival QcServerWorld::produceNow(QcChunkPos pos)
Returns the chunk pos as read or generated now, not yet in the world (for admit()); a background request of it is superseded.
bool QcServerWorld::regenerateChunk(QcChunkPos pos)
Replaces the loaded chunk pos with what the generator makes of it (decision E-246); its block entities are forgotten and those of the generated blocks created. It counts as changed, so the next save also overwrites the stored copy. Returns false when it is not loaded.
std::shared_ptr<const QcChunk> QcServerWorld::remove(QcChunkPos pos)
Takes the chunk pos out of the world with what was derived from its blocks (marks, hoppers, links); its block entities must have been taken before (QcBlockEntityRecord::takeFrom). Returns its blocks if they changed since they were last kept.
void QcServerWorld::requestChunk(QcChunkPos pos)
Starts reading or generating the chunk pos in the background unless it is loaded or under way.
QcChunkSaveState &QcServerWorld::saves()
Returns what the storage holds of the chunks, the loaded chunks that differ from it or from the generator, the quarantined chunks (decision E-373).
const QcChunkSaveState &QcServerWorld::saves() const
Returns what the storage holds of the chunks, read-only.
void QcServerWorld::setArrivalHandler(QcServerWorld::ArrivalHandler handler)
Sets handler, called with what was kept of every chunk that enters the world (read or generated).
bool QcServerWorld::setBlock(QcBlockPos pos, QcBlockId block)
Sets the block at pos to block. Returns false for unloaded chunks, positions outside the world height and unknown block ids. The block entities follow (QcBlockEntities::placed); spilled contents wait in blockEntities().
void QcServerWorld::setGroupLoader(QcServerWorld::GroupLoader loader)
Sets loader as the group loader.
void QcServerWorld::setStorage(QcChunkIo *io, QHash<QcChunkPos, QcServerWorld::Stored> catalog)
Reads and writes stored chunks through io (none: chunks are only generated); catalog is what the storage holds. The world does not own io.
QcSignTexts &QcServerWorld::signs()
Returns the text on the signs of the loaded chunks (decision E-766), kept in step like the spawners.
const QcSignTexts &QcServerWorld::signs() const
Returns the text on the signs, read-only.
int QcServerWorld::skyLight(QcBlockPos pos) const
Returns the sky light at pos.
QcSpawners &QcServerWorld::spawners()
Returns the monster spawners of the loaded chunks (decision E-520), kept in step like the fires.
const QcSpawners &QcServerWorld::spawners() const
Returns the monster spawners, read-only.
std::shared_ptr<const QcChunk> QcServerWorld::takeChanged(QcChunkPos pos)
Returns the blocks of the changed chunk pos as a snapshot for keeping (a save); it counts as unchanged then.
std::shared_ptr<QcChunk> QcServerWorld::takeChunk(QcChunkPos pos)
Removes the loaded chunk pos whatever its state and returns it (tests of circuits at the edge of the loaded area; nothing is kept).
QList<QcChunkPos> QcServerWorld::takeNewlyLoaded()
Returns the chunks that became loaded (generated, loaded synchronously or read from a save) since the last call.
void QcServerWorld::unloadChunk(QcChunkPos pos)
Drops the chunk pos, if unchanged, without keeping anything (worlds without storage: tests); changed ones stay. Empty, resting containers and idle machines go; they come back with their blocks.
QcVillages &QcServerWorld::villages()
Returns the villages of the world, loaded or not (decision E-403).
const QcVillages &QcServerWorld::villages() const
Returns the villages, read-only.
[delete] QcServerWorld &QcServerWorld::operator=(QcServerWorld &&)
Move-assigns other to this QcServerWorld instance. This function is deleted.
[delete] QcServerWorld &QcServerWorld::operator=(const QcServerWorld &)
Copy-assigns other to this QcServerWorld instance. This function is deleted.