90 lines
4.9 KiB
Markdown
90 lines
4.9 KiB
Markdown
# yugioh-legacy-engine
|
|
|
|
The duel engine of Yu-Gi-Oh! Legacy: the rules core and the duel server, built as ONE native
|
|
library per platform, `ygol-engine`, behind a written contract. Proposal 47 in the Unity repo
|
|
(`Docs/Proposals/GameArchitecture/47-engine-repo.md`) is the decision; this repo carries it out.
|
|
|
|
## Layout
|
|
|
|
| Path | What |
|
|
|---|---|
|
|
| `core/` | The rules core (C++, Lua 5.4 inside). Plain directory, no submodule. |
|
|
| `server/` | The duel server (C++, libevent) with its third-party sources vendored inside. Its premake builds the core from `../core`. |
|
|
| `build/windows.ps1` | Builds `out/win64/ygol-engine.dll` and runs the export gate. |
|
|
| `contract/` | The engine contract (TICKET-388). |
|
|
|
|
There is exactly one copy of the core in this repo. The server's old `ocgcore/` submodule is gone;
|
|
`server/premake5.lua` includes `../core`, and the six `gframe` sources that named `../ocgcore/`
|
|
now name `../../core/`.
|
|
|
|
## Sources (upstream is cut)
|
|
|
|
`core/` and `server/` start from two pinned upstream commits and carry our commits on top. There is
|
|
no upstream remote, subtree or submodule; a wanted upstream fix is copied in by hand as a normal commit.
|
|
|
|
| Directory | Upstream | Commit |
|
|
|---|---|---|
|
|
| `core/` | `nanahira/ygopro-core` (as vendored in the Unity repo, `Tools/YGOLegacy/ocgcore`) | `973672dc9ce7cb49f47173277ab1ad0e318b7593` |
|
|
| `server/` | `https://code.moenext.com/nanahira/ygopro.git`, branch `server` | `52c868ce071ea0f2fcb0cf39bf2fb4151d12b90c` |
|
|
|
|
The server import is the build-relevant part of that tree only: `gframe/`, `premake5.lua`, `.ci/`,
|
|
`LICENSE`, and `gframe/ygopro.rc` + `.ico` (upstream keeps them in `resource/` and copies them in
|
|
before building). No game assets, no card scripts.
|
|
|
|
Vendored third-party sources (the ones upstream's Windows CI downloads), at the positions its
|
|
premake expects, each with its premake fragment from upstream's `premake/` folder inside it:
|
|
|
|
| Dir | Source | Trimmed |
|
|
|---|---|---|
|
|
| `server/lua/` | lua 5.4.8 | no |
|
|
| `server/sqlite3/` | sqlite-autoconf 3.53.3 | no |
|
|
| `server/event/` | libevent 2.1.13-stable | tests, samples, autotools helpers; the files its Windows prebuild copies into `include/` (gitignored) |
|
|
| `server/zlib/` | zlib 1.3.2 | contrib, examples, platform folders |
|
|
| `server/lzma/` | xz 5.8.3 | `src/liblzma` + `src/common` only |
|
|
| `server/irrlicht/` | mycard irrlicht-1.9 `20f86d251624334d53585a1809ea4c7178f72a34` | `include/` plus the `source/Irrlicht` headers and the 11 `.cpp` files the server's zip reader project compiles (`premake5-only-zipreader.lua`). The pro3 server build turns zip support on, so this is source, not headers alone. |
|
|
|
|
## Fork changes as commits
|
|
|
|
The Unity repo's 24 patch files (`Tools/YGOLegacy/patches/`) are replayed here once as ordinary
|
|
commits and retire. Six core patches (0001, 0004, 0008, 0015, 0022, 0024) were already in the
|
|
vendored core when it was imported, so they are part of the `core:` import commit. The 16 server
|
|
patches are one commit each, in the order the old build script applied them:
|
|
0002, 0003, 0005, 0006, 0009, 0011, 0012, 0013, 0014, 0016, 0017, 0018, 0019, 0020, 0021, 0023.
|
|
Their `[YGOL]` markers are kept. `git log --oneline -- server/gframe` lists them.
|
|
|
|
## Build (Windows)
|
|
|
|
```powershell
|
|
git clone https://gitea.dev.blueoceanswim.com/donny/yugioh-legacy-engine.git C:\ygol-engine
|
|
pwsh C:\ygol-engine\build\windows.ps1
|
|
```
|
|
|
|
- The repo path must have NO spaces: libevent's premake emits an unquoted `xcopy` prebuild step. The
|
|
script refuses otherwise.
|
|
- Needs premake 5.0.0-beta8 (`-Premake`, default `C:\premake\premake5.exe`), VS 2022 Build Tools with
|
|
the C++ workload and a Windows 10 SDK.
|
|
- The script wipes `server/obj`, `server/bin` and `server/build` first (an incremental MSBuild once
|
|
reused a stale object and the DLL still built), runs `premake5 vs2022` in `server/` with
|
|
`SERVER_PRO3_SUPPORT=1 LOG_IN_CHAT=1 USE_SIMD=best`, then MSBuild on `build\YGOPro.sln`, target
|
|
`ygoserver`, Release x64.
|
|
- Output: `out/win64/ygol-engine.dll` (+ `.pdb`).
|
|
|
|
### The export gate is the truth
|
|
|
|
The script FAILS unless the DLL exports exactly **333** symbols: `start_server`, `stop_server`, and
|
|
the core's whole C API re-exported, including the six `ygol_sb_*` Sandbox exports and
|
|
`ygol_preview_attack`. A different count means the wrong tree, not "a small difference". For the
|
|
record: the Unity repo's old `ygoserver.dll` exported 327 because its build applied patch 0008
|
|
(the `ygol_sb_*` six) only to `ocgcore.dll`, never to the server's own core copy; with one core they
|
|
are in the one library.
|
|
|
|
The wire probe (`probe-feature-messages.py --dll out\win64\ygol-engine.dll`, in the Unity repo until
|
|
TICKET-388 moves it to `contract/`) checks the fork's messages and capability bits against a running
|
|
server.
|
|
|
|
## Line endings
|
|
|
|
The repo stores LF (`core.autocrlf=false` when importing; `git archive` on a machine with
|
|
`autocrlf=true` converts, so pass `-c core.autocrlf=false`). Irrlicht is CRLF because its upstream
|
|
stores CRLF.
|