MushRog

一台真正的测试服务器

2026年10月14日 arquiteturabastidores

机器翻译,尚未审校。

MushRog 有了一台放在互联网上的测试服务器。菜单里的“在线游戏”按钮现在直接连到它,不用再有人在自己的电脑上开服务器了。

为什么

到目前为止,想一起玩,得有人以主机身份打开游戏,再把 IP 发给对方。两台电脑之间测试够用,但没法拉人来玩。租机器之前,我们先量了每个玩家在网络上的开销,算下来根本撑不住。

怎么运作

在房间里,服务器每秒 20 次发送整场战斗的完整状态:每次 7 到 16 KB,每个玩家大约 250 KB/s。如果 50 个人都在房间里,就是 100 Mbit/s。

我们把几乎不变的部分(名字、外观、属性、房间地图)和每时每刻都在变的部分(位置、生命值、冷却、攻击)分开了。前一部分只在变化时才发送。后一部分用精简的二进制格式,每只怪物大约 25 字节。我们用四个玩家不停放技能的情况来测:在团队突袭里,每个玩家从 250 降到 15 KB/s,在地下城里从 200 降到 11,而且还要再过一层压缩。整体小了 17 到 27 倍。

服务器跑在一台 VPS 上,用 dedicated 模式、没有图形,作为一个挂掉会自己重启的服务。这台机器只接受用密钥的 SSH 和游戏端口,会封掉多次输错密码的人,每天凌晨自动更新,并且每天备份账号。我们还没有域名,所以客户端指向的是 IP。既然是测试服务器,它可以被清空重来。

下一步

叫第一批朋友同时来玩,看看什么会坏。

变更

  • perf(net): room state split into fixed info and a binary tick

    Rooms used to send the whole sim as a Dictionary 20 times a second (7 to 16 KB each). Now the fixed part (names, looks, stats, room meta, who exists and in what order) goes reliable only when it changes, and every tick sends a binary block in that order: positions in 1/32 px, timers in centiseconds, auras and phases as indexes. A tick that does not match the fixed version waits for the new one. Frozen time now reaches the client too. ENet range coder compression on both ends. Measured with 4 players spamming skills: explore 250 -> 15 KB/s per player, dungeon 203 -> 11, farm 314 -> 12, before compression. The explore pause is a fixed end time in meta so it does not resend the fixed part every tick. Protocol 13.

  • feat(deploy): staging VPS with a dedicated Linux server

    Linux Server export preset (dedicated server, main scene overridden to server/server.tscn). deploy/staging has the provisioning script (admin user with key-only SSH, service user without shell, ufw with SSH rate limit and the game port, fail2ban, unattended security upgrades with a 04:30 reboot, sysctl hardening, journald cap), the SSH lockdown, a sandboxed systemd unit and a daily backup timer. tools/deploy_staging.sh builds, uploads over one multiplexed SSH connection, swaps the current release link, restarts and keeps the last five releases. The client menu gets Jogar online pointing at the staging IP until there is a domain. Version 0.2.1.

← 返回开发日志