QtCraft API C++ classes QML types Handbook

QcDeviceLossPolicy Class

What the game does when the graphics device is lost (decision E-963): a lost device while the realistic mode is drawn gives coolDownMs() of classic frames, a second one within repeatWindowMs of the first draws the classic look for the rest of the session. More...

Header: #include <clientcore/settings/QcDeviceLossPolicy.h>

Public Types

enum class Response { Recover, CoolDown, FallBack }

Public Functions

QcDeviceLossPolicy(qint64 coolDownMs = defaultCoolDownMs)
void choseAgain()
qint64 coolDownLeftMs(qint64 nowMs) const
qint64 coolDownMs() const
QcDeviceLossPolicy::Response deviceLost(qint64 nowMs, bool realistic)
bool fellBack() const
bool realisticAllowed(qint64 nowMs) const

Static Public Members

const qint64 defaultCoolDownMs
const qint64 repeatWindowMs

Detailed Description

A weak GPU whose driver resets after a too long submission (Windows' TDR) would otherwise fall straight back into the same heavy frames on the new device. A loss while the classic look is drawn is not the realistic mode's fault and changes nothing. Pure logic: the caller passes the time in milliseconds of a monotonic clock.

Member Type Documentation

enum class QcDeviceLossPolicy::Response

The answer to a lost device: Recover draws on as chosen, CoolDown draws classic frames for coolDownMs(), FallBack draws the classic look until the player chooses the render mode again.

ConstantValueDescription
QcDeviceLossPolicy::Response::Recover0nothing changes
QcDeviceLossPolicy::Response::CoolDown1classic frames for a while
QcDeviceLossPolicy::Response::FallBack2the classic look for the session

Member Function Documentation

[explicit] QcDeviceLossPolicy::QcDeviceLossPolicy(qint64 coolDownMs = defaultCoolDownMs)

Makes a policy with coolDownMs of classic frames after a first loss (tests take a short one).

void QcDeviceLossPolicy::choseAgain()

The player chose the render mode again: the realistic mode may be drawn and the losses before count no more.

qint64 QcDeviceLossPolicy::coolDownLeftMs(qint64 nowMs) const

Returns the milliseconds of classic frames left at nowMs, 0 when none are left or the policy fell back for the session.

qint64 QcDeviceLossPolicy::coolDownMs() const

Returns the classic frames after a first loss in milliseconds.

QcDeviceLossPolicy::Response QcDeviceLossPolicy::deviceLost(qint64 nowMs, bool realistic)

Returns the answer to a device lost at nowMs while the realistic mode was drawn (realistic) or not. A realistic loss during a cool-down (the game draws the classic look then, so it does not happen there) counts like any other: within repeatWindowMs of the previous one it falls back. A classic loss changes nothing, neither the cool-down nor the window of the previous realistic loss.

bool QcDeviceLossPolicy::fellBack() const

Returns whether the classic look is drawn for the rest of the session.

bool QcDeviceLossPolicy::realisticAllowed(qint64 nowMs) const

Returns whether the realistic mode may be drawn at nowMs.

Member Variable Documentation

const qint64 QcDeviceLossPolicy::defaultCoolDownMs

Classic frames after the first loss in the realistic mode, unless set otherwise.

const qint64 QcDeviceLossPolicy::repeatWindowMs

A second loss in the realistic mode within this time of the previous one falls back.