QcMapData Class
The picture of one map (decision E-799), the same for the server, which reveals and saves it, and the client, which keeps what the server sent: size x size pixels over a square of the world that lies on a fixed grid of its scale (the map of a block column is the same for every holder), each pixel the top block of its column with a shade (QcMapPixel), 0 where nobody has looked yet. More...
| Header: | #include <common/maps/QcMapData.h> |
Public Functions
| QcMapData() | |
| quint16 | at(QPoint pixel) const |
| int | blocksPerPixel() const |
| QPoint | centre() const |
| QPoint | columnOf(QPoint pixel) const |
| QPointF | offsetOf(double x, double z) const |
| std::optional<QPoint> | pixelAt(int x, int z) const |
| const QList<quint16> & | pixels() const |
| QList<quint16> | pixelsIn(QRect area) const |
| int | revealedCount() const |
| int | scale() const |
| bool | set(QPoint pixel, quint16 value) |
| bool | setPixels(QRect area, const QList<quint16> &values) |
Static Public Members
| QcMapData | around(int x, int z, int scale) |
| QRect | bounds() |
| std::optional<QcMapData> | fromParts(int scale, QPoint centre, QList<quint16> pixels) |
| const int | maxCentre |
| const int | maxScale |
| const int | pixelCount |
| const int | size |
Detailed Description
One pixel covers blocksPerPixel() x blocksPerPixel() columns; north is up (-z), east right (+x).
Member Function Documentation
[constexpr noexcept default] QcMapData::QcMapData()
Default-constructs an instance of QcMapData.
[static] QcMapData QcMapData::around(int x, int z, int scale)
Returns the blank map of scale whose grid square holds the block column (x, z).
quint16 QcMapData::at(QPoint pixel) const
Returns the value of pixel (QcMapPixel); pixel must lie within the map.
int QcMapData::blocksPerPixel() const
Returns the block columns along each side of one pixel: 2^scale.
[static] QRect QcMapData::bounds()
Returns the rectangle of all pixels.
QPoint QcMapData::centre() const
Returns the block column at the middle of the map (the corner of the four middle pixels).
QPoint QcMapData::columnOf(QPoint pixel) const
Returns the first block column of pixel (its north west corner).
[static] std::optional<QcMapData> QcMapData::fromParts(int scale, QPoint centre, QList<quint16> pixels)
Returns the map of scale with its middle at centre and pixels, read from a save or a message: std::nullopt for a scale or centre out of range or a pixel list of the wrong length.
QPointF QcMapData::offsetOf(double x, double z) const
Returns where (x, z) lies in half pixels from the map's middle, as markers count (may lie outside).
std::optional<QPoint> QcMapData::pixelAt(int x, int z) const
Returns the pixel of the block column (x, z), or std::nullopt outside the map.
const QList<quint16> &QcMapData::pixels() const
Returns every pixel, row by row.
See also setPixels().
QList<quint16> QcMapData::pixelsIn(QRect area) const
Returns the pixels of area row by row (area within the map).
int QcMapData::revealedCount() const
Returns how many pixels show something.
int QcMapData::scale() const
Returns the scale (0 to maxScale).
bool QcMapData::set(QPoint pixel, quint16 value)
Sets pixel to value. Returns whether it changed.
bool QcMapData::setPixels(QRect area, const QList<quint16> &values)
Writes values (row by row) into area. Returns false, with no change, when they do not fit.
See also pixels().
Member Variable Documentation
const int QcMapData::maxCentre
Centres further out than this are damaged data: the centre of the largest map around the farthest block column of the world (decision E-883) lies less than its width beyond it.
const int QcMapData::maxScale
Scale 0 shows one block per pixel, every step doubles it (zooming out, decision E-804).
const int QcMapData::pixelCount
Pixels in all.
const int QcMapData::size
Pixels along each side.