Skip to content

About

An open-source Diablo II closed realm: the d2linux game server (native Linux, no Wine) plus realmd (Battle.net login, realm and character database) on redis + PostgreSQL.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

51 Commits

Folders and files

Repository files navigation

d2-opensource-server

An open-source Diablo II closed realm: the d2linux game server (native Linux, no Wine) plus realmd (Battle.net login, realm and character database) on redis + PostgreSQL.

The target platform is linux/amd64. The game server is an i386 ELF and needs an amd64 host with i386 multilib. The Raspberry Pi (arm64) is a separate deployment with its own compose and Dockerfiles, documented separately — it does not use scripts/up.sh.

engine/        d2linux — the game server (C++, i386 game slice + native host)
realm/         realmd + the redis/PostgreSQL compose stack (Zig)
scripts/       bring the realm up, supervise the game server (amd64)
pi/            the Raspberry Pi deployment: its own compose + Dockerfile
docs/          handoff notes, feature list, phase history

Game data

The server reads the MPQs and txt tables from a Diablo II 1.14d install, which is not in this repo (same for the realm's game-data/ — the gs-native image bakes it, d2linux reads it from disk). Point D2_GAME_DATA at it (defaults to ~/workspace/D2_MPQ):

export D2_GAME_DATA=/path/to/d2-install

Requirements

  • Linux x86-64 (amd64)
  • Docker + Docker Compose (for realmd/redis/PostgreSQL)
  • CMake, Ninja, a C++ compiler with i386 multilib support
  • Zig 0.16.0 — the pinned toolchain is in ../toolchain/ of the original working tree; system Zig is the wrong version for the realm build

Build the game server

cmake -S engine -B engine/build-i386 -G Ninja -DD2LINUX_ARCH=i386
cmake --build engine/build-i386 --target d2linux
./engine/build-i386/d2linux --smoke     # headless regression gate

The binary is engine/build-i386/d2linux. Configure without a CMAKE_BUILD_TYPE — the source tree needs the unoptimised flags (an optimised build trips a glibc stdio extern-inline conflict).

D2LINUX_ARCH=i386 is the only build that contains the game. The 481 decompiled game TUs assume the 32-bit MSVC x86 ABI (32-bit pointers, 16-bit wchar_t, byte-matched struct offsets), so -DD2LINUX_ARCH=native builds the host skeleton and shims without them — it is a CI/sandbox shape, not a server.

Raspberry Pi (arm64)

The Pi has its own compose and Dockerfiles in pi/; it does not use scripts/up.sh, which is the linux/amd64 path. The short version: the realm half is native aarch64, and the i386 game server runs under qemu-user.

git submodule update --init --recursive
cp realm/deploy/.env.example realm/deploy/.env    # set D2_LAN_IP
export D2_GAME_DATA=/path/to/your/d2-1.14d-install
pi/up.sh

See pi/README.md for why the game server is emulated and what to expect from it.

Bring up the realm

./scripts/up.sh

That starts realmd, redis and PostgreSQL via compose, waits for health, and starts d2linux against the realm store. It goes down first (fleet state lives in redis) — about 10 seconds of downtime.

The game server is also available as a systemd unit so a crash restarts it:

sudo ./engine/tools/install-d2linux.sh
systemctl status d2linux
journalctl -u d2linux -f

Run the game server by hand

D2LINUX_GAME_PORT=4010 ./engine/build-i386/d2linux \
  --server --game-dir="$D2_GAME_DATA" --server-name=p3test \
  --realm-store=127.0.0.1:6379 --realm-ip=192.168.0.16 --realm-port=4010

--realm-ip is the address clients are told to dial — never 127.0.0.1.

Tests

  • ./engine/build-i386/d2linux --smoke — engine regression gate
  • realm/zig-out/bin/stress-e2e — clientless round-loop verifier (build with zig build stress-e2e in realm/)

Status

Field-proven with the real D2VP 1.14d client: in-world play, gamble refresh, per-account shared stash (four paths: std / stdlad / hc / hclad), ladder and non-ladder separation, character saves, empty-game reaping. See docs/HANDOFF-P3.md for the full state and the remaining items.

Credits

This repo builds upon previous work.

  • VTSTech/D2VP-QoL (MIT, © the Redivivus contributors) — the decompilation of 1.14d's Game.exe that engine/ builds from. Pinned at 930302f on the linux branch.
  • VTSTech/Glide3xVK — the Vulkan translation layer the renderer can use.
  • jaenster/d2-dedicated-server (MIT, © jaenster) — realmd, the Zig realm server, and the compose stack it runs on. Pinned at b661cac.
  • libsdl-org/SDL (zlib) — the windowing and input layer, vendored as a submodule at release-3.4.18.
  • jaenster/libd2 — the clean-room 1.14d file formats and Battle.net protocol models.
  • jaenster/d2-clientless — the clientless d2-realm/d2-session modules stress-e2e drives real games through.
  • karlseguin/pg.zig — the Postgres client.

Diablo® II and Diablo® II: Lord of Destruction® are trademarks of Blizzard Entertainment. This is an unofficial, fan-made project, not affiliated with or endorsed by Blizzard. No Blizzard code or game data is included — see LEGAL.md.

License

MIT — see engine/LICENSE and realm/LICENSE.

About

An open-source Diablo II closed realm: the d2linux game server (native Linux, no Wine) plus realmd (Battle.net login, realm and character database) on redis + PostgreSQL.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages