docs(dev-docs): add common implementation pitfalls and PR self-check
This commit is contained in:
1 parent
4e99d2c484
commit
c8ba395e4f
3 files changed
+38
No files matched your search
@@ -23,6 +23,20 @@
|
||||
|
||||
本地服务器每次启动加载数值配置。数据目录下的同名 `tuning/*.jsonc` 可逐键覆盖默认对象。数字、字符串和列表整体替换。
|
||||
|
||||
## 常见实现陷阱与工程红线(含 AI 辅助开发对照)
|
||||
|
||||
欢迎借助 AI 助手阅读反汇编、排查日志和定位根因。实际提交改动时,请按下列正反对照逐条收口实现,确保补丁在后续小版本更新与长期维护中依然健壮:
|
||||
|
||||
| 维度 | 推荐做法 | 避免做法 |
|
||||
| --- | --- | --- |
|
||||
| 定位与偏移 | exe 补丁与 native 模块一律通过 `patches/exe/`、`patches/native/` 的 `signature`、`string_ref`、`within` 动态捕获地址、跳转目标和结构体偏移 | 在 C/TS 代码中硬编码 RVA、结构体偏移、函数地址或 `_ReturnAddress` |
|
||||
| 改动分层 | 先核对服务端协议、任务根字段与原版配置能否解决;协议层、规则层、存档层、数据层职责分离,修改档案先写盘再回复 | 用客户端硬补丁绕开本该由本地服务器解决的问题,或在协议处理器里堆砌业务规则、先回成功再写盘 |
|
||||
| 静态数据与数值 | 游戏文件已有的载具、任务、奖励、出生点等一律通过缓存 `datasets/` 从玩家原版文件读取;离线自定参数进 `apps/server/tuning/*.jsonc` 并做启动校验 | 在代码里手抄原版数值、写死兜底坐标或散落魔法数字 |
|
||||
| 复用与粒度 | 复用 `local_mp_core` 等公共站点与现有模块;共享库 `packages/*` 通过参数收配置;文件接近 300 行、函数接近 50 行时拆分职责 | 重复挂钩同一原生函数、让 `packages/*` 反向读取 `apps/*`、把多类职责塞进单个大文件或大函数 |
|
||||
| 编译器与运行环境 | Native C 代码严格兼容 MSVC(`native/wto-net/build.ps1` 0 警告);TS 代码兼容 Node 24 原生类型剥离(`erasableSyntaxOnly`) | 引入 GCC 专属扩展或未在 MSVC 编译核对的 C 语法 |
|
||||
| 校验与验收 | 按改动执行对应的 `typecheck`、`check-patches`、完整 `check-gui`(Quirrel 字节码检查)与临时副本构建,如实记录未实机项 | 只靠单测或静态推演就宣称已验证通过;跳过 `check-gui`;在未实机验收前提交 `patches/versions/*.jsonc` |
|
||||
| 范围与协作规范 | 一笔 PR 专注单一目标,使用英文约定式提交与英文代码注释,只保留实际人类协作者的 `Co-authored-by` | 夹带无关格式化/重构、写入个人本机路径或把 AI 助手署名为 `Co-authored-by` |
|
||||
|
||||
## 本地开发与材料
|
||||
|
||||
- 游戏只在专用副本和隔离环境里启动。启动前验证断网限制、本地服务、Steam 和账号身份,以及文件、注册表、机器标识、反作弊和崩溃上报的隔离。需要观察启动行为时,在一次性环境里核对前后变化。原版来源只读,通过离线副本启动并使用本地账号。
|
||||
@@ -52,6 +66,20 @@ Use game data and official material as the first sources for economic defaults.
|
||||
|
||||
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.
|
||||
|
||||
## Common implementation pitfalls (especially with AI-assisted PRs)
|
||||
|
||||
Using AI tools to inspect binaries, trace logs, and pinpoint root causes is welcome. Before opening a PR, verify the implementation itself against these engineering guardrails so changes stay maintainable across game updates:
|
||||
|
||||
| Area | Preferred practice | Avoid |
|
||||
| --- | --- | --- |
|
||||
| Locating & offsets | Resolve addresses, jump targets, and struct offsets dynamically via `signature`, `string_ref`, or `within` captures in `patches/exe/` and `patches/native/` | Hardcoding RVAs, struct offsets, raw function pointers, or `_ReturnAddress` checks in C or TypeScript |
|
||||
| Layering | Solve in the local server or stock config first; separate protocol, rules, persistence, and datasets, and write saves to disk before returning success | Adding client workarounds for server-solvable issues, mixing game rules into protocol handlers, or replying before persistence |
|
||||
| Static data & tuning | Extract stock vehicle, mission, reward, and spawn data from player archives via cached `datasets/`; put offline defaults in `apps/server/tuning/*.jsonc` with startup validation | Copying stock numbers into source code, hardcoding fallback coordinates, or scattering magic constants |
|
||||
| Reuse & modularity | Reuse shared native sites (`local_mp_core`) and existing helpers; pass paths/config into `packages/*`; split files near 300 lines or functions near 50 lines | Registering duplicate hooks for the same symbol, reading `apps/*` from `packages/*`, or growing monolithic handlers |
|
||||
| Toolchains | Keep native C code cleanly buildable with MSVC (`native/wto-net/build.ps1`, zero warnings) and TS compatible with Node 24 erasable syntax | Relying on GCC-only extensions or submitting C changes without an MSVC build |
|
||||
| Verification | Run the matching `typecheck`, `check-patches`, full `check-gui` (Quirrel bytecode check), and temporary copy build; clearly mark pending in-game checks | Relying on mock/unit tests as proof of in-game correctness, skipping `check-gui`, or committing `patches/versions/*.jsonc` before live acceptance |
|
||||
| Scope & hygiene | Keep each PR focused on one change, use English conventional commits and English comments, and reserve `Co-authored-by` for human collaborators | Mixing unrelated refactors, leaking local paths, or attributing AI tools in `Co-authored-by` |
|
||||
|
||||
## 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.
|
||||
|
||||
Reference in new issue
Block a user