Implement 40250 classic client port
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
# 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 1–4 和 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` 使用仓库自带 CONFIG:auth `11000`、channel1/first `13000`,
|
||||
并启动 channel1–4 与 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 不同的测试构建。
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ "$(uname -s)" != "FreeBSD" ]; then
|
||||
echo "build_server.sh: 40250 server Makefile is FreeBSD-only" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
server_root=${MT40250_ROOT:-/usr/metin2}
|
||||
if [ ! -d "$server_root/src/server" ]; then
|
||||
echo "build_server.sh: missing $server_root/src/server" >&2
|
||||
exit 2
|
||||
fi
|
||||
if ! command -v gmake >/dev/null 2>&1; then
|
||||
echo "build_server.sh: install gmake first" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
cd "$server_root"
|
||||
gmake -C src/server all
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
server_root=${MT40250_ROOT:-/usr/metin2}
|
||||
runtime="$server_root/server"
|
||||
if [ "$(uname -s)" != "FreeBSD" ]; then
|
||||
echo "prepare_runtime.sh: runtime binaries are FreeBSD-only" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ ! -x "$runtime/install.sh" ]; then
|
||||
echo "prepare_runtime.sh: missing $runtime/install.sh" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
cd "$runtime"
|
||||
sh ./install.sh
|
||||
echo "40250 runtime links and log/core directories ready under $runtime"
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cli=${MTGODOT_CLASSIC_E2E:-}
|
||||
if [ -z "$cli" ]; then
|
||||
build_root=${MTGODOT_CLASSIC_BUILD:-build-classic}
|
||||
cli="$build_root/net_classic_e2e_host"
|
||||
fi
|
||||
if [ ! -x "$cli" ]; then
|
||||
echo "run_classic_e2e.sh: missing $cli; build with -DMTGODOT_BUILD_NET_TOOLS=ON" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
host=${MT40250_GAME_HOST:-127.0.0.1}
|
||||
port=${MT40250_GAME_PORT:-13000}
|
||||
: "${MT40250_ACCOUNT_ID:?set MT40250_ACCOUNT_ID}"
|
||||
: "${MT40250_ACCOUNT_PASSWORD:?set MT40250_ACCOUNT_PASSWORD}"
|
||||
slot=${MT40250_CHARACTER_SLOT:-0}
|
||||
timeout=${MT40250_E2E_TIMEOUT_SECONDS:-30}
|
||||
|
||||
exec "$cli" "$host" "$port" "$MT40250_ACCOUNT_ID" "$MT40250_ACCOUNT_PASSWORD" "$slot" "$timeout"
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
dump_root=${MT40250_DUMP_ROOT:-/usr/metin2_mysql_dump}
|
||||
mysql_bin=${MT40250_MYSQL_BIN:-}
|
||||
if [ -z "$mysql_bin" ]; then
|
||||
mysql_bin=$(command -v mysql || true)
|
||||
fi
|
||||
if [ -z "$mysql_bin" ] || [ ! -x "$mysql_bin" ]; then
|
||||
echo "setup_mysql.sh: mysql client not found" >&2
|
||||
exit 2
|
||||
fi
|
||||
for db in account common log player; do
|
||||
if [ ! -f "$dump_root/$db.sql" ]; then
|
||||
echo "setup_mysql.sh: missing $dump_root/$db.sql" >&2
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
db_password=${MT40250_DB_PASSWORD:-password}
|
||||
case "$db_password" in
|
||||
*"'"*) echo "setup_mysql.sh: DB password may not contain a single quote" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
mysql_root() {
|
||||
if [ -n "${MT40250_MYSQL_ROOT_PASSWORD:-}" ]; then
|
||||
MYSQL_PWD="$MT40250_MYSQL_ROOT_PASSWORD" "$mysql_bin" -u root "$@"
|
||||
else
|
||||
"$mysql_bin" -u root -p "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
mysql_root -e "CREATE DATABASE IF NOT EXISTS account; CREATE DATABASE IF NOT EXISTS common; CREATE DATABASE IF NOT EXISTS log; CREATE DATABASE IF NOT EXISTS player; CREATE USER IF NOT EXISTS 'metin2'@'localhost' IDENTIFIED BY '$db_password'; CREATE USER IF NOT EXISTS 'metin2'@'127.0.0.1' IDENTIFIED BY '$db_password'; ALTER USER 'metin2'@'localhost' IDENTIFIED BY '$db_password'; ALTER USER 'metin2'@'127.0.0.1' IDENTIFIED BY '$db_password'; GRANT ALL PRIVILEGES ON *.* TO 'metin2'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'metin2'@'127.0.0.1' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||
|
||||
for db in account common log player; do
|
||||
echo "importing $db.sql"
|
||||
if [ -n "${MT40250_MYSQL_ROOT_PASSWORD:-}" ]; then
|
||||
MYSQL_PWD="$MT40250_MYSQL_ROOT_PASSWORD" "$mysql_bin" -u root "$db" < "$dump_root/$db.sql"
|
||||
else
|
||||
"$mysql_bin" -u root -p "$db" < "$dump_root/$db.sql"
|
||||
fi
|
||||
done
|
||||
|
||||
mysql_root -e "SELECT 1 AS metin2_database_ready;"
|
||||
echo "40250 databases ready"
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
server_root=${MT40250_ROOT:-/usr/metin2}
|
||||
runtime="$server_root/server"
|
||||
pid_file="$server_root/.mt40250-pids"
|
||||
if [ "$(uname -s)" != "FreeBSD" ]; then
|
||||
echo "start_server.sh: 40250 runtime is FreeBSD-only" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ ! -x "$runtime/db/db" ] || [ ! -x "$runtime/auth/auth" ]; then
|
||||
echo "start_server.sh: run prepare_runtime.sh first" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ -f "$pid_file" ]; then
|
||||
echo "start_server.sh: $pid_file exists; stop the existing server first" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
launch() {
|
||||
name=$1
|
||||
dir=$2
|
||||
bin=$3
|
||||
if [ ! -x "$dir/$bin" ]; then
|
||||
echo "start_server.sh: missing $dir/$bin" >&2
|
||||
exit 2
|
||||
fi
|
||||
(
|
||||
cd "$dir"
|
||||
exec "./$bin"
|
||||
) >> "$dir/console.log" 2>&1 &
|
||||
pid=$!
|
||||
echo "$pid $name" >> "$pid_file"
|
||||
echo "started $name pid=$pid"
|
||||
}
|
||||
|
||||
: > "$pid_file"
|
||||
launch db "$runtime/db" db
|
||||
sleep "${MT40250_DB_WAIT_SECONDS:-2}"
|
||||
launch auth "$runtime/auth" auth
|
||||
|
||||
channels=${MT40250_CHANNELS:-"1 2 3 4"}
|
||||
for channel in $channels; do
|
||||
for node in first game1 game2; do
|
||||
launch "channel${channel}/${node}" "$runtime/channel${channel}/${node}" game
|
||||
done
|
||||
done
|
||||
|
||||
if [ "${MT40250_START_GAME99:-1}" = "1" ]; then
|
||||
launch game99 "$runtime/game99" game
|
||||
fi
|
||||
|
||||
echo "40250 server started; logs are under $runtime/*/console.log"
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
server_root=${MT40250_ROOT:-/usr/metin2}
|
||||
pid_file="$server_root/.mt40250-pids"
|
||||
if [ ! -f "$pid_file" ]; then
|
||||
echo "stop_server.sh: no $pid_file"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while read -r pid name; do
|
||||
case "$pid" in
|
||||
''|*[!0-9]*) continue ;;
|
||||
esac
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
echo "stopped $name pid=$pid"
|
||||
fi
|
||||
done < "$pid_file"
|
||||
|
||||
rm -f "$pid_file"
|
||||
Reference in New Issue
Block a user