MiniQuake2

src/miniquake2/client/state.ml

Provides miniquake2 client state facilities for this project.

Package
miniquake2.client.state
Reachable
Yes

Imports

Declarations

acceptPrediction

function acceptPrediction(client, fixedOrigin, angles)

Accept prediction.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
fixedOrigindynamic—fixedOrigin value consumed by this operation.
anglesdynamic—angles value consumed by this operation.

View source

acceptSnapshot

function acceptSnapshot(client, frame)

Accept snapshot.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
framedynamic—frame value consumed by this operation.

View source

animatedFrame

inline function animatedFrame(state, effects, renderTime)

Return the animated frame value.

ParameterTypeDefaultDescription
statedynamic—Mutable state inspected or updated by the operation.
effectsdynamic—effects value consumed by this operation.
renderTimedynamic—renderTime value consumed by this operation.

View source

appendColorShell

function appendColorShell(output, outputIndex, state, oldState, fraction, renderTime, assetResolvers, lerpReset)

Append color shell.

ParameterTypeDefaultDescription
outputdynamic—Output collection or buffer populated by the operation.
outputIndexdynamic—Zero-based index of output.
statedynamic—Mutable state inspected or updated by the operation.
oldStatedynamic—oldState value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
renderTimedynamic—renderTime value consumed by this operation.
assetResolversdynamic—assetResolvers value consumed by this operation.
lerpResetdynamic—lerpReset value consumed by this operation.

View source

appendModelEntity

function appendModelEntity(output, outputIndex, state, oldState, modelIndex, part, fraction, renderTime, assetResolvers, randomResolver, lerpReset)

Append model entity.

ParameterTypeDefaultDescription
outputdynamic—Output collection or buffer populated by the operation.
outputIndexdynamic—Zero-based index of output.
statedynamic—Mutable state inspected or updated by the operation.
oldStatedynamic—oldState value consumed by this operation.
modelIndexdynamic—Zero-based index of model.
partdynamic—part value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
renderTimedynamic—renderTime value consumed by this operation.
assetResolversdynamic—assetResolvers value consumed by this operation.
randomResolverdynamic—randomResolver value consumed by this operation.
lerpResetdynamic—lerpReset value consumed by this operation.

View source

appendPowerScreen

function appendPowerScreen(output, outputIndex, state, oldState, fraction, renderTime, assetResolvers, lerpReset)

Append power screen.

ParameterTypeDefaultDescription
outputdynamic—Output collection or buffer populated by the operation.
outputIndexdynamic—Zero-based index of output.
statedynamic—Mutable state inspected or updated by the operation.
oldStatedynamic—oldState value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
renderTimedynamic—renderTime value consumed by this operation.
assetResolversdynamic—assetResolvers value consumed by this operation.
lerpResetdynamic—lerpReset value consumed by this operation.

View source

appendViewWeapon

function appendViewWeapon(output, outputIndex, client, fraction, assetResolvers, viewOrigin, viewAngles)

Append view weapon.

ParameterTypeDefaultDescription
outputdynamic—Output collection or buffer populated by the operation.
outputIndexdynamic—Zero-based index of output.
clientdynamic—client value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
assetResolversdynamic—assetResolvers value consumed by this operation.
viewOrigindynamic—viewOrigin value consumed by this operation.
viewAnglesdynamic—viewAngles value consumed by this operation.

View source

buildEntities

function buildEntities(client, fraction, assetResolvers, localEntityNumber, randomResolver, viewOrigin, viewAngles)

Build entities.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
assetResolversdynamic—assetResolvers value consumed by this operation.
localEntityNumberdynamic—localEntityNumber value consumed by this operation.
randomResolverdynamic—randomResolver value consumed by this operation.
viewOrigindynamic—viewOrigin value consumed by this operation.
viewAnglesdynamic—viewAngles value consumed by this operation.

View source

buildPredictedRefDef

function buildPredictedRefDef(client, fraction, width, height, assetResolvers, localEntityNumber, randomResolver)

Build predicted ref def.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
widthdynamic—Width in the coordinate or storage units used by the caller.
heightdynamic—Height in the coordinate or storage units used by the caller.
assetResolversdynamic—assetResolvers value consumed by this operation.
localEntityNumberdynamic—localEntityNumber value consumed by this operation.
randomResolverdynamic—randomResolver value consumed by this operation.

View source

buildPredictedRefDefWithOffset

function buildPredictedRefDefWithOffset(client, fraction, width, height, assetResolvers, localEntityNumber, randomResolver, predictionOffset)

Build a predicted refdef while matching a locally ridden pusher's visual interpolation. The offset is deliberately explicit so ordinary movement prediction, demos and renderer captures cannot accidentally inherit it.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
widthdynamic—Width in the coordinate or storage units used by the caller.
heightdynamic—Height in the coordinate or storage units used by the caller.
assetResolversdynamic—assetResolvers value consumed by this operation.
localEntityNumberdynamic—localEntityNumber value consumed by this operation.
randomResolverdynamic—randomResolver value consumed by this operation.
predictionOffsetdynamic—predictionOffset value consumed by this operation.

View source

buildRefDef

function buildRefDef(client, fraction, width, height, assetResolvers, localEntityNumber, randomResolver)

Demos and deterministic renderer captures intentionally retain pure server interpolation. The live product uses the explicit predicted entry point.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
widthdynamic—Width in the coordinate or storage units used by the caller.
heightdynamic—Height in the coordinate or storage units used by the caller.
assetResolversdynamic—assetResolvers value consumed by this operation.
localEntityNumberdynamic—localEntityNumber value consumed by this operation.
randomResolverdynamic—randomResolver value consumed by this operation.

View source

buildRefDefInternal

function buildRefDefInternal(client, fraction, width, height, assetResolvers, localEntityNumber, randomResolver, usePrediction, predictionOffset)

Build ref def internal.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
widthdynamic—Width in the coordinate or storage units used by the caller.
heightdynamic—Height in the coordinate or storage units used by the caller.
assetResolversdynamic—assetResolvers value consumed by this operation.
localEntityNumberdynamic—localEntityNumber value consumed by this operation.
randomResolverdynamic—randomResolver value consumed by this operation.
usePredictiondynamic—usePrediction value consumed by this operation.
predictionOffsetdynamic—predictionOffset value consumed by this operation.

View source

clampFraction

inline function clampFraction(value)

Clamp fraction.

ParameterTypeDefaultDescription
valuedynamic—Value consumed or transformed by the operation.

View source

clearPrediction

function clearPrediction(client)

Clear prediction.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.

View source

miniquake2.client.state.ClientRuntime struct

create

function create()

Creates create for the miniquake2 client state module.

View source

currentEntity

inline function currentEntity(client, number)

Return the current entity value.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
numberdynamic—number value consumed by this operation.

View source

disguiseFamily

inline function disguiseFamily(skin)

Return the disguise family value.

ParameterTypeDefaultDescription
skindynamic—skin value consumed by this operation.

View source

effectiveEffects

inline function effectiveEffects(state)

Return the effective effects value.

ParameterTypeDefaultDescription
statedynamic—Mutable state inspected or updated by the operation.

View source

effectiveRenderFx

inline function effectiveRenderFx(state)

Render effective fx.

ParameterTypeDefaultDescription
statedynamic—Mutable state inspected or updated by the operation.

View source

entityRenderAngles

inline function entityRenderAngles(oldState, state, fraction, reset)

Render entity angles.

ParameterTypeDefaultDescription
oldStatedynamic—oldState value consumed by this operation.
statedynamic—Mutable state inspected or updated by the operation.
fractiondynamic—fraction value consumed by this operation.
resetdynamic—reset value consumed by this operation.

View source

entityRenderOrigin

inline function entityRenderOrigin(oldState, state, fraction, reset)

Render entity origin.

ParameterTypeDefaultDescription
oldStatedynamic—oldState value consumed by this operation.
statedynamic—Mutable state inspected or updated by the operation.
fractiondynamic—fraction value consumed by this operation.
resetdynamic—reset value consumed by this operation.

View source

entityRequiresLerpReset

inline function entityRequiresLerpReset(oldState, state)

CL_DeltaEntity deliberately breaks interpolation when an entity changes model, moves more than 512 units between server frames, or reports either teleport event. Particle trails already observe this rule; the render handoff must use the same predecessor or models visibly sweep through the world after teleports and model replacements.

ParameterTypeDefaultDescription
oldStatedynamic—oldState value consumed by this operation.
statedynamic—Mutable state inspected or updated by the operation.

View source

findEntity

function findEntity(entities, number)

Find entity.

ParameterTypeDefaultDescription
entitiesdynamic—entities value consumed by this operation.
numberdynamic—number value consumed by this operation.

View source

interpolatedAngles

function interpolatedAngles(oldState, currentState, fraction)

Return the interpolated angles.

ParameterTypeDefaultDescription
oldStatedynamic—oldState value consumed by this operation.
currentStatedynamic—currentState value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.

View source

interpolatedOrigin

function interpolatedOrigin(oldState, currentState, fraction)

Return the interpolated origin.

ParameterTypeDefaultDescription
oldStatedynamic—oldState value consumed by this operation.
currentStatedynamic—currentState value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.

View source

interpolationPlayer

function interpolationPlayer(client)

Return the interpolation player value.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.

View source

lastKnownEntity

inline function lastKnownEntity(client, number)

Return the last entity state published during this map epoch. Effects such as muzzle flashes may arrive in a packet whose snapshot omits an otherwise unchanged source entity, matching cl_entities[number].current in stock.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
numberdynamic—number value consumed by this operation.

View source

lerp

inline function lerp(first, second, fraction)

Return the lerp value.

ParameterTypeDefaultDescription
firstdynamic—first value consumed by this operation.
seconddynamic—second value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.

View source

lerpAngle

inline function lerpAngle(first, second, fraction)

Quake II angles wrap at 360 degrees. A scalar interpolation would spin the long way around when a snapshot crosses north (for example 359 -> 1).

ParameterTypeDefaultDescription
firstdynamic—first value consumed by this operation.
seconddynamic—second value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.

View source

notePredictionStep

function notePredictionStep(client, previousFixedOrigin, currentFixedOrigin, flags, frameMsec)

CL_PredictMovement recognizes one ordinary stair riser in fixed-point Pmove coordinates (8..20 world units) and records a half-frame-adjusted start time. CL_CalcViewValues then removes that vertical discontinuity over the next 100 ms instead of snapping the camera upward.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
previousFixedOrigindynamic—previousFixedOrigin value consumed by this operation.
currentFixedOrigindynamic—currentFixedOrigin value consumed by this operation.
flagsdynamic—Bit flags controlling the operation.
frameMsecdynamic—frameMsec value consumed by this operation.

View source

renderAngles

function renderAngles(oldState, state, effects, fraction, renderTime, lerpReset)

Render angles.

ParameterTypeDefaultDescription
oldStatedynamic—oldState value consumed by this operation.
statedynamic—Mutable state inspected or updated by the operation.
effectsdynamic—effects value consumed by this operation.
fractiondynamic—fraction value consumed by this operation.
renderTimedynamic—renderTime value consumed by this operation.
lerpResetdynamic—lerpReset value consumed by this operation.

View source

runLightStyles

function runLightStyles(client, renderTime)

Run light styles.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
renderTimedynamic—renderTime value consumed by this operation.

View source

setConnectionState

function setConnectionState(client, state)

Set connection state.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
statedynamic—Mutable state inspected or updated by the operation.

View source

setLightStyle

function setLightStyle(client, index, pattern)

CL_SetLightstyle decodes CS_LIGHTS strings lazily at their 10 Hz playback rate. Keeping the compact source string avoids a second 256 x MAX_QPATH float table and is cheaper than rebuilding every style on every render.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
indexdynamic—Zero-based index of the affected item.
patterndynamic—pattern value consumed by this operation.

View source

setPredictionRealTime

function setPredictionRealTime(client, now)

Set prediction real time.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
nowdynamic—now value consumed by this operation.

View source

setPredictionStepSuppressed

function setPredictionStepSuppressed(client, value)

Tell the stair smoother whether local prediction is currently carried by a moving brush. A lift's regular vertical displacement falls inside the ordinary 8..20-unit stair range, but smoothing it as a stair every server frame makes the camera repeatedly ease downward and visibly hop upward. The application derives this flag from Player.groundEntity before it replays prediction; the underlying movement state remains authoritative.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
valuedynamic—Value consumed or transformed by the operation.

View source

stateModelCount

inline function stateModelCount(state)

Return the state model count.

ParameterTypeDefaultDescription
statedynamic—Mutable state inspected or updated by the operation.

View source

updatePredictionError

function updatePredictionError(client, predictedFixedOrigin)

Update prediction error.

ParameterTypeDefaultDescription
clientdynamic—client value consumed by this operation.
predictedFixedOrigindynamic—predictedFixedOrigin value consumed by this operation.

View source