QtCraft API C++ classes QML types Handbook

QcServerPause Class

Whether the server's tick loop pauses (decision E-877). More...

Header: #include <server/tick/QcServerPause.h>

Public Types

enum class Reason { None, Menu, Empty }
ViewCheck

Public Functions

void noteChange()
bool paused() const
QcServerPause::Reason reason() const
bool takeChange()
std::optional<QcServerPause::Reason> update(const std::vector<std::unique_ptr<QcServerClient>> &clients, qint64 playerTimeNs, const QcServerPause::ViewCheck &viewComplete)

Static Public Members

const char *name(QcServerPause::Reason reason)

Detailed Description

It pauses for the pause menu of a world hosted in the game (every connected client is local, asked for it, QcMsg::PauseRequest, and has its view: a world opened straight into the pause menu still loads around the player) and when no one was connected for emptySeconds of the players' time (a dedicated server; 0 never). A network client's wish never pauses a shared server, and anyone connecting resumes it at once, so the login runs. While paused the server runs no tick: the tick counter, the time of day and the simulation stand still; messages, the console, the admin channel and logins go on between ticks.

Member Type Documentation

enum class QcServerPause::Reason

Why the server pauses.

ConstantValueDescription
QcServerPause::Reason::None0It does not pause.
QcServerPause::Reason::Menu1The pause menu of a world hosted in the game.
QcServerPause::Reason::Empty2No one was connected for the configured time.

[alias] QcServerPause::ViewCheck

Whether a client has every chunk of its view (QcChunkStreaming::viewComplete).

Member Function Documentation

[static] const char *QcServerPause::name(QcServerPause::Reason reason)

Returns reason as the log names it ("pause menu", "no players").

void QcServerPause::noteChange()

Something may have changed the world while paused (a console command): takeChange() is true once, so the paused server saves it.

bool QcServerPause::paused() const

Returns whether the server pauses now.

QcServerPause::Reason QcServerPause::reason() const

Returns why the server pauses now.

bool QcServerPause::takeChange()

Returns whether something changed the world while paused since the last call.

std::optional<QcServerPause::Reason> QcServerPause::update(const std::vector<std::unique_ptr<QcServerClient>> &clients, qint64 playerTimeNs, const QcServerPause::ViewCheck &viewComplete)

Decides anew from clients (closed ones count as gone) at playerTimeNs, with viewComplete for the pause menu. Returns the new reason when it changed, else std::nullopt.