Table of Contents

Class WorldClockControlEntity

Namespace
FishMMO.Database.Npgsql.Entities
Assembly
FishMMO-DB.dll

The one world clock: a single row (ID = 1) that every scene server adopts on its next pulse and that admins write, in game (/admin time) or from the Control Panel.

public class WorldClockControlEntity
Inheritance
WorldClockControlEntity
Inherited Members

Remarks

World time is "world milliseconds since the calendar epoch", and it is never stored as a running value. The row is an anchor: at database time BaseReferenceMs the world read BaseWorldMs, and it has advanced at Rate world seconds per real second since. World ms now = base_world_ms + rate × (db_now_ms − base_reference_ms), computed in SQL against the database clock, so every reader agrees on it whatever its own clock says. See WorldClockControlService.

Every write re-anchors at the moment it is made and bumps Revision. A scene server that reads a new revision treats it as an instant jump rather than smoothing towards it — that is what an admin setting the time asked for.

No xmin token: every write is one raw UPDATE … RETURNING that computes from the row it locks, so there is no read-modify-write for a token to protect.

Properties

BaseReferenceMs

The DATABASE clock, in Unix milliseconds, when BaseWorldMs was written.

public long BaseReferenceMs { get; set; }

Property Value

long

BaseWorldMs

World milliseconds since the calendar epoch at BaseReferenceMs.

public long BaseWorldMs { get; set; }

Property Value

long

EpochUnixSeconds

The calendar epoch the scene servers use, in Unix seconds. Stored so a reader without the Unity calendar asset (the Control Panel) can write and read world timestamps.

public long EpochUnixSeconds { get; set; }

Property Value

long

ID

Always 1. A check constraint keeps it the only row.

public int ID { get; set; }

Property Value

int

Rate

World seconds per real second: 0 held, 1 real time, above 1 raced.

public double Rate { get; set; }

Property Value

double

RequestKey

The idempotency key of the last write. A retried write whose first attempt committed but lost its reply finds its own key here and is not applied twice — which matters for a relative shift, where a second application would move the world twice as far.

public Guid? RequestKey { get; set; }

Property Value

Guid?

ResumeRate

The pace a resume returns to. Always above zero.

public double ResumeRate { get; set; }

Property Value

double

Revision

Incremented on every write.

public long Revision { get; set; }

Property Value

long

UpdatedAt

UTC time of the last write, by the database clock.

public DateTime? UpdatedAt { get; set; }

Property Value

DateTime?

UpdatedBy

Account that made the last write, or null for the seed.

public string? UpdatedBy { get; set; }

Property Value

string