mirror of
https://github.com/bdnugget/rs-sdk.git
synced 2026-11-07 09:07:30 +00:00
Track sdk/collision-data.json again; add refresh script
716a9375f removed collision-data.json from tracking and gitignored it as
"regenerable", but sdk/pathfinding.ts imports it statically -- so a fresh
clone hard-failed on import with no way to know why. Nothing fetched it.
Re-track it. The anti-bloat rationale was already sunk cost: that commit
never rewrote history, so all 12 prior collision-data blobs remain reachable
and every clone already pays for them. One more version costs ~3.4MB packed
(23MB raw, but it's highly repetitive), against a 259MB .git.
Add sdk/fetch-collision-data.ts to regenerate it from a running server,
replacing the bare curl in DEVELOPERS.md -- it buffers before writing so an
interrupted download can't leave a truncated file that breaks the import,
and needs --force to clobber. The committed copy is a fresh export: 123,648
zones (= 483 mapsquares, full coverage), 1,068,791 tiles, 2,603 doors.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
180b4001d8
commit
3bdb46329b
5 files changed
+65
-5
No files matched your search
@@ -12,9 +12,6 @@ server.json
|
||||
backups/
|
||||
.obsidian/
|
||||
|
||||
# Regenerable: curl https://rs-sdk-demo.fly.dev/api/exportCollision > sdk/collision-data.json
|
||||
sdk/collision-data.json
|
||||
|
||||
# Bot folders (except template)
|
||||
bots/*/
|
||||
!bots/_template/
|
||||
|
||||
+8
-2
@@ -112,10 +112,16 @@ directly from `webclient/out`.
|
||||
|
||||
### Collision data (`sdk/collision-data.json`)
|
||||
|
||||
Used by `sdk/pathfinding.ts` and not tracked in git. Regenerate it from a running server:
|
||||
Used by `sdk/pathfinding.ts`, which imports it directly. It's ~23MB but compresses
|
||||
to ~3.4MB in git, so it's tracked — a clone works without any fetch step.
|
||||
|
||||
Regenerate it after map changes, or pull from a different server:
|
||||
```sh
|
||||
curl https://rs-sdk-demo.fly.dev/api/exportCollision > sdk/collision-data.json
|
||||
bun run fetch-collision-data -- --force
|
||||
bun run fetch-collision-data -- --force --server=http://localhost:8080
|
||||
```
|
||||
The server can also be set with `COLLISION_SERVER`. **Commit the result** — a stale
|
||||
tracked copy is how the 442-vs-483 mapsquare drift crept in previously.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"name": "server",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"fetch-collision-data": "bun sdk/fetch-collision-data.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"puppeteer": "^24.0.0"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"tiles":[[0,2560,3520,2097152],[0,2560,3521,2097152],[0,2560,3522,2097152],[0,2560,3523,2097152],[0,2560,3524,2097152],[0,2560,3525,2097152],[0,2560,3526,2097152],[0,2560,3527,2097152],[0,2561,3520,2097152],[0,2561,3521,2097152],[0,2561,3522,2097152],[0,2561,3523,2097152],[0,2561,3524,2097152],[0,2561,3525,2097152],[0,2561,3526,2097152],[0,2561,3527,2097152],[0,2562,3520,2097152],[0,2562,3521,2097152],[0,2562,3522,2097152],[0,2562,3523,2097152],[0,2562,3524,2097152],[0,2562,3525,2097152],[0,2562,3526,2097152],[0,2562,3527,2097152],[0,2563,3520,2097152],[0,2563,3521,2097152],[0,2563,3522,2097152],[0,2563,3523,2097152],[0,2563,3524,2097152],[0,2563,3525,2097152],[0,2563,3526,2097152],[0,2563,3527,2097152],[0,2564,3520,2097152],[0,2564,3521,2097152],[0,2564,3522,2097152],[0,2564,3523,2097152],[0,2564,3524,2097152],[0,2564,3525,2097152],[0,2564,3526,2097152],[0,2564,3527,2097152],[0,2565,3520,2097152],[0,2565,3521,2097152],[0,2565,3522,2097152],[0,2565,3523,2097152],[0,2565,3524,2097152],[0,2565,3525,2097152],[0,2565,3526,2097152],[0,2565,3527,2097152],[0,2566,3520,2097152],[0,2566,3521,2097152],[0,2566,3522,2097152],[0,2566,3523,2097152],[0,2566,3524,2097152],[0,2566,3525,2097152],[0,2566,3526,2097152],[0,2566,3527,2097152],[0,2567,3520,2097152],[0,2567,3521,2097152],[0,2567,3522,2097152],[0,2567,3523,2097152],[0,2567,3524,2097152],[0,2567,3525,2097152],[0,2567,3526,2097152],[0,2567,3527,2097152],[0,2560,3528,2097152],[0,2560,3529,2097152],[0,2560,3530,2097152],[0,2560,3531,2097152],[0,2560,3532,2097152],[0,2560,3533,2097152],[0,2560,3534,2097152],[0,2560,3535,2097152],[0,2561,3528,2097152],[0,2561,3529,2097152],[0,2561,3530,2097152],[0,2561,3531,2097152],[0,2561,3532,2097152],[0,2561,3533,2097152],[0,2561,3534,2097152],[0,2561,3535,2097152],[0,2562,3528,2097152],[0,2562,3529,2097152],[0,2562,3530,2097152],[0,2562,3531,2097152],[0,2562,3532,2097152],[0,2562,3533,2097152],[0,2562,3534,2097152],[0,2562,3535,2097152],[0,2563,3528,2097152],[0,2563,3529,2097152],[0,2563,3530,2097152],[0,2563,3531,2097152],[0,2563,3532,2097152],[0,2563,3533,2097152],[0,2563,3534,2097152],[0,2563,3535,2097152],[0,2564,3528,2097152],[0,2564,3529,2097152],[0,2564,3530,2097152],[0,2564,3531,2097152],[0,2564,3532,2097152],[0,2564,3533,2097152],[0,2564,3534,2097152],[0,2564,3535,2097152],[0,2565,3528,2097152],[0,2565,3529,2097152],[0,2565,3530,2097152],[0,2565,3531,2097152],[0,2565,3532,2097152],[0,2565,3533,2097152],[0,2565,3534,2097152],[0,2565,3535,2097152],[0,2566,3528,2097152],[0,2566,3529,2097152],[0,2566,3530,2097152],[0,2566,3531,2097152],[0,2566,3532,2097152],[0,2566,3533,2097152],[0,2566,3534,2097152],[0,2566,3535,2097152],[0,2567,3528,2097152],[0,2567,3529,2097152],[0,2567,3530,2097152],[0,2567,3531,2097152],[0,2567,3532,2097152],[0,2567,3533,2097152],[0,2567,3534,2097152],[0,2567,3535,2097152],[0,2560,3536,2097152],[0,2560,3537,2097152],[0,2560,3538,2097152],[0,2560,3539,2097152],[0,2560,3540,2097152],[0,2560,3541,2097152],[0,2560,3542,2097152],[0,2560,3543,2097152],[0,2561,3536,2097152],[0,2561,3537,2097152],[0,2561,3538,2097152],[0,2561,3539,2097152],[0,2561,3540,2097152],[0,2561,3541,2097152],[0,2561,3542,2097152],[0,2561,3543,2097152],[0,2562,3536,2097152],[0,2562,3537,2097152],[0,2562,3538,2097152],[0,2562,3539,2097152],[0,2562,3540,2097152],[0,2562,3541,2097152],[0,2562,3542,2097152],[0,2562,3543,2097152],[0,2563,3536,2097152],[0,2563,3537,2097152],[0,2563,3538,2097152],[0,2563,3539,2097152],[0,2563,3540,2097152],[0,2563,3541,2097152],[0,2563,3542,2097152],[0,2563,3543,2097152],[0,2564,3536,2097152],[0,2564,3537,2097152],[0,2564,3538,2097152],[0,2564,3539,2097152],[0,2564,3540,2097152],[0,2564,3541,2097152],[0,2564,3542,2097152],[0,2564,3543,2097152],[0,2565,3536,2097152],[0,2565,3537,2097152],[0,2565,3538,2097152],[0,2565,3539,2097152],[0,2565,3540,2097152],[0,2565,3541,2097152],[0,2565,3542,2097152],[0,2565,3543,2097152],[0,2566,3536,2097152],[0,2566,3537,2097152],[0,2566,3538,2097152],[0,2566,3539,2097152],[0,2566,3540,2097152],[0,2566,3541,2097152],[0,2566,3542,2097152],[0,2566,3543,2097152],[0,2567,3536,2097152],[0,2567,3537,2097152],[0,2567,3538,2097152],[0,2567,3539,2097152],[0,2567,3540,2097152],[0,2567,3541,2097152],[0,2567,3542,2097152],[0,2567,3543,2097152],[0,2560,3544,2097152],[0,2560,3545,2097152],[0,2560,3546,2097152],[0,2560,3547,2097152],[0,2560,3548,2097152],[0,2560,3549,2097152],[0,2560,3550,2097152],[0,2560,3551,2097152],[0,2561,3544,2097152],[0,2561,3545,2097152],[0,2561,3546,2097152],[0,2561,3547,2097152],[0,2561,3548,2097152],[0,2561,3549,2097152],[0,2561,3550,2097152],[0,2561,3551,2097152],[0,2562,3544,2097152],[0,2562,3545,2097152],[0,2562,3546,2097152],[0,2562,3547,2097152],[0,2562,3548,2097152],[0,2562,3549,2097152],[0,2562,3550,2097152],[0,2562,3551,2097152],[0,2563,3544,2097152],[0,2563,3545,2097152],[0,2563,3546,2097152],[0,2563,3547,2097152],[0,2563,3548,2097152],[0,2563,3549,2097152],[0,2563,3550,2097152],[0,2563,3551,2097152],[0,2564,3544,2097152],[0,2564,3545,2097152],[0,2564,3546,2097Line truncated
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bun
|
||||
// Refreshes sdk/collision-data.json, which sdk/pathfinding.ts imports directly.
|
||||
// The file IS tracked in git, so a clone already has a working copy — this script
|
||||
// is for regenerating it after map changes, or pulling from a non-default server.
|
||||
// Commit the result: a stale tracked copy is how 442-vs-483 mapsquare drift crept
|
||||
// in before. Requires --force to overwrite an existing file.
|
||||
import { existsSync, statSync } from 'fs';
|
||||
import { writeFile } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
|
||||
const DEFAULT_SERVER = 'https://rs-sdk-demo.fly.dev';
|
||||
const OUTPUT_PATH = join(import.meta.dir, 'collision-data.json');
|
||||
|
||||
async function fetchCollisionData(server: string, force: boolean) {
|
||||
if (existsSync(OUTPUT_PATH) && !force) {
|
||||
const mb = (statSync(OUTPUT_PATH).size / 1_000_000).toFixed(1);
|
||||
console.log(`collision-data.json already present (${mb}MB) - skipping. Use --force to refresh.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const url = `${server}/api/exportCollision`;
|
||||
console.log(`Fetching collision data from ${url} ...`);
|
||||
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`${url} returned ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
// Buffer fully before writing so an interrupted download can't leave a
|
||||
// truncated file behind — pathfinding.ts would fail to parse it on import.
|
||||
const body = await response.arrayBuffer();
|
||||
if (body.byteLength === 0) {
|
||||
throw new Error(`${url} returned an empty body`);
|
||||
}
|
||||
|
||||
await writeFile(OUTPUT_PATH, new Uint8Array(body));
|
||||
const mb = (body.byteLength / 1_000_000).toFixed(1);
|
||||
console.log(`Wrote ${OUTPUT_PATH} (${mb}MB)`);
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const force = args.includes('--force');
|
||||
const serverArg = args.find(a => a.startsWith('--server='))?.split('=')[1];
|
||||
const server = serverArg || process.env.COLLISION_SERVER || DEFAULT_SERVER;
|
||||
|
||||
try {
|
||||
await fetchCollisionData(server, force);
|
||||
} catch (e) {
|
||||
console.error(`\nFailed to fetch collision data: ${e instanceof Error ? e.message : e}`);
|
||||
console.error('Pathfinding (sdk/pathfinding.ts) will not work until this file exists.');
|
||||
console.error(`Retry with: bun sdk/fetch-collision-data.ts --force --server=${server}`);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in new issue
Block a user