refactor(repo)!: move apps, shared packages, and patch definitions

Everything sat in packages/: two programs next to the small libraries
they use, and the patch data loose at the root. The programs now live in
apps/ and the shared libraries in packages/:

  apps/server        the local server (was packages/local-service),
                     package @wto/server
  packages/patcher   builds the game copy (was packages/build),
                     package @wto/patcher
  patches/exe        exe patch definitions (was exe-patches)
  patches/gui        GUI script patches (was gui-patches)

Inside the server, the network layer folder becomes transport/ so it is
not server/server/, the entry module is server.ts, and startLocalService
and its types become startServer, ServerOptions and RunningServer. The
health answer names the app wto-server, and the TLS files in the data
folder are server.key and server.crt (made again on the next start).
Comments, logs and tool texts say "local server".

The patcher no longer reaches into the server's folder. It read the
default tuning/store.jsonc by a relative path to register bundle GUIDs
for the multi-vehicle packs, which also ignored the player's overrides
in <data>/tuning/. It now takes the pack ids from its caller; the
server exports multiVehiclePackIds(dataFolder), which reads them the way
the running server does. rebuildGuiPack takes the patch folder from its
caller as well.

The development build moves out of the patcher to
scripts/build-game-copy.ts, since it uses both the server and the
patcher. It needs --data (the folder the server will run with) and
defaults the patch folders and the hook library to this repository.


Checked with the root typecheck, check-patches, check-gui,
check-offsets, the native build, a run of build-game-copy.ts into a
scratch folder (12 exe patches, 35 GUI patches, 496 bundle GUIDs as
before) and a server start from apps/server answering wto-server.

BREAKING CHANGE: Use @wto/server and @wto/patcher from the new workspace paths. Run the development build with scripts/build-game-copy.ts and pass --data.
This commit is contained in:
N0VAN0M4LY committed 2026-11-29 03:20:54 +08:00
1 parent 9c813ccf7d
commit 930ea07630
476 files changed
+275 -251

No files matched your search

+8 -4
View File
@@ -2,12 +2,16 @@
《战争雷霆》离线版。目标客户端版本:Steam 2.61.0.37。
做法和 SPT 一样:客户端的所有联网请求改到本机,由本地服务模拟 Gaijin 的服务器。
做法和 SPT 一样:客户端的所有联网请求改到本机,由本地服务器模拟 Gaijin 的服务器。
本仓库不包含任何游戏文件。构建时从一个游戏文件夹读取原版文件。
| 目录 | 内容 |
|---|---|
| `packages/` | TypeScript(npm workspace):BLK 编解码、数据包读写、exe 补丁应用、构建流程、本地服务,以后还有启动器 |
| `tools/` | Python 开发端工具:数据包读写、exe 补丁引擎(特征码生成、汇编核对) |
| `exe-patches/` | exe 补丁定义 |
| `apps/server/` | 本地服务器(TypeScript):模拟 Gaijin 的登录、档案、匹配、商店等服务器 |
| `packages/` | 共用的 TypeScript 库(npm workspace):BLK 编解码(`blk`)、数据包读写(`vromfs`)、JSONC(`jsonc`)、exe 补丁引擎(`exepatch`)、构建游戏副本(`patcher`) |
| `patches/exe/` | exe 补丁定义 |
| `patches/gui/` | 界面脚本补丁定义 |
| `native/` | 网络钩子与本地对局模块 `wto_ws.dll`(C) |
| `scripts/` | 开发用的 TypeScript 脚本(如 `build-game-copy.ts` 构建游戏副本) |
| `tools/` | Python 开发端工具:数据包读写、exe 补丁核对(特征码生成、汇编核对)、界面补丁编译检查 |
@@ -1,5 +1,5 @@
{
"name": "@wto/local-service",
"name": "@wto/server",
"version": "0.1.0",
"private": true,
"type": "module",
@@ -11,4 +11,4 @@
"@wto/jsonc": "*",
"@wto/vromfs": "*"
}
}
}
@@ -4,7 +4,7 @@
* connection. Run it on a machine that can reach the official sites; nothing is shipped with
* the project, every player makes their own copy.
*
* node packages/local-service/src/asset-pack-cli.ts --data <data folder> [--concurrency 6]
* node apps/server/src/asset-pack-cli.ts --data <data folder> [--concurrency 6]
*
* Sources: official marketplace art and vehicle renders, plus store covers and screenshots.
* The storefront links videos directly.
@@ -32,7 +32,7 @@ export type DebriefingRow =
| 'Assist' | 'AirSevereDamage' | 'ShipSevereDamage' | 'Critical' | 'Hit'
| 'Captures' | 'AwardDamage';
/** What the client reports for one combat event (gui-patches/battle/record-local-battle-awards). */
/** What the client reports for one combat event (patches/gui/battle/record-local-battle-awards). */
export interface CombatEventFact {
readonly code: number;
readonly expClass: string;
@@ -1,6 +1,6 @@
/**
* The battle report of `cln_wto_finish_battle` (gui-patches/battle/report-local-battle-settlement):
* what happened in the battle, as facts only. The client sends no money; the local service
* The battle report of `cln_wto_finish_battle` (patches/gui/battle/report-local-battle-settlement):
* what happened in the battle, as facts only. The client sends no money; the local server
* prices every event (battle-economy.ts).
*
* sessionId:t outcome:t ("win" | "lose" | "running") localTeam:i
@@ -13,7 +13,7 @@ import { withAccount } from './account-context.ts';
/**
* cln_get_initial_meta: server-side metadata the client reads in GameSaveData's initial-meta
* handling (aces.exe 0xeb5f60). binaryDataMetainfo lists server-side binary files the client
* must fetch and compare by hash; the local service has none, so the list is empty and no
* must fetch and compare by hash; the local server has none, so the list is empty and no
* downloads follow. generalBlkMeta carries the cloud-settings schema and saved versions/hashes
*.
*/
@@ -9,7 +9,7 @@
* - error: a body starting "!ERROR:" followed by an error code.
*/
import { encodeBlk, formatBlkText, type BlkBlock } from '@wto/blk';
import type { ServiceResponse } from '../server/exchange.ts';
import type { ServiceResponse } from '../transport/exchange.ts';
import { encodeDataAnswer } from './char-payload.ts';
export type CharAnswer =
@@ -4,7 +4,7 @@
* The client names the action in the request header "action" (request headers assembled at
* aces.exe 0x336c590). Requests carry no "userid" header; the player is identified by
* "uidhint", the user id from the sign-in answer (implementation notes; added by
* EconomicSerializeJob::doJob, 0x2968a5). The local service trusts uidhint as it is: there
* EconomicSerializeJob::doJob, 0x2968a5). The local server trusts uidhint as it is: there
* is nothing to protect on a single-player machine.
*
* An action with no handler yet gets a data answer holding an empty BLK and is marked
@@ -13,7 +13,7 @@
* default lets the client continue and reveal what it asks for next.
*/
import { emptyBlock } from '@wto/blk';
import type { Service, ServiceRequest, ServiceResponse } from '../server/exchange.ts';
import type { Service, ServiceRequest, ServiceResponse } from '../transport/exchange.ts';
import type { CharActionHandler } from './char-action.ts';
import { toResponse, type CharAnswer } from './char-answers.ts';
import { decodeRequestPayload } from './char-payload.ts';
@@ -1,13 +1,13 @@
/**
* Development entry point of the local service.
* Development entry point of the local server.
*
* node packages/local-service/src/cli.ts --game <game folder> --data <data folder> --port <n>
* node apps/server/src/cli.ts --game <game folder> --data <data folder> --port <n>
*
* The port must match the one the game copy was built with (packages/build). The launcher
* The port must match the one the game copy was built with (packages/patcher). The launcher
* will start the service the same way. Stops on Ctrl+C.
*/
import { parseArgs } from 'node:util';
import { LOOPBACK, startLocalService } from './local-service.ts';
import { LOOPBACK, startServer } from './server.ts';
async function main(): Promise<number> {
const { values } = parseArgs({
@@ -24,13 +24,13 @@ async function main(): Promise<number> {
}
let service;
try {
service = await startLocalService({ gameFolder: values.game, dataFolder: values.data, port, report: (line) => console.log(line) });
service = await startServer({ gameFolder: values.game, dataFolder: values.data, port, report: (line) => console.log(line) });
} catch (error) {
const code = (error as NodeJS.ErrnoException).code;
console.error(code === 'EADDRINUSE' ? `port ${port} is already in use; choose another port` : String(error));
return 1;
}
console.log(`local service listening on ${LOOPBACK}:${port}`);
console.log(`local server listening on ${LOOPBACK}:${port}`);
console.log(`traffic log: ${service.logFolder}`);
const running = service;
await new Promise<void>((resolve) => process.once('SIGINT', resolve));
@@ -2,7 +2,7 @@
* Downloadable content (dldata): there is no CDN offline, so the index list and every file on
* the dldata hosts are answered with 404, each with a note in the traffic log.
*
* Where the client gets its decals instead (aces.exe 2.61.0.37; packages/build/src/decals/):
* Where the client gets its decals instead (aces.exe 2.61.0.37; packages/patcher/src/decals/):
* - No player decal source: char.vromfs.bin holds dldata/downloadable_skins.blk and
* dldata/downloadable_decals.blk, the client loads them at init (0xd3bc40 -> 0xd3cc60) and
* never asks for dldata_s.info.
@@ -14,7 +14,7 @@
* The client does not download the indexes themselves (0xd3e710 only looks in the cache
* folder), so serving them here would have no effect.
*/
import type { Service, ServiceRequest, ServiceResponse } from '../server/exchange.ts';
import type { Service, ServiceRequest, ServiceResponse } from '../transport/exchange.ts';
const INFO_HOST = /^public-configs[a-z0-9-]*\.(warthunder\.com|cdn\.gaijin\.net)$/;
const INFO_PATH = /^\/[a-z0-9_-]+\/dldata_s\.info$/;
@@ -9,7 +9,7 @@
* vehicle types allowed, per-difficulty overrides, and the players' spawn slots
* ("wing" entries of player / player_teamB). Its scalar parameters (and those of each
* per-difficulty "mission" sub-block) are also kept as written, with their BLK types, for
* the mission settings the local service sends when a battle starts.
* the mission settings the local server sends when a battle starts.
*
* 2.61.0.37: 1315 missions, each name matching exactly one mission file (docs/implementation notes).
*/
@@ -5,7 +5,7 @@
* char.vromfs.bin config/warpoints.blk playerExpToCountryFor1Gold:i (2.61.0.37: 45). The
* client reads it in wp_get_exp_convert_exp_for_gold_rate (aces.exe 0x1052af0 -> 0x916eb0),
* defaulting to 1; the price table can override it per country (exp_to_gold_rate), which the
* local service does not send.
* local server does not send.
*/
import { numberField } from './blk-fields.ts';
import type { Dataset } from './dataset.ts';
Loaded 100 of 476 files, more files were not shown because too many files have changed in this diff. Show more