QtCraft API C++ classes QML types Handbook

QcMapSaveCodec Namespace

One map in the world folder (decision E-799), maps/<id>.qcmap in the save file container (QcSaveFile): its scale, centre and world ("overworld", the only one so far), the names of the blocks it shows and its pixels as indices into that list with their shades, compressed. More...

Header: #include <server/maps/QcMapSaveCodec.h>

Variables

const QByteArrayView magic
const qsizetype maxBytes
const QStringView overworld

Functions

QString fileName(quint32 id)
std::optional<quint32> idOf(const QString &fileName)
QcResult<QcMapData> read(const QByteArray &file, const QString &path, const QcContentRegistry &content)
QByteArray write(const QcMapData &map, const QcContentRegistry &content)

Detailed Description

Blocks a later content no longer knows read as blank pixels. Every value is checked when read.

Variable Documentation

const QByteArrayView QcMapSaveCodec::magic

The container's magic of a map file.

const qsizetype QcMapSaveCodec::maxBytes

The longest file a map may have (a map of noise compresses to about 40 KiB).

const QStringView QcMapSaveCodec::overworld

The name of the world a map shows (the only one so far).

Function Documentation

QString QcMapSaveCodec::fileName(quint32 id)

Returns the file name of map id below the world folder ("maps/<id>.qcmap").

std::optional<quint32> QcMapSaveCodec::idOf(const QString &fileName)

Returns the id of map file name fileName ("maps/12.qcmap" or "12.qcmap"), std::nullopt for any other name and for ids beyond QcMapStore::maxId.

QcResult<QcMapData> QcMapSaveCodec::read(const QByteArray &file, const QString &path, const QcContentRegistry &content)

Returns the map read from file, its blocks looked up in content (unknown ones read as blank pixels), or an error naming path when the file is too large, damaged or not a map.

QByteArray QcMapSaveCodec::write(const QcMapData &map, const QcContentRegistry &content)

Returns the file of map with the block names of content.