Fix squadron persistence 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:
1 parent
0b604c76f1
commit
8012cf7954
40 files changed
+1347
-1248
No files matched your search
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Dataset: squadron creation, edit, member-limit upgrade, and battalion-to-normal upgrade
|
||||
* prices from char.vromfs.bin config/warpoints.blk (implementation notes; scripts/clans/clanType.nut).
|
||||
* Dataset: squadron creation, edit, member-limit upgrade, battalion-to-normal upgrade prices,
|
||||
* and free tag decorators from char.vromfs.bin config/warpoints.blk (implementation notes;
|
||||
* aces.exe 0x906fe0..0x907070; scripts/clans/clanType.nut).
|
||||
*/
|
||||
import { findBlock, type BlkBlock } from '@wto/blk';
|
||||
import { numberField } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
|
||||
@@ -10,34 +12,58 @@ const WARPOINTS = 'config/warpoints.blk';
|
||||
export interface ClanEconomy {
|
||||
readonly normalCreateGold: number;
|
||||
readonly normalCreateSilver: number;
|
||||
readonly normalPrimaryEditGold: number;
|
||||
readonly normalPrimaryEditSilver: number;
|
||||
readonly normalSecondaryEditGold: number;
|
||||
readonly normalSecondaryEditSilver: number;
|
||||
readonly battalionCreateGold: number;
|
||||
readonly battalionCreateSilver: number;
|
||||
readonly battalionPrimaryEditGold: number;
|
||||
readonly battalionPrimaryEditSilver: number;
|
||||
readonly battalionSecondaryEditGold: number;
|
||||
readonly battalionSecondaryEditSilver: number;
|
||||
readonly battalionMembersUpgradeGold: number;
|
||||
readonly battalionMembersUpgradeStep: number;
|
||||
readonly battalionMembersUpgradeLimit: number;
|
||||
readonly upgradeBattalionToNormalGold: number;
|
||||
readonly upgradeBattalionToNormalSilver: number;
|
||||
readonly normalFreeDecorators: readonly string[];
|
||||
readonly battalionFreeDecorators: readonly string[];
|
||||
}
|
||||
|
||||
export const clanEconomy: Dataset<ClanEconomy> = {
|
||||
id: 'clan-economy',
|
||||
version: 1,
|
||||
version: 2,
|
||||
extract: (source) => {
|
||||
const wp = source.readBlk('char.vromfs.bin', WARPOINTS);
|
||||
return {
|
||||
normalCreateGold: numberField(wp, 'clanCreateGoldCost') ?? 2500,
|
||||
normalCreateSilver: numberField(wp, 'clanCreateWPCost') ?? 0,
|
||||
normalPrimaryEditGold: numberField(wp, 'costGoldPrimaryInfo') ?? 2500,
|
||||
normalPrimaryEditSilver: numberField(wp, 'costWPPrimaryInfo') ?? 0,
|
||||
normalSecondaryEditGold: numberField(wp, 'costGoldSecondaryInfo') ?? 0,
|
||||
normalSecondaryEditSilver: numberField(wp, 'costWPSecondaryInfo') ?? 0,
|
||||
battalionCreateGold: numberField(wp, 'battalionCreateGoldCost') ?? 0,
|
||||
battalionCreateSilver: numberField(wp, 'battalionCreateWPCost') ?? 1_000_000,
|
||||
battalionPrimaryEditGold: numberField(wp, 'battalionCostGoldPrimaryInfo') ?? 0,
|
||||
battalionPrimaryEditSilver: numberField(wp, 'battalionCostWPPrimaryInfo') ?? 1_000_000,
|
||||
battalionSecondaryEditGold: numberField(wp, 'battalionCostGoldSecondaryInfo') ?? 0,
|
||||
battalionSecondaryEditSilver: numberField(wp, 'battalionCostWPSecondaryInfo') ?? 0,
|
||||
battalionMembersUpgradeGold: numberField(wp, 'battalionMembersUpgradeCost') ?? 225,
|
||||
battalionMembersUpgradeStep: numberField(wp, 'battalionMembersUpgradeStep') ?? 10,
|
||||
battalionMembersUpgradeLimit: numberField(wp, 'battalionMembersUpgradeLimit') ?? 110,
|
||||
upgradeBattalionToNormalGold: numberField(wp, 'clanUpgradeCostGoldBattalionToNormal') ?? 2500,
|
||||
upgradeBattalionToNormalSilver: numberField(wp, 'clanUpgradeCostWPBattalionToNormal') ?? 0,
|
||||
normalFreeDecorators: readDecorList(findBlock(wp, 'clanTagDecorators'), ['--', '..', '==', '^^', '[]']),
|
||||
battalionFreeDecorators: readDecorList(findBlock(wp, 'battalionTagDecorators'), ['**']),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
function readDecorList(block: BlkBlock | undefined, fallback: readonly string[]): readonly string[] {
|
||||
if (!block) return fallback;
|
||||
const values = block.params
|
||||
.filter((p) => p.name === 'decor' && p.value.type === 'string')
|
||||
.map((p) => (p.value as { type: 'string'; value: string }).value);
|
||||
return values.length > 0 ? values : fallback;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import type { BlkBlock } from '@wto/blk';
|
||||
import { numberField, stringField } from './blk-fields.ts';
|
||||
import type { Dataset, DatasetSource } from './dataset.ts';
|
||||
import type { DecorKind } from './decor-catalogue.ts';
|
||||
import { parseLocalizedCsvMap } from './lang-csv.ts';
|
||||
import type { LocalizedText } from './unit-names.ts';
|
||||
|
||||
export interface MarketplaceDecorCoupon {
|
||||
@@ -41,12 +42,11 @@ const DECOR_FILES: readonly { kind: DecorKind; blkPath: string; csvPath: string
|
||||
export const externalItemSources: Dataset<ExternalItemSources> = {
|
||||
id: 'external-item-sources',
|
||||
version: 1,
|
||||
extract: (source) => {
|
||||
const decorCoupons = DECOR_FILES.flatMap(({ kind, blkPath, csvPath }) => extractDecorCoupons(source, kind, blkPath, csvPath));
|
||||
const unlockCoupons = extractUnlockCoupons(source);
|
||||
const workshopItemdefIds = [...collectWorkshopIds(source.readBlk('aces.vromfs.bin', 'config/workshop.blk'))].sort((a, b) => a - b);
|
||||
return { decorCoupons, unlockCoupons, workshopItemdefIds };
|
||||
},
|
||||
extract: (source) => ({
|
||||
decorCoupons: DECOR_FILES.flatMap(({ kind, blkPath, csvPath }) => extractDecorCoupons(source, kind, blkPath, csvPath)),
|
||||
unlockCoupons: extractUnlockCoupons(source),
|
||||
workshopItemdefIds: [...collectWorkshopIds(source.readBlk('aces.vromfs.bin', 'config/workshop.blk'))].sort((a, b) => a - b),
|
||||
}),
|
||||
};
|
||||
|
||||
function extractDecorCoupons(
|
||||
@@ -55,7 +55,7 @@ function extractDecorCoupons(
|
||||
blkPath: string,
|
||||
csvPath: string,
|
||||
): MarketplaceDecorCoupon[] {
|
||||
const locMap = parseCsvNames(source.readText('lang.vromfs.bin', csvPath));
|
||||
const locMap = parseLocalizedCsvMap(source.readText('lang.vromfs.bin', csvPath));
|
||||
const root = source.readBlk('char.vromfs.bin', blkPath);
|
||||
const out: MarketplaceDecorCoupon[] = [];
|
||||
for (const entry of root.blocks) {
|
||||
@@ -73,8 +73,8 @@ function extractDecorCoupons(
|
||||
}
|
||||
|
||||
function extractUnlockCoupons(source: DatasetSource): MarketplaceUnlockCoupon[] {
|
||||
const menuLoc = parseCsvNames(source.readText('lang.vromfs.bin', 'lang/menu.csv'));
|
||||
const achieveLoc = parseCsvNames(source.readText('lang.vromfs.bin', 'lang/unlocks_achievements.csv'));
|
||||
const menuLoc = parseLocalizedCsvMap(source.readText('lang.vromfs.bin', 'lang/menu.csv'));
|
||||
const achieveLoc = parseLocalizedCsvMap(source.readText('lang.vromfs.bin', 'lang/unlocks_achievements.csv'));
|
||||
const root = source.readBlk('char.vromfs.bin', 'config/unlocks.blk');
|
||||
const out: MarketplaceUnlockCoupon[] = [];
|
||||
for (const entry of root.blocks) {
|
||||
@@ -102,55 +102,6 @@ function collectWorkshopIds(block: BlkBlock, out = new Set<number>()): Set<numbe
|
||||
return out;
|
||||
}
|
||||
|
||||
function parseCsvNames(csvText: string): Map<string, LocalizedText> {
|
||||
const lines = csvText.split(/\r?\n/);
|
||||
const header = parseSemicolonRow(lines[0] ?? '');
|
||||
const idIdx = 0;
|
||||
const enIdx = Math.max(1, header.findIndex((col) => col.includes('<English>')));
|
||||
const zhIdx = header.findIndex((col) => col.includes('<Chinese>'));
|
||||
const hzhIdx = header.findIndex((col) => col.includes('<HChinese>'));
|
||||
const map = new Map<string, LocalizedText>();
|
||||
for (let i = 1; i < lines.length; i += 1) {
|
||||
const line = lines[i];
|
||||
if (!line) continue;
|
||||
const cols = parseSemicolonRow(line);
|
||||
const id = cols[idIdx];
|
||||
if (!id) continue;
|
||||
const en = cleanText(cols[enIdx] ?? '') || id;
|
||||
const zh = cleanText((zhIdx >= 0 ? cols[zhIdx] : '') || (hzhIdx >= 0 ? cols[hzhIdx] : '') || '') || en;
|
||||
map.set(id, { en, zh });
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
function parseSemicolonRow(line: string): string[] {
|
||||
const fields: string[] = [];
|
||||
let current = '';
|
||||
let inQuotes = false;
|
||||
for (let i = 0; i < line.length; i += 1) {
|
||||
const ch = line[i]!;
|
||||
if (ch === '"') {
|
||||
if (inQuotes && line[i + 1] === '"') {
|
||||
current += '"';
|
||||
i += 1;
|
||||
} else {
|
||||
inQuotes = !inQuotes;
|
||||
}
|
||||
} else if (ch === ';' && !inQuotes) {
|
||||
fields.push(current);
|
||||
current = '';
|
||||
} else {
|
||||
current += ch;
|
||||
}
|
||||
}
|
||||
fields.push(current);
|
||||
return fields;
|
||||
}
|
||||
|
||||
function cleanText(text: string): string {
|
||||
return text.replace(/\u200b/g, '').trim();
|
||||
}
|
||||
|
||||
function humanizeKey(key: string): string {
|
||||
const leaf = key.includes('/') ? key.slice(key.indexOf('/') + 1) : key;
|
||||
return leaf.replace(/[_-]+/g, ' ').replace(/\b[a-z]/g, (ch) => ch.toUpperCase());
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Shared semicolon-separated localization CSV parser for files in `lang.vromfs.bin`.
|
||||
*/
|
||||
export interface LocalizedCsvText {
|
||||
readonly en: string;
|
||||
readonly zh: string;
|
||||
}
|
||||
|
||||
export function parseSemicolonCsvRow(line: string): string[] {
|
||||
const fields: string[] = [];
|
||||
let current = '';
|
||||
let inQuotes = false;
|
||||
for (let i = 0; i < line.length; i += 1) {
|
||||
const ch = line[i]!;
|
||||
if (ch === '"') {
|
||||
if (inQuotes && line[i + 1] === '"') {
|
||||
current += '"';
|
||||
i += 1;
|
||||
} else {
|
||||
inQuotes = !inQuotes;
|
||||
}
|
||||
} else if (ch === ';' && !inQuotes) {
|
||||
fields.push(current);
|
||||
current = '';
|
||||
} else {
|
||||
current += ch;
|
||||
}
|
||||
}
|
||||
fields.push(current);
|
||||
return fields;
|
||||
}
|
||||
|
||||
/** Strip zero-width word-break spaces Gaijin inserts into CJK localization strings. */
|
||||
export function cleanLangText(raw: string): string {
|
||||
return raw.replace(/\u200b/g, '').trim();
|
||||
}
|
||||
|
||||
export function parseLocalizedCsvMap(csvText: string): Map<string, LocalizedCsvText> {
|
||||
const lines = csvText.split(/\r?\n/);
|
||||
const header = parseSemicolonCsvRow(lines[0] ?? '');
|
||||
const enIdx = Math.max(1, header.findIndex((col) => col.includes('<English>')));
|
||||
const zhIdx = header.findIndex((col) => col.includes('<Chinese>'));
|
||||
const hzhIdx = header.findIndex((col) => col.includes('<HChinese>'));
|
||||
const map = new Map<string, LocalizedCsvText>();
|
||||
|
||||
for (let i = 1; i < lines.length; i += 1) {
|
||||
const line = lines[i];
|
||||
if (!line) continue;
|
||||
const cols = parseSemicolonCsvRow(line);
|
||||
const id = cols[0];
|
||||
if (!id) continue;
|
||||
const en = cleanLangText(cols[enIdx] ?? '') || id;
|
||||
const zh = cleanLangText((zhIdx >= 0 ? cols[zhIdx] : '') || (hzhIdx >= 0 ? cols[hzhIdx] : '') || '') || en;
|
||||
map.set(id, { en, zh });
|
||||
}
|
||||
return map;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user