Serve game modes from extracted mission data

Publish stable mode IDs and matching responses in the stock format.
Build the mission pools from the multiplayer mission data and provide
required fields and localized names. Load datasets before listening and
reuse cached results when the source file digests match.

Preserve invalid UTF-8 bytes when round-tripping BLK strings and names.
The game mode list appeared in the offline client.
This commit is contained in:
N0VAN0M4LY committed 2026-11-24 11:02:30 +08:00
1 parent 6ed498e4d0
commit 40af06edad
26 files changed
+943 -28

No files matched your search

+3 -4
View File
@@ -11,11 +11,10 @@ import type { BlkValue } from '../model.ts';
import { BlkFormatError } from '../errors.ts';
import { isInline, typeById, typeByName } from '../param-types.ts';
import type { ByteWriter } from './byte-writer.ts';
import { decodeText, encodeText } from './text-bytes.ts';
export const NAME_TABLE_STRING_FLAG = 0x8000_0000;
const utf8Decoder = new TextDecoder('utf-8', { fatal: true });
const utf8Encoder = new TextEncoder();
const bits = new DataView(new ArrayBuffer(4));
export interface DecodeContext {
@@ -68,7 +67,7 @@ export function storesInline(value: BlkValue): boolean {
/** Append a string to the complex-data area; returns its offset. */
export function appendString(complex: ByteWriter, text: string): number {
const encoded = utf8Encoder.encode(text);
const encoded = encodeText(text);
if (encoded.includes(0)) throw new BlkFormatError('a string value cannot contain a NUL character');
const offset = complex.length;
complex.bytes(encoded);
@@ -110,7 +109,7 @@ function decodeString(v: number, { names, complex }: DecodeContext): string {
}
const end = complex.indexOf(0, v);
if (v >= complex.length || end < 0) throw new BlkFormatError(`string at complex offset ${v} is not terminated`);
return utf8Decoder.decode(complex.subarray(v, end));
return decodeText(complex.subarray(v, end));
}
function decodeInline(type: BlkValue['type'], v: number): BlkValue {