QtCraft API C++ classes QML types Handbook

QcPendingCommands Class

Destructive commands wait for /confirm (decision E-245): each source (player or console) has at most one pending action, a new one replaces it, and it expires after timeoutSeconds of real time (the players' time of the server, QcServerClock::playerTimeNs). More...

Header: #include <server/commands/QcPendingCommands.h>

Public Types

Action

Public Functions

void ask(const QcCommandContext &context, QcPendingCommands::Action action, qint64 nowNs)
bool cancel(const QcCommandSource &source)
bool confirm(const QcCommandSource &source, qint64 nowNs)
void forget(quint32 sourceId)
bool hasPending(quint32 sourceId) const

Static Public Members

const qint64 timeoutNs
const int timeoutSeconds

Detailed Description

The action keeps the right its command needs: a source that lost it (/deop) cannot confirm. The action receives the source that confirms, so nothing refers to a player who has left.

Member Type Documentation

[alias] QcPendingCommands::Action

The destructive action, run for the source that confirms.

Member Function Documentation

void QcPendingCommands::ask(const QcCommandContext &context, QcPendingCommands::Action action, qint64 nowNs)

Keeps action for the source of context and tells it how to confirm; nowNs is the players' time.

bool QcPendingCommands::cancel(const QcCommandSource &source)

Drops the pending action of source and tells it so. Returns false when there was none.

bool QcPendingCommands::confirm(const QcCommandSource &source, qint64 nowNs)

Runs the pending action of source at the players' time nowNs. Returns false (after telling why) when there is none, it expired or the source may no longer run its command.

void QcPendingCommands::forget(quint32 sourceId)

The player sourceId (QcCommandSource::id) left or lost his rights: his pending action goes.

bool QcPendingCommands::hasPending(quint32 sourceId) const

Returns whether the source sourceId has a pending action.