QtCraft API C++ classes QML types Handbook

QcServerSigns Class

Players writing on signs (decision E-766). More...

Header: #include <server/blockentities/QcServerSigns.h>

Public Functions

void announceChanges()
void edit(QcServerClient &client, const QcMsg::EditSign &message)
bool mayWrite(const QcServerClient &client, QcBlockPos pos) const
bool openEditor(QcServerClient &client, QcBlockPos pos)
void sendChunk(QcServerClient &client, QcChunkPos pos) const

Detailed Description

Placing a sign or using one (not sneaking, within reach, not in adventure mode) opens its editor on the player's client (QcMsg::OpenSignEditor); the player's EditSign is taken only for the sign whose editor the server opened for them, within reach and the Sign rate limit, and its lines are cleaned (QcSignText::cleaned: no control or format characters, the block's number of lines and line length). The text lives in QcSignTexts; clients learn it after the chunk (sendChunk) and whenever it changes (announceChanges). Holds no state of its own; made where it is needed, like QcBlockDyeing.

Member Function Documentation

void QcServerSigns::announceChanges()

Tells the clients that have a chunk about the signs in it whose text changed.

void QcServerSigns::edit(QcServerClient &client, const QcMsg::EditSign &message)

Takes the lines the player client wrote (message); ignored unless they belong to the sign whose editor is open.

bool QcServerSigns::mayWrite(const QcServerClient &client, QcBlockPos pos) const

Returns whether client may write on the sign block at pos now (also: dye its text, E-830).

bool QcServerSigns::openEditor(QcServerClient &client, QcBlockPos pos)

Opens the editor of the sign at pos for client (the caller checked sneaking). Returns false when there is no sign or the player may not write on it (then other uses of the click may follow).

void QcServerSigns::sendChunk(QcServerClient &client, QcChunkPos pos) const

Sends the texts of the signs in chunk pos to client (right after the chunk's blocks).