/** * The features the patch set covers (feature inventory rows named in `features` of the exe, GUI * and native definitions), each once, with the patches and native modules behind it. The * launcher lists them to show which features a copy has. */ import { loadPatches } from '@wto/exepatch'; import { ESSENTIAL_FEATURES } from './essential-features.ts'; import { loadGuiPatches } from './gui-patch-definition.ts'; import { loadNativeModules } from './native/native-definition.ts'; import { patchSetFolders } from './patch-set.ts'; export interface PatchFeature { /** Feature tag with a prefix identifying its feature group. */ readonly tag: string; /** A copy cannot run, or cannot stay apart from the online game, without it. */ readonly essential: boolean; /** Ids of the exe and GUI patches, and `native/` of native modules, tagged with it. */ readonly patchIds: readonly string[]; } export function patchFeatures(patches: string): PatchFeature[] { const folders = patchSetFolders(patches); const natives = loadNativeModules(folders.native).map((module) => ({ id: `native/${module.module}`, features: module.features })); const byTag = new Map(); for (const patch of [...loadPatches(folders.exe), ...loadGuiPatches(folders.gui), ...natives]) { for (const tag of patch.features) { const ids = byTag.get(tag) ?? []; ids.push(patch.id); byTag.set(tag, ids); } } return [...byTag.entries()] .map(([tag, patchIds]) => ({ tag, essential: ESSENTIAL_FEATURES.has(tag), patchIds })) .sort((a, b) => a.tag.localeCompare(b.tag)); }