fix(server): persist squadrons and align inventory wire formats

Read squadron action parameters from the request headers and persist
squadron state on profile refresh. Use floating-point trophy weights
to match the client probability display and assign unique log IDs
when opening multiple chests.

Tighten shop, marketplace, squadron, and cloud settings validation.
Move PBBD and inventory encoding into the protocol modules and share
CSV reading. Update the research and acceptance instructions.

Type checking and all eight executable patch checks passed.
In-game acceptance is pending.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 09:10:09 +08:00
1 parent b68f321b84
commit 29e5cf2bd8
40 files changed
+1347 -1248

No files matched your search

@@ -5,23 +5,19 @@
* game's own English and Chinese vehicle names without shipping game text with the service.
*/
import type { Dataset } from './dataset.ts';
import { cleanLangText, parseSemicolonCsvRow, type LocalizedCsvText } from './lang-csv.ts';
const UNITS_CSV = 'lang/units.csv';
export interface LocalizedText {
readonly en: string;
readonly zh: string;
}
export type LocalizedText = LocalizedCsvText;
export type UnitNamesMap = Readonly<Record<string, LocalizedText>>;
export const unitNames: Dataset<UnitNamesMap> = {
id: 'unit-names',
version: 1,
extract: (source) => {
const csv = source.readText('lang.vromfs.bin', UNITS_CSV);
const lines = csv.split(/\r?\n/);
const header = parseCsvRow(lines[0] ?? '');
const lines = source.readText('lang.vromfs.bin', UNITS_CSV).split(/\r?\n/);
const header = parseSemicolonCsvRow(lines[0] ?? '');
const enCol = Math.max(1, header.indexOf('<English>'));
const zhCol = header.indexOf('<Chinese>');
const hzhCol = header.indexOf('<HChinese>');
@@ -38,10 +34,10 @@ export const unitNames: Dataset<UnitNamesMap> = {
const isFull = !isShop && key.endsWith('_0');
if (!isShop && !isFull) continue;
const cols = parseCsvRow(line);
const en = cleanText(cols[enCol] ?? '');
const cols = parseSemicolonCsvRow(line);
const en = cleanLangText(cols[enCol] ?? '');
if (!en) continue;
const zh = cleanText((hzhCol >= 0 ? cols[hzhCol] : '') || (zhCol >= 0 ? cols[zhCol] : '') || en);
const zh = cleanLangText((hzhCol >= 0 ? cols[hzhCol] : '') || (zhCol >= 0 ? cols[zhCol] : '') || en);
const unitId = key.slice(0, isShop ? -5 : -2);
if (isShop) shopNames.set(unitId, { en, zh });
else fullNames.set(unitId, { en, zh });
@@ -53,44 +49,3 @@ export const unitNames: Dataset<UnitNamesMap> = {
return result;
},
};
function parseCsvRow(line: string): string[] {
const fields: string[] = [];
let i = 0;
while (i < line.length) {
if (line[i] === '"') {
i++;
let value = '';
while (i < line.length) {
if (line[i] === '"') {
if (line[i + 1] === '"') {
value += '"';
i += 2;
} else {
i++;
break;
}
} else {
value += line[i]!;
i++;
}
}
fields.push(value);
if (line[i] === ';') i++;
} else {
const next = line.indexOf(';', i);
if (next < 0) {
fields.push(line.slice(i));
break;
}
fields.push(line.slice(i, next));
i = next + 1;
}
}
return fields;
}
function cleanText(raw: string): string {
// Strip zero-width word-break spaces Gaijin inserts into CJK localization strings.
return raw.replace(/\u200b/g, '').trim();
}