Expand dev-docs with a plain-language glossary, accurate single-port server flow, real apps/server directory map and cln_set_researchable trace, un-elided 57-byte EXE patch anatomy, 6-file Native C wiring guide, real Good vs. Bad code comparisons, AI constraint prompt, and traffic-log debugging steps at 1:1 zh-CN/en parity.
33 KiB
WTOffline Developer Documentation / 开发者文档
欢迎参与 WTOffline 开发。本目录面向项目贡献者、客户端新版本适配者,以及使用 AI 编程工具辅助逆向定位与编写代码的协作者。无论你之前是否接触过 Dagor 引擎或《战争雷霆》客户端内部结构,都可以按本指南一步步上手。
如果你只是想制作载具属性魔改、自定义地图池、全新 3D 载具模型或服务端脚本模组:你完全不需要修改 WTOffline 核心源码,请直接阅读 模组开发文档(mod-dev-docs) 或访问 在线模组文档。
第一次来,建议按什么顺序读?
不要一上来就啃二进制补丁字段或反汇编地址。按下面三步顺读,大约 15–20 分钟就能建立完整的全局认知:
- 开发理念、架构分层与工程规范(必读第一站):搞清楚启动器、单端口本地模拟服务器(
apps/server)与进程内网络/对局桥接库(wto_ws.dll)是如何协同工作的;顺着一个真实的cln_set_researchable动作看懂服务端四层代码怎么流转;掌握「三类数值放哪里」「好代码 vs 坏代码」真实对比,以及可直接复制给 AI 编程助手的工程约束提示词。 - 补丁编写与新版本适配指南:当确认本地服务器与原版配置确实无法解决问题、必须修改客户端时,按这篇手把手教程拆包查看原版文件、用
tools/re/cli.py反汇编定位,并对照完整无省略的 GUI(patches/gui/)、EXE(patches/exe/)和 Native(patches/native/+native/wto-net/)真实案例编写跨版本自适应补丁。 - 环境搭建、流量调试与提交自查:配齐本地开发环境,学会直接阅读
<数据目录>/logs/下自动解码的明文 BLK 流量日志快速抓 Bug,按改动类型运行对应的必跑检查命令,并对照 PR 模板 提交高质量改动。
核心概念与术语词典
在阅读后续文档或翻阅源码时,你会频繁遇到以下专有名词。这里用大白话一次性讲透:
1. vromfs.bin(Dagor 虚拟只读归档包)
《战争雷霆》不会把成千上万个零散脚本和配置文件直接摊在硬盘上,而是打包进若干个 .vromfs.bin 归档文件中。它在结构上分两层:外层是带简单异或混淆的 Zstandard(zstd)压缩容器、内部镜像 MD5 与末尾 256 字节签名;内层是文件表(全小写相对路径、偏移量、可选 SHA-1 摘要,以及可选的共享键名表 nm 与 .dict 压缩字典)。项目中的 @wto/vromfs(readArchive / getFile / putFile / writeArchive)负责无损读写这些归档包。
不同归档包各司其职,查数据时按下面这张表找最快:
| 归档包路径(相对于游戏根目录) | 里面装什么核心内容 | WTOffline 哪里会用到它 |
|---|---|---|
char.vromfs.bin |
科技树排布(config/shop.blk)、载具价格/研发点/修车费/改装件(config/wpcost.blk)、全局经济与分房公式(config/warpoints.blk、config/rank.blk)、初始档案模板(config/default_user.blk)、任务列表与成就解锁(config/mislist.blk、config/pve_awards.blk、config/unlocks.blk)、涂装/贴花/挂件/道具定义(config/skins.blk、config/decals.blk、config/attachable.blk、config/items.blk)以及 config/network.blk |
packages/patcher 构建副本时改写服务地址与隐藏载具可见性;apps/server 启动时从中提取绝大部分静态经济与科技树数据集 |
aces.vromfs.bin |
局内玩法与连杀支援规则(config/gameplay.blk)、界面与礼包 GUID 映射(config/gui.blk)、工坊配方(config/workshop.blk)以及全部载具的气动/损伤/武器预设模型(gamedata/flightmodels/…、gamedata/units/…) |
packages/patcher 写入本地商店礼包 GUID;apps/server 提取对局出生规则、礼包映射与载具武器预设 |
gui.vromfs.bin |
客户端全部机库、弹窗、商店、战后结算与 HUD 界面的 Quirrel 脚本(scripts/**/*.nut)与布局模板(.blk / .css) |
patches/gui/ 在构建副本时对少数客户端界面脚本做精确片段替换 |
mis.vromfs.bin |
多人对战与单人任务的地图逻辑、出生点区域、战区与胜利条件定义(gamedata/missions/**/*.blk) |
apps/server 启动时扫描提取多人任务目录(multiplayer-missions 数据集),用于匹配开局 |
lang.vromfs.bin |
分号分隔的多语言本地化词条表(lang/units.csv、lang/menu.csv、lang/unlocks_achievements.csv 等) |
apps/server 提取载具、国家与物品的多语言显示名称,供本地网页商店、交易所和启动器展示 |
ui/atlases.vromfs.bin |
科技树载具剪影与阵营国旗等矢量图标(gameuiskin/*.svg) |
apps/server 按需提取金币车/礼包车/市场车图标与国旗(web-icons 数据集)供游戏内嵌网页商店渲染 |
ui/images.vromfs.bin |
界面位图插画、礼包封面与飞行员头像贴图(images/**) |
apps/server 为内嵌网页商店展示商品封面,并为启动器存档页渲染玩家头像 |
2. BLK / DataBlock(Dagor 树状键值与块数据格式)
BLK(引擎 C++ 类名为 DataBlock)是贯穿整个游戏的通用配置与通信载体,结构类似「带严格值类型的树状 JSON」:每个节点既可以挂载带类型的参数(如整数 :i、浮点 :r、字符串 :t、布尔 :b、三维向量 :p3、矩阵 :m 等),也可以嵌套任意多层同名或异名子块。在 WTOffline 中你会见到它的四种形态,全部由 @wto/blk(decodeBlk、encodeBlk、formatBlkText、parseBlkText)统一处理:
- 归档包内的紧凑二进制 BLK:
char.vromfs.bin与aces.vromfs.bin里的.blk通常将键名抽离到包内共享键名表nm(甚至配合.dict字典做二次 zstd 压缩),解码时需传入SharedNameContext; char协议单包二进制 BLK:HTTP 响应体首字节带压缩标记(例如0x69即'i'表示未压缩二进制 BLK,另有 zlib / zstd 标记),后面紧跟自包含二进制 BLK;PBBD批处理流:客户端上传云端键位与设置(cln_bulk_set_gblk)时使用的多段二进制容器(魔数"PBBD"),每段内嵌独立 BLK 块;- 本地存档自包含二进制 BLK:
<数据目录>/saves/<userId>/profile.blk直接用encodeBlk()落盘,完整保留每个字段的原始值类型,避免整数与浮点数混淆导致客户端解析异常。
3. 本地模拟的四大 Gaijin 后端服务
原版联网客户端并不是只跟一台服务器通信,而是同时访问多套职责不同的后端服务。apps/server 在本机 127.0.0.1:<端口> 上把这四大核心服务全部接管并模拟:
yuplay2(登录与权益服务,login/、store/):处理客户端启动时的账号密码表单登录(POST /login.php),签发本地会话凭据与userId,并提供商店礼包与激活码相关的 Web 接口;char(角色档案服务器 Character Server,char/):机库阶段最核心的请求入口(原域名char-*.warthunder.com)。客户端通过 HTTP 请求头action指明动作名(如cln_get_user_stat、cln_buy_aircraft、cln_set_researchable、cln_update),通过uidhint指明当前账号,请求与响应主体以二进制 BLK 为主,负责完整玩家档案下发、科技树研发、买车买改装、乘员组训练、联队、云端键位设置及战后经济结算;matching(匹配与开局二进制长连接服务,matching/):基于 TCP 的自定义二进制长连接协议(首字节固定为0x01,9 字节包头 + LZ4 压缩负载,握手后启用流加密)。负责向客户端下发可用游戏模式列表、接收排队与小队状态,并在匹配成功时向客户端下发完整的对局启动参数(地图、天气、AI 名单、自定义计分参数等);inventory(外部物品库与交易所服务,inventory/):模拟inventory-proxy-*.gaijin.net/char接口(动作名如GetInventory、GetItemDefsClient、GetItemPrices、GetItemDefChances、ExchangeItems)。与char不同,客户端charsq模块直接将响应解析为 UTF-8 JSON,且要求关键响应附带 RSA 内容签名;用于驱动补给箱开箱、载具兑换券、工坊合成与本地模拟交易所。
4. LocalMP(为什么既要有 apps/server,又必须有 wto_ws.dll?)
初看代码库时最容易产生的疑问是:既然已经用 Node.js 写了本地服务器 apps/server,为什么还要用 C 写一个 native/wto-net/(编译为 wto_ws.dll)注入进游戏进程?
原因在于《战争雷霆》客户端与专用对局服务器(Dedicated Server)的代码裁剪边界:
- 原版零售客户端
aces.exe内部其实保留了一套名为LocalMP(本地多人主机,mp_is_host == 1 && mp_is_local_mp == 1) 的局内会话模式,能够在本机直接跑完整的物理引擎、弹道解算、损伤模型与 AI 驾驶逻辑,因此 WTOffline 不需要重写整套游戏物理服务器; - 但是,Gaijin 在编译零售版
aces.exe时,把原本只在云端专用对局服务器上运行的大量「对局裁判(Host Referee)」处理逻辑裁掉了——包括:响应玩家选车与挂载弹药并生成实体、允许BotSystem刷出 AI 载具、判定击杀/助攻/占点并往记分牌加分、陆战街机连杀空中支援事件生成、核弹落地直接判胜,以及过滤本不该发给受害者之外玩家的炮管/炮闩受损提示; - 因此两套组件分工明确、缺一不可:
apps/server负责对局之外的一切(登录、机库养成、商店市场、排队拼装任务配置、战后发银狮/研发点与存档持久化);而wto_ws.dll在对局进行期间通过 MinHook 挂载在aces.exe进程内,一方面把所有硬编码外网 Socket 连接重定向回127.0.0.1,另一方面通过local_mp_*模块把被客户端裁掉的局内主机裁判逻辑原原本本补齐。
5. Quirrel (.nut) 与 sq.exe 字节码编译器
gui.vromfs.bin 中的 .nut 文件使用的是 Gaijin 基于 Squirrel 深度定制的强词法作用域脚本语言 Quirrel。客户端在玩家点击登录、进入机库前会一次性编译加载大批 .nut 脚本。
为什么修改 patches/gui/ 后不能只靠肉眼或普通语法树(AST)检查,而需要用对应提交版本的原生编译器 sq.exe 跑 wtotools check-gui?因为 Quirrel 的 compilestring 字节码编译阶段会执行严格的词法绑定检查:
- 如果你在
replace.nut里声明了一个local变量,恰好与该文件顶部from ... import *通配导入的某个全局常量重名; - 或者在函数尚未定义/绑定前做了前向调用;
- 或者把 Quirrel 保留字(最典型的坑是
base)当成了普通变量名;
普通语法检查器都会放行,但真进游戏时 Quirrel 虚拟机就会直接中断模块加载,导致客户端永远卡死在登录后的「正在加载…」转圈界面。wtotools check-gui 会在内存中打上所有 GUI 补丁并逐个调用 sq.exe 编译字节码,把这类致命隐患在提交前 100% 拦住。
6. RVA、虚拟地址(VA)与进程运行时指针
在看 patches/exe/、patches/native/ 或使用逆向工具时,务必分清这三种地址表示:
VA(Virtual Address,静态虚拟地址):Ghidra 或 IDA 打开 64 位 Windows 程序aces.exe时,默认镜像基址(ImageBase)是0x140000000,因此反编译器里显示的函数地址往往长这样:0x1412657a0;RVA(Relative Virtual Address,相对虚拟地址):减去镜像基址后的纯偏移,即RVA = VA - ImageBase(例如0x1412657a0 - 0x140000000 = 0x12657a0)。因为 Windows 的 ASLR(地址空间布局随机化)每次启动游戏都会把aces.exe加载到不同的内存基址,仓库内所有补丁注释、tools/re/cli.py参数以及生成的win64/wto_ws.cfg一律使用 RVA;- 运行时绝对指针(Runtime Pointer):游戏启动后,
wto_ws.dll(见native/wto-net/src/local_mp_values.c)通过(uint8_t *)GetModuleHandleW(NULL) + rva把wto_ws.cfg里的 RVA 换算成当次进程内的真实内存地址存入g_lmp。
7. features 功能标签与三条「核心安全锁」(ESSENTIAL_FEATURES)
每个 patches/exe/**/patch.jsonc、patches/gui/**/patch.jsonc 和 patches/native/*.jsonc 都包含一个 features 字符串数组,标签以功能分组字母 A-..K- 开头(例如 "G-Store"、"K-AI opponents and teammates"、"K-Kill, assist and capture scoring")。当游戏刚发布小版本更新、个别非关键补丁暂时失配时,启动器依靠这些标签清晰告知玩家「当前版本哪一项具体子功能暂不可用」,其余功能仍可正常游玩。
但其中有 3 个定义在 packages/patcher/src/essential-features.ts(ESSENTIAL_FEATURES)中的硬阻断安全标签例外:
A-Offline startup:离线副本能否启动的根基(例如跳过修改后.vromfs.bin的官方签名校验);A-Isolation from the official game:与官方正版客户端的完全隔离(将用户配置存档改到独立WTOffline目录、注册表改到Software\WTOffline、剥离反作弊启动器与崩溃上报);A-No Gaijin connections:彻底阻断连向 Gaijin 官方服务器(例如将导入表WS2_32.dll替换为wto_ws.dll并在加载时强制挂载网络重定向钩子)。
只要带有上述任一标签的补丁未能成功定位和应用,blockingFailures() 就会终止副本构建与启动,防止离线客户端触碰玩家的线上正版数据或直连官方服务器,从而保护玩家的线上账号安全。
按你想做的事,直接定位代码目录
| 你想做什么 | 具体源码子目录 | 对口参考章节 |
|---|---|---|
新增或修复机库动作路由(买车、研发、乘员、联队、贴花、战后结算等 char 接口) |
apps/server/src/char/actions/(协议适配)+ apps/server/src/<领域>/(纯业务规则,如 research/、modifications/、crew/、battle/) |
架构分层与真实动作追踪 |
| 修改玩家档案字段读写、新号初始资产或存档落盘格式 | apps/server/src/profile/、apps/server/src/saves/、apps/server/src/storage/ |
存档层与原子写盘规范 |
| 从游戏原版数据包提取新的载具/经济/任务/本地化静态数据 | apps/server/src/game-data/datasets/ |
三类数值与缓存数据集 |
| 调整离线版默认倍率、商店定价、补给箱权重、AI 重生数或上限参数 | apps/server/tuning/*.jsonc + apps/server/src/tuning/ + 各领域 *-tuning.ts |
三类数值放哪里 |
| 修改本地内嵌网页商店、模拟交易所或服务器脚本模组运行时 | apps/server/src/store/、apps/server/src/inventory/、apps/server/src/web-ui/、apps/server/src/mods/ |
服务器目录全景图 |
| 修改桌面启动器界面、安装向导、存档管理页、模组管理页或更新器 | apps/launcher/src/ |
检查命令清单 |
| 修改离线副本构建管线、归档包改写、BLK 编解码、EXE 补丁引擎或模组加载器 | packages/patcher/、packages/blk/、packages/vromfs/、packages/exepatch/、packages/mods/ |
仓库级单向依赖约定 |
修改游戏内界面弹窗、按钮或结算页脚本(Quirrel .nut) |
patches/gui/<领域>/<名称>/ |
GUI 补丁完整范例 |
修改 aces.exe 机器码分支或只读常量字符串 |
patches/exe/<领域>/<名称>/ |
EXE 补丁 57 字节逐指令拆解 |
编写或修复 wto_ws.dll 局内 LocalMP 原生裁判钩子 |
patches/native/<模块>.jsonc + native/wto-net/src/ |
Native 模块 6 文件串联教程 |
| 协助适配刚发布的《战争雷霆》客户端小版本更新 | patches/versions/、scripts/record-game-version.ts |
适配新版本客户端四步流程 |
简体中文 · English · Online Docs
Welcome to WTOffline development. This directory is written for project contributors, client build adapters, and collaborators using AI coding assistants to reverse-engineer, investigate, and fix issues. Even if you have never worked with the Dagor Engine or War Thunder internals before, these guides walk you through every layer from first principles.
Just want to create vehicle stat tweaks, custom map pools, standalone 3D vehicles, or server script mods? You do not need to modify WTOffline's core source code at all—head straight to the Mod Development Docs (
mod-dev-docs) or the online Mod Docs.
Recommended Reading Order
Do not jump straight into raw byte patterns or disassembly offsets on your first visit. Reading the three core guides in this order builds the full mental model in 15–20 minutes:
- Design Philosophy, Architecture & Engineering Rules (Start here): Understand how the launcher, single-port local server (
apps/server), and in-process Winsock/LocalMP bridge (wto_ws.dll) fit together; trace one realcln_set_researchablerequest end-to-end across all four server layers; learn where the three categories of numbers belong; review four real Good vs. Bad code comparisons; and grab the copy-paste prompt block for AI coding assistants. - Patch Authoring & Version Adaptation Guide: Once you have confirmed that the local server and stock configuration genuinely cannot solve an issue, follow step-by-step instructions to unpack stock archives, disassemble
aces.exewithtools/re/cli.py, and study un-elided real patches acrosspatches/gui/,patches/exe/, andpatches/native/+native/wto-net/. - Environment Setup, Traffic Debugging & PR Guide: Set up the Windows x64 toolchain, inspect auto-decoded readable BLK payloads under
<data-dir>/logs/to pinpoint bugs in minutes, run the required verification commands for your change type, and fill out the PR template.
Core Concepts & Glossary
You will encounter these War Thunder and WTOffline terms throughout the codebase and documentation. Here is what each one means in plain language:
1. vromfs.bin (Dagor Virtual Read-Only File System Archive)
Instead of shipping tens of thousands of loose scripts and config files on disk, War Thunder bundles them into .vromfs.bin archives. Each archive has two layers: an outer container (Zstandard compression with lightweight XOR obfuscation, an MD5 digest of the inner image, and a 256-byte signature tail) and an inner image (a lowercase relative path table, byte offsets, optional SHA-1 digests, plus an optional shared name map nm and .dict zstd dictionary). @wto/vromfs (readArchive, getFile, putFile, writeArchive) reads and repacks these archives losslessly.
Use this lookup table whenever you need to find where a stock script, config, or asset lives:
| Archive path (relative to game root) | What it stores | How WTOffline uses it |
|---|---|---|
char.vromfs.bin |
Tech-tree layout (config/shop.blk), per-vehicle prices, RP, repair costs, and modifications (config/wpcost.blk), global economy and BR formulas (config/warpoints.blk, config/rank.blk), new-account profile template (config/default_user.blk), mission lists and unlock definitions (config/mislist.blk, config/pve_awards.blk, config/unlocks.blk), camos/decals/decorators/classic items (config/skins.blk, config/decals.blk, config/attachable.blk, config/items.blk), and config/network.blk |
packages/patcher rewrites backend URLs and hidden-vehicle visibility during copy builds; apps/server extracts most economy, tech-tree, unlock, and mission datasets from it at startup |
aces.vromfs.bin |
Match gameplay and killstreak rules (config/gameplay.blk), UI config and store bundle GUID mappings (config/gui.blk), workshop recipes (config/workshop.blk), and all vehicle flight/damage/weapon preset files (gamedata/flightmodels/…, gamedata/units/…) |
packages/patcher injects offline store bundle GUIDs; apps/server extracts spawn rules, bundle mappings, and weapon presets |
gui.vromfs.bin |
All in-game hangar, modal, store, debriefing, and HUD Quirrel scripts (scripts/**/*.nut) and layout templates (.blk / .css) |
patches/gui/ applies minimal surgical text replacements to UI scripts when building the offline copy |
mis.vromfs.bin |
Multiplayer and single-player mission logic, spawn zones, capture points, and victory rules (gamedata/missions/**/*.blk) |
apps/server scans it at startup (multiplayer-missions dataset) to build matchmaking mission definitions |
lang.vromfs.bin |
Semicolon-separated localization CSV tables (lang/units.csv, lang/menu.csv, lang/unlocks_achievements.csv, etc.) |
apps/server extracts localized vehicle, country, and item names for the in-game web store, marketplace, and launcher |
ui/atlases.vromfs.bin |
Tech-tree vehicle silhouettes and country flags in SVG format (gameuiskin/*.svg) |
apps/server extracts icons for gift/premium/market vehicles and flags (web-icons dataset) for the local web store and marketplace |
ui/images.vromfs.bin |
UI raster artwork, bundle cover images, and pilot avatar textures (images/**) |
apps/server serves store/marketplace item artwork and renders player profile icons for the launcher's saves page |
2. BLK / DataBlock (Dagor Typed Hierarchical Data Format)
BLK (named DataBlock in Dagor Engine C++ code) is the typed tree format used everywhere in War Thunder for configs, network payloads, and player profiles. Think of it as a tree of named blocks and typed key-value parameters (:i integers, :r floats, :t strings, :b booleans, :p3 3D vectors, :m matrices, etc.). You will encounter four binary/wire representations in WTOffline, all handled by @wto/blk (decodeBlk, encodeBlk, formatBlkText, parseBlkText):
- Slimmed binary BLK inside
.vromfs.bin:.blkfiles insidechar.vromfs.binandaces.vromfs.binstrip repeated key names into the archive's shared name mapnm(and may compress payloads with an archive.dictzstd dictionary), decoded by passingSharedNameContexttodecodeBlk; - Framed binary BLK on
charHTTP exchanges: Single-document HTTP payloads prefixed with a 1-byte compression marker (e.g.,0x69/'i'for uncompressed binary BLK, or zlib/zstd markers); PBBDbatch streams: Multi-chunk binary streams (magic"PBBD") used byonline_storage(cln_bulk_set_gblk) when uploading keybindings and cloud settings, where each chunk carries an embedded BLK block;- Self-contained binary BLK on disk: Player profiles saved at
<data>/saves/<userId>/profile.blkviaencodeBlk(), preserving every parameter's exact scalar/vector type so the game client never misinterprets ints as floats or vice versa.
3. The Four Gaijin Backend Services Emulated Locally
A live War Thunder client talks to several distinct backend services rather than a single monolithic API. apps/server emulates all four locally on a single 127.0.0.1:<port> listener:
yuplay2(Login & Entitlement APIs,login/,store/): Handles form-encoded credential sign-in (POST /login.php), issues local session tokens anduserIds, and serves store/redeem-code web endpoints;char(Character Server,char/): The primary hangar RPC service (char-*.warthunder.com). Requests specify the operation via theactionHTTP header (such ascln_get_user_stat,cln_buy_aircraft,cln_set_researchable,cln_update) and identify the player viauidhint, exchanging binary BLK payloads for full profile sync, tech-tree research, vehicle/modification/crew purchases, squadrons, cloud settings, and post-battle settlement;matching(Binary Matchmaking & Session RPC,matching/): A persistent binary TCP protocol (first byte0x01, 9-byte header + LZ4-compressed frame, stream-encrypted after handshake) that serves game-mode lists, manages queues and squad state, and dispatches complete battle launch configurations (map, weather, AI bot rosters,customScoreParams, etc.);inventory(External Inventory & Marketplace Service,inventory/): Emulatesinventory-proxy-*.gaijin.net/char(GetInventory,GetItemDefsClient,GetItemPrices,GetItemDefChances,ExchangeItems). Unlikechar, the client'scharsqsubsystem parses raw HTTP bodies directly as UTF-8 JSON and verifies RSA content signatures—powering supply chests, vehicle coupons, workshop crafting, and the simulated marketplace.
4. LocalMP (Why WTOffline Needs Both apps/server AND wto_ws.dll)
A natural question for newcomers is: If apps/server already emulates Gaijin's backend in TypeScript, why do we also compile native/wto-net/ into wto_ws.dll and load it inside aces.exe?
The answer comes down to what Gaijin kept vs. stripped in the retail game client:
- Retail
aces.exestill contains an in-processLocalMPsession mode (mp_is_host == 1 && mp_is_local_mp == 1) capable of running full physics, ballistics, damage models, and AI piloting/driving locally—meaning WTOffline does not have to reimplement a Dedicated Server physics engine from scratch; - However, when building retail
aces.exe, Gaijin compiled out many Dedicated Server battle referee handlers that normally run only in the cloud during live matches: spawning player vehicles and weapon loadouts on selection, grantingBotSystempermission to spawn AI vehicles, awarding kill/assist/capture scoreboard points, running Ground Arcade killstreak air events, triggering nuclear instant victories, and filtering barrel/breech/part-damage HUD notices so enemy hits are not misdelivered to the local player; - Consequently, the two halves have a crisp boundary:
apps/serverowns everything before and after a battle (login, hangar progression, economy, store/market, matchmaking setup, post-battle Silver Lions/RP settlement, and atomic save persistence), whilewto_ws.dllhooksaces.exein-process via MinHook—redirecting hardcoded outbound Winsock traffic to127.0.0.1and restoring stripped host-side referee logic during liveLocalMPbattles via modularlocal_mp_*bridges.
5. Quirrel (.nut) & the sq.exe Bytecode Compiler
UI scripts inside gui.vromfs.bin (.nut files) are written in Quirrel, Gaijin's Squirrel-derived scripting language with strict lexical scoping. When logging into the hangar, the client preloads and compiles UI script modules en masse.
Why is running wtotools check-gui with the matching sq.exe compiler mandatory whenever you touch patches/gui/, instead of eyeballing diffs or running an AST-only syntax check? Because Quirrel's compilestring bytecode compiler enforces lexical binding rules that AST parsers ignore:
- Declaring a
localidentifier that collides with a constant imported viafrom ... import *at the top of the file; - Referencing an unbound local/module function before its declaration;
- Using a Quirrel reserved keyword (most notoriously
base) as a variable name.
Any of those mistakes looks syntactically innocent on paper, yet aborts module compilation inside the game client and freezes login indefinitely on the "Loading..." spinner. wtotools check-gui applies every GUI patch in memory and compiles each modified .nut file to Quirrel bytecode via sq.exe, catching 100% of lexical and constant-binding errors before commit.
6. RVA vs. Virtual Address (VA) vs. Runtime Pointer
Keep these three address forms straight whenever you read disassembly or write patches/:
VA(Virtual Address): When you open 64-bitaces.exein Ghidra or IDA, the default PEImageBaseis0x140000000, so addresses appear as0x1412657a0;RVA(Relative Virtual Address): Offset from the image base, i.e.,RVA = VA - ImageBase(0x1412657a0 - 0x140000000 = 0x12657a0). Because Windows ASLR loadsaces.exeat a fresh random base address on every launch, everypatches/comment,tools/re/cli.pyargument, andwin64/wto_ws.cfgentry uses RVAs exclusively;- Runtime Pointer: When the game starts,
wto_ws.dll(native/wto-net/src/local_mp_values.c) adds the live module base(uint8_t *)GetModuleHandleW(NULL) + rvaand stores the resulting process pointer ing_lmp.
7. features Tags & the Three Essential Safety Locks (ESSENTIAL_FEATURES)
Every definition in patches/exe/**/patch.jsonc, patches/gui/**/patch.jsonc, and patches/native/*.jsonc lists one or more features tags prefixed by inventory category (A- through K-, such as "G-Store", "K-AI opponents and teammates", or "K-Kill, assist and capture scoring"). If a minor client update breaks an optional patch, the launcher uses these tags to show the player exactly which non-essential gameplay feature is degraded while still letting them play.
Three tags defined in packages/patcher/src/essential-features.ts (ESSENTIAL_FEATURES) are hard-blocking safety locks:
A-Offline startup: Required for the offline copy to boot at all (e.g., bypassing.vromfs.binpack signature checks so modified archives load);A-Isolation from the official game: Keeps the offline copy completely separate from the official client (redirecting user saves/settings toWTOffline, registry keys toSoftware\WTOffline, and disabling the anti-cheat launcher and crash reporter);A-No Gaijin connections: Guarantees zero traffic reaches Gaijin's live servers (e.g., rewriting the PE import descriptor fromWS2_32.dlltowto_ws.dlland enforcing Winsock redirection hooks on attach).
If any patch carrying one of these three tags fails to resolve, blockingFailures() immediately aborts copy installation and launch—protecting the player's official online installation and account from ever being touched.
Jump Straight to Your Task
| What you want to do | Specific codebase directories | Primary reference |
|---|---|---|
| Add or fix hangar actions (research, purchases, crews, squadrons, decals, post-battle settlement, etc.) | apps/server/src/char/actions/ (wire handlers) + apps/server/src/<domain>/ (pure rules: research/, modifications/, crew/, battle/, etc.) |
Server Layers & Action Walkthrough |
| Change player profile fields, new-account defaults, or save persistence / format upgrades | apps/server/src/profile/, apps/server/src/saves/, apps/server/src/storage/ |
Persistence & Atomic Writes |
| Extract new static vehicle, economy, mission, or localization data from stock archives | apps/server/src/game-data/datasets/ |
Three Categories of Values |
| Adjust offline reward multipliers, store prices, supply-chest weights, AI respawn counts, or limits | apps/server/tuning/*.jsonc + apps/server/src/tuning/ + <domain>/*-tuning.ts |
Three Categories of Values |
| Work on the in-game web store, simulated marketplace, or server script mod runtime | apps/server/src/store/, apps/server/src/inventory/, apps/server/src/web-ui/, apps/server/src/mods/ |
Server Directory Map |
| Change the desktop launcher UI, install wizard, saves manager, mods page, or auto-updater | apps/launcher/src/ |
Required Check Commands |
| Modify copy building, archive patching, BLK/vromfs codecs, EXE patch engine, or mod loader | packages/patcher/, packages/blk/, packages/vromfs/, packages/exepatch/, packages/mods/ |
Workspace Dependency Rule |
Patch in-game UI modals, buttons, or debriefing Quirrel scripts (.nut) |
patches/gui/<domain>/<name>/ |
GUI Patches Full Example |
Patch machine instructions or constant .rdata strings in aces.exe |
patches/exe/<domain>/<name>/ |
EXE Patch 57-Byte Anatomy |
Write or fix wto_ws.dll in-process LocalMP battle host hooks |
patches/native/<module>.jsonc + native/wto-net/src/ |
Native Modules 6-File Wiring |
| Adapt WTOffline to a newly released minor War Thunder client build | patches/versions/, scripts/record-game-version.ts |
Adapting a New Client Build |