ugly-game 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,8 +7,10 @@ export declare class SharedClock {
|
|
|
7
7
|
private pinned;
|
|
8
8
|
constructor(tickMs: number, // ms per tick (e.g. 1000/60)
|
|
9
9
|
now: () => number);
|
|
10
|
-
/** From the server `hello`.
|
|
11
|
-
|
|
10
|
+
/** From the server `hello`. Pass the server's `now` to seed a PROVISIONAL offset so `targetTick()` is roughly
|
|
11
|
+
* right immediately — the window between joining and the first ping/pong returning is exactly when lockstep
|
|
12
|
+
* clients stamp their first commands, and an offset of 0 there desyncs them. A real ping sample overrides it. */
|
|
13
|
+
setEpoch(epoch: number, serverNow?: number): void;
|
|
12
14
|
get hasEpoch(): boolean;
|
|
13
15
|
get epochMs(): number;
|
|
14
16
|
/** Feed a ping round-trip: `sentAt` = local ms we sent, `serverNow` = server ms in the pong. Keeps the sample
|
package/dist/net/sharedClock.js
CHANGED
|
@@ -17,10 +17,14 @@ export class SharedClock {
|
|
|
17
17
|
this.tickMs = tickMs;
|
|
18
18
|
this.now = now;
|
|
19
19
|
}
|
|
20
|
-
/** From the server `hello`.
|
|
21
|
-
|
|
20
|
+
/** From the server `hello`. Pass the server's `now` to seed a PROVISIONAL offset so `targetTick()` is roughly
|
|
21
|
+
* right immediately — the window between joining and the first ping/pong returning is exactly when lockstep
|
|
22
|
+
* clients stamp their first commands, and an offset of 0 there desyncs them. A real ping sample overrides it. */
|
|
23
|
+
setEpoch(epoch, serverNow) {
|
|
22
24
|
this.epoch = epoch;
|
|
23
25
|
this.pinned = true;
|
|
26
|
+
if (serverNow !== undefined && this.bestRtt === Infinity)
|
|
27
|
+
this.offset = serverNow - this.now();
|
|
24
28
|
}
|
|
25
29
|
get hasEpoch() {
|
|
26
30
|
return this.pinned;
|