QtCraft API C++ classes QML types Handbook

QcProfileValidation Namespace

The server's check of a player's profile before it takes it over (Hello, SetAppearance; decisions E-036, E-231, E-232): the client stores and sends the profile, but nothing it sends is trusted. More...

Header: #include <common/auth/QcProfileValidation.h>

Variables

const QStringView markupCharacters
const qsizetype maxPlayerNameLength

Functions

QcAppearance appearance(const QcContentRegistry &content, const QcAppearance &requested)
bool hasMarkup(const QString &name)
QString playerName(const QString &requested)
std::optional<QString> validPlayerName(const QString &requested)

Detailed Description

Outfit, hair and cape names longer than QcAppearance::maxNameLength never get here: the decoder refuses the whole message.

Variable Documentation

const QStringView QcProfileValidation::markupCharacters

Characters a player name may not hold: shown on other clients, a name must never read as markup.

const qsizetype QcProfileValidation::maxPlayerNameLength

In Unicode code points (QcNameText).

Function Documentation

QcAppearance QcProfileValidation::appearance(const QcContentRegistry &content, const QcAppearance &requested)

Returns requested with only playable outfits, hair styles and capes of content: an unknown or wrong outfit becomes the default outfit (or else any playable one), an unknown or wrong hair style or cape none; colours keep their RGB bits.

bool QcProfileValidation::hasMarkup(const QString &name)

Returns whether name holds one of markupCharacters.

QString QcProfileValidation::playerName(const QString &requested)

Returns validPlayerName() of requested, with "Player" for a name that names nobody (Hello).

std::optional<QString> QcProfileValidation::validPlayerName(const QString &requested)

Returns requested without unpaired surrogates, control and format characters, trimmed, at most maxPlayerNameLength code points cut between graphemes (QcNameText::clean); std::nullopt when no letter, digit or symbol is left (empty, only spaces or punctuation) or when it holds one of markupCharacters. Commands refuse such names, the login refuses names with markup characters.