diff --git a/docs/linux-wine.md b/docs/linux-wine.md new file mode 100644 index 00000000..079ab275 --- /dev/null +++ b/docs/linux-wine.md @@ -0,0 +1,91 @@ +# Running the client on Linux with Wine + +This is an interim path for playing and testing on Linux while a native Linux port is a longer-term goal. Wine runs the unmodified Windows build of `Metin2.exe` / `Metin2_Debug.exe` directly. Verified to reach the character selection screen on Fedora 41 with Wine 10 Staging; other modern distros should work the same. + +Use this when you want to: + +- Smoke-test the Windows binary without rebooting into Windows +- Develop server-side with a live client connected from the same machine +- Run a dev loop without owning a Windows install + +## Requirements + +- A recent Wine (10.x Staging tested, 9.x stable should work). Older than 8 may be rough on D3D9. +- `winetricks` for installing MSVC runtime, D3DX9 helper DLLs, core fonts, and Tahoma +- A copy of the client deploy folder (the one containing `Metin2.exe`, `Metin2_Debug.exe`, `assets/`, `pack/`, `bgm/`, `config/`, `log/`). The whole folder is ~4.3 GB. +- ~7 GB free disk for the writable client copy plus the Wine prefix + +On Fedora: + +```bash +sudo dnf install -y wine winetricks +``` + +On Debian/Ubuntu (use the WineHQ repo for a modern version): + +```bash +sudo apt install -y wine winetricks +``` + +## One-shot setup + +The easiest way is the helper script in this repo: + +```bash +./scripts/setup-wine-prefix.sh /path/to/windows/client ~/metin-wine +``` + +This will: + +1. Copy the client folder to `~/metin-wine/client` (needs to be on a writable filesystem, so an NTFS read-only mount won't do). +2. Create a fresh Wine prefix at `~/metin-wine/prefix`. +3. Install `vcrun2022`, `d3dx9`, `corefonts`, and `tahoma` via winetricks. +4. Print the launch command. + +See the script itself for exact steps if you prefer to run them manually. + +## Why Tahoma is required + +The client hard-codes Tahoma as its UI font. On Windows this is invisible because Tahoma ships with the OS; on a fresh Wine prefix it's missing, and the result is that the login screen renders layouts and backgrounds correctly but **all text is invisible**. You can reach the server picker and character selection, you just can't read anything. Installing Tahoma via `winetricks tahoma` fixes it in one shot. + +If the login screen looks right but has no readable text, this is what you're seeing. + +## Launching + +After setup, the launch command is just: + +```bash +cd ~/metin-wine/client +WINEPREFIX=~/metin-wine/prefix wine Metin2.exe +``` + +Use `Metin2_Debug.exe` instead of `Metin2.exe` if you want more verbose client-side logging via `OutputDebugString`. Wine will echo those to stderr when `WINEDEBUG` includes `+seh` or you pass `+outputdebugstring`. For normal play use `-all,+err`. + +## Logs and debug output + +Useful `WINEDEBUG` settings: + +- `WINEDEBUG=-all,+err` — quiet, only real errors. Use this for normal play. +- `WINEDEBUG=-all,+loaddll,+module,+err` — shows which DLLs Wine loads, handy when the client crashes early with a missing DLL. +- `WINEDEBUG=-all,+err,+seh` — captures the client's own `OutputDebugString` calls via SEH, which is how metin2's internal logging surfaces. Very noisy but useful when diagnosing client-side issues ("CResource::Load file not exist X", "CPythonNonPlayer::LoadNonPlayerData", etc.). + +Redirect to a file and grep the signal out of the noise: + +```bash +WINEDEBUG=-all,+err,+seh wine Metin2_Debug.exe >wine-run.log 2>&1 +grep -E 'OutputDebugString[AW] "' wine-run.log | sed 's/.*OutputDebugString[AW] //' | sort -u +``` + +The client also writes its own logs to `log/` inside the client folder. Those are plain text and more readable than the Wine SEH traces. + +## Known quirks + +- **Wayland:** works via XWayland, no special config. If the window opens minimized or off-screen, `Alt+Tab` to find it. +- **Read-only NTFS mount:** don't try to launch from a read-only mount of your Windows partition. The client creates and writes `log/`, `config/`, and cache files; on a read-only FS the launch will be confusing. Always copy to a writable location first. `setup-wine-prefix.sh` does this for you. +- **DXVK render state warnings:** lines like `D3D9DeviceEx::SetRenderState: Unhandled render state 163` in the log are harmless. DXVK doesn't implement every legacy D3D9 render state, but the ones metin2 cares about all work. +- **SEH dispatch spam:** `dispatch_exception code=4001000a` / `4001000c` are how Windows signals `OutputDebugStringW` / `OutputDebugStringA`. They're soft exceptions, not errors. They only show up if you enable `+seh` in `WINEDEBUG`. +- **First launch is slower:** DXVK compiles its shader pipelines on first run and writes a state cache. Subsequent launches are noticeably faster. + +## When to stop using Wine + +This guide is for the interim. The longer-term plan is a native Linux build of the client with a free-software replacement for Granny2 animation runtime. Until that lands, Wine is the way.