diff --git a/README.md b/README.md index f41029c..30829bc 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ AI 的驾驶、寻路和战术使用游戏自带的 AI,目前仍有明显不 | 路径 | 内容 | |---|---| | `accounts.json` | 本地账号 | -| `saves/` | 每个账号的存档。存档格式变更时,旧存档在读取时自动升级 | +| `saves/` | 每个本地账号的存档 | | `clans.json` | 本地联队 | | `cache/` | 从游戏文件提取的数据集缓存 | | `logs/` | 流量日志,服务器每次启动新建一个子目录 | @@ -150,6 +150,8 @@ AI 的驾驶、寻路和战术使用游戏自带的 AI,目前仍有明显不 ## 开发 +开发规范、补丁指南和 PR 自查清单见 [Dev Docs](dev-docs/README.md#zh-cn)。 + ### 环境要求 - Windows x64 @@ -186,7 +188,8 @@ node apps/server/src/cli.ts --game "<副本目录>" --data "<数据目录>" --po |---|---| | `--decal-cache <目录>` | 线上版安装的 `cache/content`,复制到副本以显示真实贴花;不指定时使用占位贴图 | | `--skip-unavailable` | 非必需补丁不可用时继续构建 | -| `--patches`、`--gui-patches`、`--native` | 替换默认的补丁目录和 `wto_ws.dll` 所在目录 | +| `--patches <目录>` | 指定补丁集根目录,包含 `exe/`、`gui/`、`native/` 和 `versions/` | +| `--native <目录>` | 指定 `wto_ws.dll` 所在目录 | | `--verbose` | 输出每个补丁的定位结果 | ### 辅助命令 @@ -215,6 +218,8 @@ wtotools check-patches --exe "<原版目录>\win64\aces.exe" # 定位并核 wtotools check-gui --gui "<原版目录>\gui.vromfs.bin" --sq "" # 应用界面补丁并用 Quirrel 编译器编译 ``` +GUI 检查需要 Quirrel 编译器,准备方式见 [Dev Docs](dev-docs/contributing.md#quirrel)。 + 检查全部补丁和 native 模块并写入该客户端版本的核对记录:`node scripts/record-game-version.ts --game "<原版目录>"`。 ## 目录结构 @@ -376,7 +381,7 @@ The server and the build script share one data folder (`--data`): | Path | Contents | |---|---| | `accounts.json` | Local accounts | -| `saves/` | One save per account. When the save format changes, older saves are upgraded on load | +| `saves/` | One save per local account | | `clans.json` | Local squadrons | | `cache/` | Dataset cache extracted from the game files | | `logs/` | Traffic logs, one subfolder per server run | @@ -405,6 +410,8 @@ To override defaults, create `tuning/.jsonc` in the data folder ## Development +See [Dev Docs](dev-docs/README.md#english) for development rules, patch templates, and the PR checklist. + ### Requirements - Windows x64 @@ -441,7 +448,8 @@ Optional arguments for `build-game-copy.ts`: |---|---| | `--decal-cache ` | The online installation's `cache/content`, copied into the copy to show real decals. Without it, placeholder images are used | | `--skip-unavailable` | Continue when non-essential patches are unavailable | -| `--patches`, `--gui-patches`, `--native` | Override the default patch folders and the folder containing `wto_ws.dll` | +| `--patches ` | Override the patch set root containing `exe/`, `gui/`, `native/`, and `versions/` | +| `--native ` | Override the folder containing `wto_ws.dll` | | `--verbose` | Print the locate result of every patch | ### Helper commands @@ -470,6 +478,8 @@ wtotools check-patches --exe "\win64\aces.exe" # locate and ve wtotools check-gui --gui "\gui.vromfs.bin" --sq "" # apply UI patches and compile them with the Quirrel compiler ``` +The GUI check requires the Quirrel compiler. See [the build steps](dev-docs/contributing.md#quirrel). + To check every patch and native module and write the check record of that client version: `node scripts/record-game-version.ts --game ""`. ## Repository layout diff --git a/dev-docs/README.md b/dev-docs/README.md new file mode 100644 index 0000000..ada721d --- /dev/null +++ b/dev-docs/README.md @@ -0,0 +1,31 @@ +# Dev Docs + + + +简体中文 · [English](#english) + +这是 WTOffline 的开发与贡献入口。请先准备一份自己持有的原版客户端,只读使用,并从 [主 README 的开发章节](../README.md#开发)安装工具和依赖。要启动游戏验证时,另备一份 Steam 游戏库之外的离线副本和独立的数据目录,先按[开发规范](development-rules.md#zh-cn)核实隔离。 + +| 要做的事 | 从这里开始 | +| --- | --- | +| 改启动器或安装流程 | [apps/launcher](../apps/launcher) | +| 改游戏规则、档案或本地服务 | [apps/server](../apps/server) | +| 改游戏副本的构建或补丁检查 | [packages/patcher](../packages/patcher)、[scripts](../scripts)、[tools](../tools) | +| 写客户端补丁或适配新的游戏版本 | [补丁指南](patches.md#zh-cn)和[补丁集](../patches) | + +提交前按[自查清单](contributing.md#zh-cn)整理依据、运行适用的[检查命令](contributing.md#checks),并把检查结果和实机步骤写进 [PR 模板](templates/pull-request.md)。 + + + +[简体中文](#zh-cn) · English + +Start with a stock client you own and use it as a read-only source. Install the tools and dependencies listed in the [main README](../README.md#development). To launch the game for verification, prepare an offline copy outside the Steam library and a separate data directory, then verify isolation using the [development rules](development-rules.md#english). + +| Task | Start here | +| --- | --- | +| Change the launcher or installer | [apps/launcher](../apps/launcher) | +| Change game rules, saves, or local services | [apps/server](../apps/server) | +| Change the game copy build or patch checks | [packages/patcher](../packages/patcher), [scripts](../scripts), [tools](../tools) | +| Write a client patch or adapt a new game build | [Patch guide](patches.md#english) and the [patch set](../patches) | + +Before submitting, follow the [review checklist](contributing.md#english), run the applicable [checks](contributing.md#checks), and record the results and in-game steps in the [PR template](templates/pull-request.md). diff --git a/dev-docs/contributing.md b/dev-docs/contributing.md new file mode 100644 index 0000000..dad2b01 --- /dev/null +++ b/dev-docs/contributing.md @@ -0,0 +1,83 @@ +# Contributing + + + +简体中文 · [English](#english) · [返回 Dev Docs](README.md#zh-cn) + +## 提交前自查 + +- 改动只解决一个目标。实现、配置、补丁说明和相关开发文档一致。提交标题用英文 `type(scope): description`,scope 用小写模块名,仓库级改动用 `repo`。破坏兼容时用 `type(scope)!: description`,并在 `BREAKING CHANGE:` 脚注说明影响和处理方式。正文交代原因、依据和验证结果,代码注释也用英文。联署留给实际协作的开发者。 +- 游戏行为的判断有目标版本和一手出处。新动作写清客户端怎样发请求、怎样读取应答。客户端改动登记到对应补丁或构建模块,并说明为何需要。涉及新数值时,按[三类数值规则](development-rules.md#数值和数据来源)检查来源、配置和校验。 +- 检查模块职责、依赖方向和重复逻辑。涉及账号、余额和档案时,检查错误输入、写盘顺序,以及多个账号之间的数据隔离。选择奖品或其他数据项时,按明确规则排序和筛选。 +- 只做类型、补丁、构建和可运行检查。功能验收由人使用隔离副本在游戏里做。注明实际执行过的命令、对应版本和结果。还要实机核对时写出入口、操作和预期现象。商城或交易所改动覆盖内置浏览器打开、相关操作和关窗后的档案刷新。 +- 提交前看一遍差异,确认来源、路径、记录和玩家数据可以分享。用 [PR 模板](templates/pull-request.md) 提供复核所需的信息。 + + + +[简体中文](#zh-cn) · English · [Dev Docs](README.md#english) + +## Review before submitting + +- Keep one purpose per change. Update the affected implementation, configuration, patch notes, and developer docs together. Use English `type(scope): description` commit subjects with a lowercase module scope or `repo` for repository-wide changes. For a breaking change, use `type(scope)!: description` and a `BREAKING CHANGE:` footer that explains the impact and what to do. Explain the reason, evidence, and verification in the commit body. Use English comments and reserve co-author credits for developers who actually collaborated. +- Cite the target build and primary evidence for game behavior. For new actions, explain how the client sends the request and consumes the reply. Register client edits in their patch or build module and explain why they are needed. For new values, check the source, tuning, and validation using the [three kinds of values](development-rules.md#data-and-tuning). +- Check module responsibilities, dependency direction, and reuse. For accounts, currency, and saves, check bad inputs, when updates reach disk, and separation between accounts. Use explicit ordering and selection rules for prize pools and other lists. +- Limit automated checks to type, patch, build, and startup checks. Functional acceptance is performed by a person in an isolated game copy. Report the commands actually run, the client builds, and the results. For pending in-game checks, give the entry point, action, and expected result. Store and marketplace changes cover opening the embedded browser, the affected action, and the profile refresh on close. +- Review the diff for shareable sources, paths, records, and player data. Use the [PR template](templates/pull-request.md) to provide enough detail for review. + + + +## 检查命令 / Check commands + +在仓库根目录执行适用于本次改动的命令。尖括号内的占位内容换成自己的实际值。所有游戏输入文件用只读原版来源,构建输出用单独目录。 + +Run the applicable commands from the repository root. Replace placeholders in angle brackets with your own values. Use read-only stock inputs and a separate build output directory. + +| 改动 / Change | 检查 / Check | +| --- | --- | +| 共用库或本地服务器 / Shared packages or local server | 根目录类型检查,必要时用独立数据目录确认服务器能启动
Root type check and server startup with separate data when applicable | +| 启动器 / Launcher | 启动器的类型检查和构建
Launcher type check and build | +| exe 补丁 / Exe patch | `check-patches` 核对定位、原字节和源码
Verify matches, original bytes, and the patch source with `check-patches` | +| 修改 `patch.jsonc` 或 GUI 片段 / Edits to `patch.jsonc` or GUI fragments | 完整 `check-gui` 检查所有 GUI 补丁的命中、词法作用域和字节码编译
Run the full `check-gui` location, lexical scope, and bytecode checks | +| Native 或构建流程 / Native or copy build | Native 改动先编译 DLL,再用临时输出目录构建,核对定位和可用性
Build the DLL for native changes, then check locations and availability with a temporary copy build | +| 版本适配 / New client build | 生成版本核对记录,完成适用的补丁和构建检查,再走实机验收
Generate a version record, run the applicable checks, then perform in-game acceptance | + +```powershell +# TypeScript / launcher +npm run typecheck +npm run typecheck --workspace "@wto/launcher" +npm run build --workspace "@wto/launcher" + +# Patch tool setup +python -m venv .venv +.\.venv\Scripts\python.exe -m pip install -e ./tools + +# Patch verification +.\.venv\Scripts\python.exe -m wtotools.cli check-patches --exe "\win64\aces.exe" +.\.venv\Scripts\python.exe -m wtotools.cli check-gui --gui "\gui.vromfs.bin" --sq "build\quirrel-cli\bin\Release\sq.exe" + +# Native build and copy build check +powershell -NoProfile -File .\native\wto-net\build.ps1 +node scripts/build-game-copy.ts --game "" --out "" --data "" --port + +# Version adaptation +node scripts/record-game-version.ts --game "" +``` + +实际启动时,离线副本需要包含完整游戏文件,本地服务器与副本构建使用同一端口和数据目录。版本记录命令会写入 `patches/versions/`,按[补丁指南](patches.md#核对版本与提交)核对后再提交。[服务器启动命令](../README.md#构建副本并启动服务器) + +For an actual launch, use a full offline copy and match the server's port and data directory to the copy build. The record generator writes to `patches/versions/`. Follow the [patch guide](patches.md#check-versions-and-submit) before committing a record. [Server startup command](../README.md#build-the-copy-and-start-the-server) + + + +## 构建 Quirrel 编译器 / Build the Quirrel compiler + +GUI 检查使用 `sq.exe` 调用 `compilestring`,检查词法作用域和字节码编译。成功时会报告所有改动脚本都编译通过。以下步骤使用 Visual Studio 2022 的 x64 C++ 工具和 CMake 3.31。将实际编译器路径传给 `check-gui --sq`。[Quirrel 源码版本](https://github.com/GaijinEntertainment/quirrel/tree/19f17df9b6ee43c91ef5c635fd45970ec76c5dbe) + +The GUI checker uses `sq.exe` and `compilestring` to check lexical scope and compile bytecode. A passing run reports successful compilation for all changed scripts. These steps use the Visual Studio 2022 x64 C++ tools and CMake 3.31. Pass the path to your compiler to `check-gui --sq`. [Quirrel source revision](https://github.com/GaijinEntertainment/quirrel/tree/19f17df9b6ee43c91ef5c635fd45970ec76c5dbe) + +```powershell +git clone https://github.com/GaijinEntertainment/quirrel.git build/quirrel-source +git -C build/quirrel-source checkout --detach 19f17df9b6ee43c91ef5c635fd45970ec76c5dbe +cmake -S build/quirrel-source -B build/quirrel-cli -G "Visual Studio 17 2022" -A x64 +cmake --build build/quirrel-cli --config Release --target sq +``` diff --git a/dev-docs/development-rules.md b/dev-docs/development-rules.md new file mode 100644 index 0000000..34888d9 --- /dev/null +++ b/dev-docs/development-rules.md @@ -0,0 +1,59 @@ +# Development rules + + + +简体中文 · [English](#english) · [返回 Dev Docs](README.md#zh-cn) + +## 实现位置 + +- 开工前明确玩家会看到什么变化和准备改的范围。涉及玩法或架构取舍,先和维护者对齐。先查目标版本的游戏文件、原版界面脚本和官方公开源码,记录版本、文件或函数以及支持结论的事实。把推测标为推测。需要读写游戏格式时,先评估已有工具的许可、维护情况和版本适用性。[DagorEngine 源码](https://github.com/GaijinEntertainment/DagorEngine) +- 客户端沿用原有流程,由本地服务器按协议回应。先看服务器或游戏自带配置能否解决。确实需要改客户端时,注明对应功能、原有行为和更小的改动为什么不够。界面脚本进 `patches/gui/`,数据包配置改动归 `packages/patcher/`,其他补丁按[补丁指南](patches.md#zh-cn)登记。 +- 服务端按领域分模块。协议层处理请求和应答格式,规则层处理游戏规则,存档层负责持久化,数据层只提取游戏文件中的事实。修改档案的动作写盘成功后再回复。无法识别账号、缺必填参数或余额不足时,明确拒绝。初期开发用新存档验收,无需增加旧存档迁移。 +- 应用通过参数把配置和路径交给共享库。按职责拆文件、函数和类,复用现有逻辑和常量。文件接近 300 行或函数接近 50 行就检查是否该拆分。商城与交易所的 HTML、CSS、JS 使用独立文件并复用[网页模块](../apps/server/src/web-ui)。 + +## 数值和数据来源 + +| 数值类别 | 做法 | +| --- | --- | +| 协议规定的值,如包头长度和消息类型 | 保留在代码中,注明版本和出处。 | +| 游戏文件已有的值,如车价、改装件价格 | 启动时从玩家的游戏文件读取。缺少必需值时报告具体字段并停止,避免悄悄代入编造的默认值。 | +| 离线版决定的值,如奖励、价格、权重、倍率、等级门槛、数量上限 | 写进对应模块的 `tuning/`。服务端默认值位于 [apps/server/tuning](../apps/server/tuning),启动时校验类型、范围和必填字段。 | + +经济数值先查游戏数据和官方资料。商城以官方美元价作为 GJN 标价依据。官方资料缺项时,沿用已有出处的参考数据,或说明它属于离线设计。配置注释或 PR 记录出处、单位和取值规则,具体数值以配置为准。展示给玩家的数字也从同一数据来源生成。 + +本地服务器每次启动加载数值配置。数据目录下的同名 `tuning/*.jsonc` 可逐键覆盖默认对象。数字、字符串和列表整体替换。 + +## 本地开发与材料 + +- 游戏只在专用副本和隔离环境里启动。启动前验证断网限制、本地服务、Steam 和账号身份,以及文件、注册表、机器标识、反作弊和崩溃上报的隔离。需要观察启动行为时,在一次性环境里核对前后变化。原版来源只读,通过离线副本启动并使用本地账号。 +- 商城和交易所通过游戏内置浏览器访问本地服务。改动时核对该客户端内置浏览器支持的语法,沿用游戏语言和游戏文件中的本地化文字。包括浏览器子进程在内都要检查网络和缓存位置。 +- 提交材料使用自己的代码和最小改动片段。游戏文件、解包产物和玩家数据留在本机。PR 使用可公开复核的出处和已清理的日志节选。 + + + +[简体中文](#zh-cn) · English · [Dev Docs](README.md#english) + +## Where changes belong + +- State the player-visible result and the intended scope before starting. Discuss gameplay or architectural changes with maintainers. Check the target build, stock UI scripts, and official public source. Record the version, file or symbol, and the evidence for the behavior. Mark any inference as such. For game formats, look for existing tools and review their licensing, maintenance, and version support. [DagorEngine source](https://github.com/GaijinEntertainment/DagorEngine) +- Keep the client's normal flow by responding from the local server. Check the server and stock configuration first. When a client change is necessary, document the feature, the stock behavior, and why a lighter change is insufficient. Put UI edits in `patches/gui/` and archive configuration edits in `packages/patcher/`. See the [patch guide](patches.md#english) for the other patch types. +- Keep protocol encoding, game rules, persistence, and game data extraction in their own layers. Persist a save change before returning success. Reject unknown accounts, missing required inputs, and insufficient balances. During early development, use fresh saves for acceptance and omit legacy migrations. +- Pass configuration and paths from applications into shared packages. Reuse existing logic and constants. Review files near 300 lines or functions near 50 lines for responsibilities that can be split. Store shop and marketplace HTML, CSS, and JavaScript in separate files and reuse the [web UI module](../apps/server/src/web-ui). + +## Data and tuning + +| Kind of value | Where it belongs | +| --- | --- | +| Protocol constants such as header sizes and message types | Keep them in code with the source and relevant version. | +| Values already in the game files such as vehicle and modification prices | Read them from the player's game files at startup. Report the field and stop if a required value is missing. | +| Offline defaults such as rewards, prices, weights, multipliers, rank thresholds, and limits | Put them in the module's `tuning/` directory. Server defaults are in [apps/server/tuning](../apps/server/tuning) and are validated at startup. | + +Use game data and official material as the first sources for economic defaults. The local store uses official USD prices as the basis for GJN prices. For gaps, use reference data with a recorded source or document the offline design choice. Put the source, unit, and reasoning in a comment or the PR. Read the exact values and any player-facing numbers from the configuration. + +At startup, the server can load a same-named `tuning/*.jsonc` file from the data directory. Object keys merge. Numbers, strings, and arrays are replaced as a whole. + +## Local development and contributions + +- Launch the game in a dedicated copy and isolated environment. Before launch, verify the network restrictions, local service, and isolation of Steam identity, accounts, files, registry, machine identifiers, anti-cheat, and crash reporting. Observe before and after effects in a disposable environment when needed. Use a read-only stock source and a local account, and launch from the offline copy. +- The store and marketplace use the game's embedded browser and the local service. Check the browser features supported by the target build and reuse the game's language and localized data. Include the browser subprocess when checking network access and cache paths. +- Submit your own code and the smallest fragments needed for a patch. Keep game files, extracted assets, and player data local. Use sources that reviewers can access and redact any log excerpts. diff --git a/dev-docs/patches.md b/dev-docs/patches.md new file mode 100644 index 0000000..0f45cec --- /dev/null +++ b/dev-docs/patches.md @@ -0,0 +1,79 @@ +# Patch guide + + + +简体中文 · [English](#english) · [返回 Dev Docs](README.md#zh-cn) + +## 从一个改动开始 + +先在目标版本核对原有行为。用英文注释说明改什么、为什么本地服务或游戏配置不足、缺少这一改动时玩家会看到什么。一个补丁目录处理一个行为。沿用项目已有的英文 `features` 标签,启动器用这些标签告知玩家哪些功能受影响。 + +复制下面对应的模板,再填入目标版本、路径和原内容。模板使用虚构的路径和数据。补丁加载器只接受定义中的字段,证据和解释写在注释或 PR 里。 + +| 改动 | 放置位置 | 模板与示例 | +| --- | --- | --- | +| exe 字节改动 | `patches/exe/<领域>/<名称>/patch.jsonc` | [模板](templates/exe/patch.jsonc) · [数据目录名称改动](../patches/exe/isolation/user-data-folder-name/patch.jsonc) | +| 界面脚本改动 | `patches/gui/<领域>/<名称>/patch.jsonc` 及同目录片段 | [模板目录](templates/gui) · [教程跳过选项的保存改动](../patches/gui/tutorials/immediate-save-skip-tutorial/patch.jsonc) | +| 本地对局的 native 模块定位 | `patches/native/<模块>.jsonc`,对应 `native/wto-net/src/<模块>.c` | [模板](templates/native/local_mp_example.jsonc) · [计分模块](../patches/native/local_mp_scores.jsonc) | + +### exe 补丁 + +- `id` 用 `<领域>/<名称>`,`title` 说明效果,`features` 列出功能标签,`requires` 列出依赖的 exe 补丁 ID。 +- 每个 `variant` 填 `written_for`、`locate` 和 `edit`。用 `signature` 按当前文件内容定位,使开发侧的 `check-patches` 和构建使用相同方式核对。特征需要唯一命中。为跨版本会变化的字节使用 `??`,把写入位置相对命中点的距离填到 `edit.offset`。 +- `edit.expect_original` 核对原字节,与 `bytes` 等长。改代码用 `asm` 记汇编源码,改文本用 `data` 记编码和文本,检查工具核对源码与写入字节。随版本变化的值可通过 `captures` 读取,由 `fixups` 填入 `bytes` 里的空位。每种写法的注释记下核对版本、范围和通配或捕获的理由。 + +### GUI 补丁 + +- 定义使用 `id`、`title`、`features` 和 `variants`。每种写法填 `written_for`、数据包内的脚本路径 `file` 和 `edits`。每条编辑的 `find` 与 `replace` 引用同目录的文件名。 +- 将最小且唯一命中的原文逐字放进查找片段,缩进和空行也属于匹配内容。片段末尾的一个换行会被去掉,CRLF 和 LF 等效。新写法需要不同片段时另起文件名。替换片段需要本地服务地址时可用 `{{LOCAL_ENDPOINT}}` 代入构建时的主机和端口。 +- 举例说,要改教程选项的保存行为,先核对目标脚本中的原回调和保存路径,再在对应的查找与替换片段记录差异。修改后对该版本原版数据包跑完整 `check-gui`,实机步骤写清勾选选项、退出再进入,以及期望看到的结果。[教程补丁示例](../patches/gui/tutorials/immediate-save-skip-tutorial) + +### Native 模块 + +- `module` 与 JSONC 文件名一致。`requires` 填依赖的模块名。`sites` 用小写下划线命名,所有站点名在补丁集中唯一。每个站点的 `variants` 有 `written_for` 和 `locate`,各写法提供相同名称的捕获值。 +- 定位可用 `signature`、按字符串引用定位的 `string_ref`,或在一个已定位站点所在函数内搜索的 `within`。构建解析站点和捕获值后写入 `wto_ws.cfg`。把随版本变化的地址和结构体偏移交给构建解析。站点缺失或不唯一时,相应模块及其依赖者会报告不可用。 + +## 核对版本与提交 + +补丁引擎要求只有一种写法通过定位和原内容核对。构建会报告不可用项及受影响的功能,必需补丁失配时停止。[必需功能定义](../packages/patcher/src/essential-features.ts) + +适配新版本时,先用只读原版文件生成一份本地核对记录,查看 `unavailable`,针对失配项修定位或新增写法。然后重新核对并完成适用的编译检查。通过隔离副本的实机验收后,再提交 `patches/versions/<版本>.jsonc`。`written_for` 表示写法的编写版本,启动器通过版本核对记录判断「已核对」。[检查命令](contributing.md#checks) · [记录生成脚本](../scripts/record-game-version.ts) · [PR 模板](templates/pull-request.md) + + + +[简体中文](#zh-cn) · English · [Dev Docs](README.md#english) + +## Start with one behavior + +Check the stock behavior in the target build. Use English comments to explain the change, why the local service or stock configuration is insufficient, and what players would observe without the change. Use one directory per behavior. Reuse the project's English `features` tags so the launcher can report affected functionality. + +Copy the matching template and enter the target version, path, and original content. The template inputs are fictional. Keep rationale and evidence in comments or the PR because the loaders reject unknown fields. + +| Change | Location | Template and example | +| --- | --- | --- | +| Exe byte edit | `patches/exe///patch.jsonc` | [Template](templates/exe/patch.jsonc) · [User data folder name](../patches/exe/isolation/user-data-folder-name/patch.jsonc) | +| UI script edit | `patches/gui///patch.jsonc` and its fragments | [Template folder](templates/gui) · [Save the tutorial opt-out](../patches/gui/tutorials/immediate-save-skip-tutorial/patch.jsonc) | +| LocalMP native module site | `patches/native/.jsonc` for `native/wto-net/src/.c` | [Template](templates/native/local_mp_example.jsonc) · [Score module](../patches/native/local_mp_scores.jsonc) | + +### Exe patches + +- Use `/` for `id`, describe the effect in `title`, list the feature tags in `features`, and put required exe patch IDs in `requires`. +- Give each variant a `written_for`, `locate`, and `edit`. Use `signature` so the build and the Python `check-patches` command can both locate the site. The pattern must match once. Use `??` for bytes that vary between builds. Set `edit.offset` to the distance from the match to the edit. +- Set `edit.expect_original` to the bytes expected at that edit and use the same length as `bytes`. Include `asm` for code or an encoding and text in `data` for a text edit. The check tool compares this source with the stored bytes. Use `captures` for values read from the located site and `fixups` for holes in `bytes`. Comment the build, range, wildcards, and captured values for each variant. + +### GUI patches + +- Set `id`, `title`, `features`, and `variants`. Each variant names its `written_for` build, the internal script path in `file`, and its `edits`. An edit names the `find` and `replace` files in the patch directory. +- Copy the smallest unique piece of stock text into the find fragment, including indentation and blank lines. One final newline in each fragment is removed. CRLF and LF match equivalently. Use separate fragment filenames when variants need different text. Use `{{LOCAL_ENDPOINT}}` in replacement text that needs the host and port from the build. +- To change how a tutorial option is saved, for example, trace the original callback and save path, then record the change as find and replace fragments. Run the full `check-gui` against that build's stock archive. Describe how to set the option, leave and return, and observe the expected result. [Tutorial patch example](../patches/gui/tutorials/immediate-save-skip-tutorial) + +### Native modules + +- Match `module` to the JSONC filename. Put required module names in `requires`. Use unique lowercase snake_case names for `sites` across the patch set. Each site variant has `written_for` and `locate`. All variants of a site provide the same capture names. +- Use `signature`, `string_ref` for a reference to a known string, or `within` to search the function containing an already resolved site. The build resolves sites and captured values into `wto_ws.cfg`. Resolve version-dependent addresses and structure offsets at build time. A missing or ambiguous site makes its module and dependent modules unavailable. + +## Check versions and submit + +The patch engine requires a single variant to pass location and original-content checks. The build reports unavailable changes and their affected features. Missing essential patches stop the build. [Essential features](../packages/patcher/src/essential-features.ts) + +To adapt a new build, generate a local version record from read-only stock files and inspect `unavailable`. Adjust the sites or add variants for the failing changes. Rerun the checks and the applicable compilation steps. Commit `patches/versions/.jsonc` after in-game acceptance in an isolated copy. `written_for` identifies the build a variant was authored against. The launcher uses the version record to report a build as checked. [Check commands](contributing.md#checks) · [Record generator](../scripts/record-game-version.ts) · [PR template](templates/pull-request.md) diff --git a/dev-docs/templates/exe/patch.jsonc b/dev-docs/templates/exe/patch.jsonc new file mode 100644 index 0000000..0d3744a --- /dev/null +++ b/dev-docs/templates/exe/patch.jsonc @@ -0,0 +1,29 @@ +// Change a fictional label defined by the offline executable. +// The local server does not supply this label. +// The example would otherwise show the stock label. +{ + "id": "example/local-label", + "title": "Rename the example label in the offline client", + "features": ["Replace with an existing feature tag"], + "requires": [], + "variants": [ + // Example data pattern for DemoLabel followed by a null byte. Use the actual build and bytes. + { + "written_for": "0.0.0.0", + "locate": { + "method": "signature", + "section": ".rdata", + "pattern": "44 65 6d 6f 4c 61 62 65 6c 00" + }, + "edit": { + "offset": 0, + "data": { + "encoding": "ascii", + "text": "LocalDemo" + }, + "bytes": "4c 6f 63 61 6c 44 65 6d 6f 00", + "expect_original": "44 65 6d 6f 4c 61 62 65 6c 00" + } + } + ] +} diff --git a/dev-docs/templates/gui/find.nut b/dev-docs/templates/gui/find.nut new file mode 100644 index 0000000..4b4782a --- /dev/null +++ b/dev-docs/templates/gui/find.nut @@ -0,0 +1 @@ +let exampleLabel = "Example" diff --git a/dev-docs/templates/gui/patch.jsonc b/dev-docs/templates/gui/patch.jsonc new file mode 100644 index 0000000..3a65140 --- /dev/null +++ b/dev-docs/templates/gui/patch.jsonc @@ -0,0 +1,18 @@ +// Set the label on a fictional local screen. +// The script owns this label and reads no data from the server. +// The example would otherwise display the stock text. +{ + "id": "example/offline-label", + "title": "Show an offline label on the example screen", + "features": ["Replace with an existing feature tag"], + "variants": [ + // Replace the fictional game version, script path, and fragment contents. + { + "written_for": "0.0.0.0", + "file": "scripts/example/example.nut", + "edits": [ + { "find": "find.nut", "replace": "replace.nut" } + ] + } + ] +} diff --git a/dev-docs/templates/gui/replace.nut b/dev-docs/templates/gui/replace.nut new file mode 100644 index 0000000..b12376e --- /dev/null +++ b/dev-docs/templates/gui/replace.nut @@ -0,0 +1 @@ +let exampleLabel = "Offline example" diff --git a/dev-docs/templates/native/local_mp_example.jsonc b/dev-docs/templates/native/local_mp_example.jsonc new file mode 100644 index 0000000..86e8af7 --- /dev/null +++ b/dev-docs/templates/native/local_mp_example.jsonc @@ -0,0 +1,26 @@ +// Describe the values a fictional native module reads for the local copy. +// This example locates a settings marker in read-only data and captures its mode byte. +// The module would otherwise lack the value required for its example behavior. +{ + "module": "local_mp_example", + "features": ["Replace with an existing feature tag"], + "requires": [], + "sites": { + "example_label_mode": { + "variants": [ + // The fictional WTO_EXAMPLE marker ends before the one-byte mode. + { + "written_for": "0.0.0.0", + "locate": { + "method": "signature", + "section": ".rdata", + "pattern": "57 54 4f 5f 45 58 41 4d 50 4c 45 00 ??", + "captures": { + "mode": { "offset": 12, "type": "u8" } + } + } + } + ] + } + } +} diff --git a/dev-docs/templates/pull-request.md b/dev-docs/templates/pull-request.md new file mode 100644 index 0000000..c564b92 --- /dev/null +++ b/dev-docs/templates/pull-request.md @@ -0,0 +1,23 @@ +## Change + + + +## Reason and evidence + + + + + +## Client compatibility + + + +## Checks run + +| Command or check | Client build if relevant | Result | +| --- | --- | --- | +| | | | + +## In-game acceptance + +