A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(gate): the arena check runs its clients at the rate the server does
esengine9652454ae874
diff --git a/tools/check-arena-server.mjs b/tools/check-arena-server.mjsindex 6603572d3..398cad70f 100644--- a/tools/check-arena-server.mjs+++ b/tools/check-arena-server.mjs@@ -178,12 +178,27 @@ function ghosts(app) {}));}-/** Tick both apps for `seconds` of simulated time, letting the socket breathe. */+/**+ * Tick both apps for `seconds` of simulated time, at the rate the authority runs+ * at. The server is a real 60Hz process: a client that outpaces it overruns the+ * input window and has its commands refused, which reads as "replication is+ * behind" while the client's own prediction sits at the wall.+ */async function run(apps, seconds) {for (let i = 0; i < Math.round(seconds / STEP); i++) {for (const app of apps) await app.tick(STEP);- await delay(4);+ await delay(STEP * 1000);+ }+}++/** Run until `done()`, or fail once `seconds` of simulated time have passed. */+async function runUntil(apps, seconds, done) {+ for (let i = 0; i < Math.round(seconds / STEP); i++) {+ if (done()) return true;+ for (const app of apps) await app.tick(STEP);+ await delay(STEP * 1000);}+ return done();}let player, spectator;@@ -232,9 +247,12 @@ if (Math.abs(wallX - BOUND_X) > 0.5) {// 4 — a third party saw it happen. The spectator runs no gameplay code at all,// so this position can only have arrived as replicated state.-await run([player.app, spectator.app], 0.3);-const witnessed = ghosts(spectator.app).map((g) => g.x);-if (!witnessed.some((x) => Math.abs(x - BOUND_X) < 40)) {+// Waiting for the state to ARRIVE rather than for a fixed duration: how many+// ticks a socket round trip takes is a property of the machine, and a deadline+// dressed up as a duration fails on a slow one while asserting nothing more.+const sawWall = () => ghosts(spectator.app).some((g) => Math.abs(g.x - BOUND_X) < 40);+if (!await runUntil([player.app, spectator.app], 1.0, sawWall)) {+ const witnessed = ghosts(spectator.app).map((g) => g.x);fail(`the spectator never saw the moving pawn reach the wall (saw x=${witnessed.join(', ')}).`, serverLog);}diff --git a/tools/check-sdk-test-types.mjs b/tools/check-sdk-test-types.mjsindex 0d66333b3..3fc6f6822 100644--- a/tools/check-sdk-test-types.mjs+++ b/tools/check-sdk-test-types.mjs@@ -62,11 +62,9 @@ if (run.status !== 0 && !/error TS\d+/.test(output)) {const ROOT_POSIX = ROOT.split(path.sep).join('/');/**- * The checkout's own location, out of the message text. TS7016 and friends name- * the resolved module by ABSOLUTE path, so an identity built from the raw- * message is per-machine: a baseline banked on one checkout reported three- * phantom "new" diagnostics on every other one, including CI, where the same- * three were already banked under a different prefix.+ * The checkout's own location, out of the message text. TS7016 names the+ * resolved module by ABSOLUTE path, so a raw-message identity is per-machine and+ * a baseline banked on one checkout reads as new diagnostics on every other.*/const unroot = (msg) => msg.split(`${ROOT_POSIX}/`).join('').split(ROOT_POSIX).join('');diff --git a/tools/mutation-census.mjs b/tools/mutation-census.mjsindex 4cef0f90b..038b8db5a 100644--- a/tools/mutation-census.mjs+++ b/tools/mutation-census.mjs@@ -225,13 +225,10 @@ function scanFile(rel, text) {const written = new Set();/**- * Whether the handle rooted at `node` is handed back to the World in the- * same scope — `world.set(e, C, h)` / `insert` / an explicit `markChanged`.- *- * This is the distinction the whole census turns on. Read-modify-write-back- * is a LEGAL idiom today and reports normally; the same two lines without- * the third are the silent write. Counting them together would price the- * migration at every mutation in the repo rather than at the broken ones.+ * Whether the handle rooted at `node` is handed back to the World in the same+ * scope. The distinction the census turns on: read-modify-write-back is legal+ * today and reports normally, the same edit without the write-back is the+ * silent write, and counting them together misprices the migration.*/const storesBack = (node) => {const r = accessRoot(node);diff --git a/tools/mutation-contract.mjs b/tools/mutation-contract.mjsindex 7daaf0cf7..cf7273203 100644--- a/tools/mutation-contract.mjs+++ b/tools/mutation-contract.mjs@@ -84,13 +84,10 @@ function snapshot(world, entity, component) {}/**- * One access path against a fresh world.- *- * `make` builds the component and its initial value, so a row can choose the- * storage it needs: an all-scalar script shape is pooled into the wasm heap, a- * shape with a nested object is a plain JS object, and a builtin lives in C++.- * Those are three different objects to hand a caller, and the whole question is- * whether they behave the same.+ * One access path against a fresh world. `kind` picks the storage: an all-scalar+ * script shape is pooled into the wasm heap, a nested one is a plain JS object,+ * a builtin lives in C++. Three different objects to hand a caller, and the+ * question is whether they behave the same.*/async function probe({ name, kind, expect, defect = false, cpp = false, body }) {const app = sdk.App.new();