SOURCE / PINNED RELEASE
Made of little things.
Supersonic RC Revive
- Release
- bb8b570f3600…
- Author-recorded commit
- 073e2d2c0e63…
- License
- LICENSE
- Author’s source reference
- nostr://npub1ye5ptcxfyyxl5vjvdjar2ua3f0hynkjzpx552mu5snj3qmx5pzjscpknpr/wss%3A%2F%2Fgit.shakespeare.diy%2F/SuperSonicRCRevive
Archive hash verified: 857599401cc78951…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import { currentLevelOverlay, currentPackBuffer, fetchPackLink, installLevelOverlay, installPack, isGlb } from './assets.js';
import { assetDescriptor } from './onlineSession.js';
import { mismatch, type Descriptor } from './onlineProtocol.js';
const link = (hash: string, servers: string[] = []) => `blossom:${hash}?${new URLSearchParams(servers.map(s => ['xs', s]))}`;
export const onlineAssetIO = {
descriptor: assetDescriptor,
pack: currentPackBuffer,
level: currentLevelOverlay,
download: fetchPackLink,
installPack,
installLevel: installLevelOverlay,
isGlb,
};
/** Download first, then rebuild atomically; failed or cancelled joins restore the old scene. */
export async function loadHostAssets(target: Descriptor, isActive: () => boolean, reload: () => Promise<void>, io = onlineAssetIO): Promise<Descriptor> {
const local = await io.descriptor();
if (!isActive()) throw new Error('Joining cancelled.');
if (local.physics !== target.physics) throw new Error('Game versions differ. Open the same game release as the host.');
const previousPack = io.pack(), previousLevel = io.level();
const [pack, level] = await Promise.all([
local.pack === target.pack ? Promise.resolve(previousPack) : io.download(link(target.pack, target.packServers)),
target.level === null ? Promise.resolve(null)
: local.level === target.level ? Promise.resolve(previousLevel) : io.download(link(target.level, target.levelServers)),
]);
if (!isActive()) throw new Error('Joining cancelled.');
if (!pack || io.isGlb(pack)) throw new Error('The host’s asset pack is not an .ssrcpack file.');
if (level && !io.isGlb(level)) throw new Error('The host’s custom level is not a .glb file.');
let installed = false;
try {
if (pack !== previousPack) { io.installPack(pack); installed = true; }
io.installLevel(level);
installed = true;
const actual = await io.descriptor();
const reason = mismatch(target, actual);
if (reason) throw new Error('The downloaded game data does not match the host’s hashes.');
if (!isActive()) throw new Error('Joining cancelled.');
await reload();
if (!isActive()) throw new Error('Joining cancelled.');
return actual;
} catch (error) {
// A separate asset switch owns its own scene; do not overwrite it on cancellation.
if (installed && io.pack() === pack && (io.level() === level || io.level() === null)) {
if (previousPack) io.installPack(previousPack);
io.installLevel(previousLevel);
await reload();
}
throw error;
}
}
