QtCraft API C++ classes QML types Handbook

QcServerMaps Class

What players do with maps in the server (decisions E-800 to E-804, E-807, E-808): using an empty map makes a filled map of the land around its user, holding a filled map reveals the land around its holder, and the holder and the players near an item frame showing the map receive what changed of it, at most pixelBudget pixels per player and tick, with the players who carry the map and the frames showing it as markers. More...

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

Public Functions

void forget(const QcServerClient &client)
std::optional<quint32> mapIdOf(const QcItemStack &stack) const
void tick()
bool useHeld(QcServerClient &client)
std::optional<quint32> zoomOut(quint32 id)

Static Public Members

QcMapMarker frameMarker(const QcMapData &map, const QcHanging &hanging)
const double frameWatchRange
const int framedMarkerInterval
const int markerInterval
const int maxMapsPerMinute
const int maxWatched
const int pixelBudget
const double watchSlack

Detailed Description

Holds no state of its own (the maps, what each player watches and the maps players made are in QcMapStore), so the server makes one where it needs it.

Member Function Documentation

void QcServerMaps::forget(const QcServerClient &client)

client left.

[static] QcMapMarker QcServerMaps::frameMarker(const QcMapData &map, const QcHanging &hanging)

Returns the marker of an item frame hanging on map (decision E-808): where it hangs, facing away from its wall (a frame on a floor or ceiling turned like its map).

std::optional<quint32> QcServerMaps::mapIdOf(const QcItemStack &stack) const

Returns the map id of the filled map stack stack, std::nullopt for anything else.

void QcServerMaps::tick()

Reveals the held maps and sends what changed (QcMsg::MapUpdate) to their holders and to the players near frames showing them; maps neither used nor framed leave memory (QcMapStore::tick).

bool QcServerMaps::useHeld(QcServerClient &client)

Handles the use button of client with an empty map in the hand: the map becomes a filled map (scale 0) of the land around the player (one map of a stack; the filled map goes into the inventory or drops), at most maxMapsPerMinute per player. Returns false when the held item is no empty map.

std::optional<quint32> QcServerMaps::zoomOut(quint32 id)

Makes a new map one scale larger around the same land as map id (zooming out, decision E-804). Returns its id; std::nullopt for an unknown map, one at the largest scale, or when the ids are used up.

Member Variable Documentation

const double QcServerMaps::frameWatchRange

Item frames within this many blocks of a player send their maps to it (decision E-807).

const int QcServerMaps::framedMarkerInterval

Ticks between two marker updates of a map a player only sees in a frame (frames rarely move).

const int QcServerMaps::markerInterval

Ticks between two marker updates of a held map when no pixels go out.

const int QcServerMaps::maxMapsPerMinute

New maps one creative player may make per minute of ticks (decision E-810): creative players keep their empty map, so only this bounds the files they can add to the world; in survival every map costs paper, as in the reference, which has no limit.

const int QcServerMaps::maxWatched

Maps one player watches at most: the held one and the nearest framed ones.

const int QcServerMaps::pixelBudget

Pixels a player receives per tick at most (a whole new map in four ticks).

const double QcServerMaps::watchSlack

Blocks a framed map a player watches already counts nearer (decision E-807): it stops only beyond frameWatchRange plus these, and a new map takes its place among the maxWatched only when it is this much nearer.