Files
mtgodot-poc/tools/40250/README.md
T

98 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 40250 FreeBSD + MySQL live E2E
这组脚本把文档里最后一个不能在 macOS 本机完成的前置变成可执行入口:
1. 在 FreeBSD jail/VM 准备 40250 server tree、MySQL 和 32-bit toolchain。
2. 导入 `metin2_mysql_dump/{account,common,log,player}.sql`
3. 编译(或使用已编译的)`game` / `db`,安装 server runtime links。
4. 启动 db、auth、channel 14 和 game99。
5.`net_classic_e2e_host` 验证 DH2/CTR、登录、选角和 `PHASE_GAME`
当前 Mac 环境没有 FreeBSD 或 MySQL server,因此这里只能完成脚本、构建配置和
离线协议测试;不能把真实服结果冒充为已执行。脚本均使用环境变量,避免把本机
路径或密码写死到工程中。
## 复制/准备目录
```sh
export MT40250_ROOT=/usr/metin2
export MT40250_DUMP_ROOT=/usr/metin2_mysql_dump
```
`MT40250_ROOT` 必须是包含 `src/server``server/` 的 40250 server tree。
官方 Makefile 默认把二进制放到 `/usr/metin2/server/share/bin`,所以推荐保持
这个路径;若使用其他路径,必须同时确保 Makefile 的 `GAMEDIR`/`DBDIR` 指向
对应 runtime 目录。
## FreeBSD 安装与编译
依赖由管理员按镜像版本安装,典型组合如下(具体包名以目标 FreeBSD 版本为准):
```sh
pkg install gmake clang-devel mysql80-server mysql80-client
sh tools/40250/build_server.sh
```
源码 Makefile 是 40250 原版,使用 `clang++-devel``-m32`、静态 MySQL client、
Crypto++ 8.4.0 和 FreeBSD 系统库;`build_server.sh` 会执行原始的 `gmake -C
src/server all`,失败时应保留完整编译输出修复 jail 的 32-bit/库依赖。
## 初始化数据库
先启动 MySQL,再执行:
```sh
export MT40250_MYSQL_ROOT_PASSWORD='你的 root 密码' # 不设置则每次交互式 -p
export MT40250_DB_PASSWORD=password # 必须与 CONFIG 一致,默认 password
sh tools/40250/setup_mysql.sh
```
脚本创建 `account/common/log/player`,并同时建立 `metin2@localhost`
`metin2@127.0.0.1`;这是因为 CONFIG 使用 TCP `127.0.0.1`,而旧 Readme 只写了
`localhost`。导入后会执行最小连接检查。
## 启停 40250 服务
```sh
sh tools/40250/prepare_runtime.sh
sh tools/40250/start_server.sh
sh tools/40250/stop_server.sh
```
`start_server.sh` 使用仓库自带 CONFIGauth `11000`、channel1/first `13000`
并启动 channel14 与 game99。每个进程的 stdout/stderr 写入其 runtime 目录的
`console.log`PID 只记录在 `$MT40250_ROOT/.mt40250-pids`;停止脚本只终止这份
PID 文件中的进程。可用 `MT40250_CHANNELS='1'` 只启动 channel1,或设置
`MT40250_START_GAME99=0` 跳过 game99。
## 编译/运行 classic 探针
FreeBSD 不能启用 Godot extension,但顶层 CMake 提供了 host-only 模式:
```sh
cmake -S . -B build-classic \
-DMTGODOT_BUILD_EXTENSION=OFF \
-DMTGODOT_BUILD_NET_TOOLS=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build build-classic --target net_classic_e2e_host -j2
build-classic/net_classic_e2e_host 127.0.0.1 13000 test_account test_password 0 30
```
探针成功的判据是输出 `PASS PHASE_GAME`,并且打印主角 VID、实体数、背包槽位数
和等级。它不会自动创建角色、交易、购买或移动仓库物品;这些操作属于有副作用的
fixture 测试,应在测试账号/NPC/第二账号准备后通过 Godot UI 或对应 `M2Client`
intent 逐项操作:好友 add/remove、exchange start/item/gold/accept/cancel、
NPC safebox checkin/checkout/move、mall checkout、Cube open/add/delete/make。
## 40250 配置核对
- `auth/CONFIG`: `PORT 11000`
- `channel1/first/CONFIG`: `PORT 13000``MAP_ALLOW` 包含起始地图。
- 所有 CONFIG 的 DB 端口是 `15000`,由 `server/db/conf.txt` 控制。
- `PLAYER_SQL` 指向 `player`auth 的 `PLAYER_SQL` 指向 `account`,两者与原服
源码约定一致。
- `service.h` 默认定义 `_IMPROVED_PACKET_ENCRYPTION_`classic 客户端必须走
DH2 + CTR,不能用“明文配置项”绕过。若专门做明文诊断,必须复制源码、重新
编译 game,并把它视为与 shipped server 不同的测试构建。