feat(patcher): resolve native LocalMP values from patch definitions
The LocalMP modules of wto_ws.dll scanned for 42 functions at start-up and used about a hundred structure offsets compiled in as constants, so a game update could move a field without anything noticing. Their needs are now definitions under patches/native/<module>.jsonc, resolved by the patcher when it builds the game copy, the same way exe patches are located: - Locate methods: "string_ref" finds code by the string it loads (optionally with a pattern around the lea, to read the field a scoreboard row stores under that name), and "within" searches a short pattern inside the function of a site located before it (function ranges from the exception directory). - Each module lists its sites (functions, globals, call targets and the instructions whose captures give structure offsets), its features and the modules it requires. A module whose sites are not all found is reported like an unavailable patch, with the modules depending on it. - The resolved values go into wto_ws.cfg as native.<site>[.<capture>] lines, with the executable's PE time stamp and image size so the library can refuse values resolved for another build. - Version records include the native module variants and values. - Patch-set folders: the patcher, the scripts and the launcher take the root of a patch set (exe, gui, native, versions) instead of separate folders. - New feature tags K-Chat and radio and K-Nuclear bomb in both language packs. The library still scans by itself; reading these values is the next change. Checked: root and launcher type checks; all 10 modules resolve on 2.61.0.37, where the 239 values equal what the drafting tool read with a disassembler, and on 2.61.0.43, where every structure offset is unchanged except the GameSaveData HUD event queue (0xae8 -> 0xb18); build-game-copy from 2.61.0.37 into a temporary folder writes the values into wto_ws.cfg.
This commit is contained in:
1 parent
373b7a037a
commit
dde852e2b1
36 files changed
+3318
-91
No files matched your search
@@ -1,23 +1,28 @@
|
||||
/**
|
||||
* The features the patch definitions cover (feature inventory rows named in `features`), each
|
||||
* once, with the patches behind it. The launcher lists them to show which features a copy has.
|
||||
* 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 tagged with it. */
|
||||
/** Ids of the exe and GUI patches, and `native/<module>` of native modules, tagged with it. */
|
||||
readonly patchIds: readonly string[];
|
||||
}
|
||||
|
||||
export function patchFeatures(exePatches: string, guiPatches: string): PatchFeature[] {
|
||||
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<string, string[]>();
|
||||
for (const patch of [...loadPatches(exePatches), ...loadGuiPatches(guiPatches)]) {
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user