Document development rules, patch formats, and PR review checks. Include reusable patch and PR templates, and correct the README development commands. Verified Markdown links, all three patch template types, root and launcher type checks, and exe and GUI checks on client 2.61.0.37.
8.9 KiB
Patch guide
简体中文 · English · 返回 Dev Docs
从一个改动开始
先在目标版本核对原有行为。用英文注释说明改什么、为什么本地服务或游戏配置不足、缺少这一改动时玩家会看到什么。一个补丁目录处理一个行为。沿用项目已有的英文 features 标签,启动器用这些标签告知玩家哪些功能受影响。
复制下面对应的模板,再填入目标版本、路径和原内容。模板使用虚构的路径和数据。补丁加载器只接受定义中的字段,证据和解释写在注释或 PR 里。
| 改动 | 放置位置 | 模板与示例 |
|---|---|---|
| exe 字节改动 | patches/exe/<领域>/<名称>/patch.jsonc |
模板 · 数据目录名称改动 |
| 界面脚本改动 | patches/gui/<领域>/<名称>/patch.jsonc 及同目录片段 |
模板目录 · 教程跳过选项的保存改动 |
| 本地对局的 native 模块定位 | patches/native/<模块>.jsonc,对应 native/wto-net/src/<模块>.c |
模板 · 计分模块 |
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,实机步骤写清勾选选项、退出再进入,以及期望看到的结果。教程补丁示例
Native 模块
module与 JSONC 文件名一致。requires填依赖的模块名。sites用小写下划线命名,所有站点名在补丁集中唯一。每个站点的variants有written_for和locate,各写法提供相同名称的捕获值。- 定位可用
signature、按字符串引用定位的string_ref,或在一个已定位站点所在函数内搜索的within。构建解析站点和捕获值后写入wto_ws.cfg。把随版本变化的地址和结构体偏移交给构建解析。站点缺失或不唯一时,相应模块及其依赖者会报告不可用。
核对版本与提交
补丁引擎要求只有一种写法通过定位和原内容核对。构建会报告不可用项及受影响的功能,必需补丁失配时停止。必需功能定义
适配新版本时,先用只读原版文件生成一份本地核对记录,查看 unavailable,针对失配项修定位或新增写法。然后重新核对并完成适用的编译检查。通过隔离副本的实机验收后,再提交 patches/versions/<版本>.jsonc。written_for 表示写法的编写版本,启动器通过版本核对记录判断「已核对」。检查命令 · 记录生成脚本 · PR 模板
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/<domain>/<name>/patch.jsonc |
Template · User data folder name |
| UI script edit | patches/gui/<domain>/<name>/patch.jsonc and its fragments |
Template folder · Save the tutorial opt-out |
| LocalMP native module site | patches/native/<module>.jsonc for native/wto-net/src/<module>.c |
Template · Score module |
Exe patches
- Use
<domain>/<name>forid, describe the effect intitle, list the feature tags infeatures, and put required exe patch IDs inrequires. - Give each variant a
written_for,locate, andedit. Usesignatureso the build and the Pythoncheck-patchescommand can both locate the site. The pattern must match once. Use??for bytes that vary between builds. Setedit.offsetto the distance from the match to the edit. - Set
edit.expect_originalto the bytes expected at that edit and use the same length asbytes. Includeasmfor code or an encoding and text indatafor a text edit. The check tool compares this source with the stored bytes. Usecapturesfor values read from the located site andfixupsfor holes inbytes. Comment the build, range, wildcards, and captured values for each variant.
GUI patches
- Set
id,title,features, andvariants. Each variant names itswritten_forbuild, the internal script path infile, and itsedits. An edit names thefindandreplacefiles 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-guiagainst that build's stock archive. Describe how to set the option, leave and return, and observe the expected result. Tutorial patch example
Native modules
- Match
moduleto the JSONC filename. Put required module names inrequires. Use unique lowercase snake_case names forsitesacross the patch set. Each site variant haswritten_forandlocate. All variants of a site provide the same capture names. - Use
signature,string_reffor a reference to a known string, orwithinto search the function containing an already resolved site. The build resolves sites and captured values intowto_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
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/<version>.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 · Record generator · PR template