game: auto-pick metin wine prefix when WINEPREFIX is unset

The default ~/.wine prefix lacks tahoma + d3dx9 + vcrun, which makes the
client run with invisible fonts and missing renderer DLLs — exactly what
Jan hit when running the launcher against a fresh install dir on Fedora.

If the parent shell already set WINEPREFIX, honor it. Otherwise fall
back to ~/metin/wine-metin, which is what
m2dev-client/scripts/setup-wine-prefix.sh prepares with the right
runtime deps. The fallback is guarded on the dir existing, so
deployments without that setup are a no-op rather than a broken prefix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jan Nedbal
2026-04-15 12:22:30 +02:00
parent d2775bcfd8
commit 027786a79d

View File

@@ -67,6 +67,21 @@ public static class GameProcess
UseShellExecute = false,
};
psi.ArgumentList.Add(exePath);
// The default ~/.wine prefix lacks tahoma + d3dx9 + vcrun, which
// makes the client run with invisible fonts and missing renderer
// DLLs. If the caller already set WINEPREFIX, honor it; otherwise
// fall back to the metin-specific prefix prepared by
// m2dev-client/scripts/setup-wine-prefix.sh.
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WINEPREFIX")))
{
var home = Environment.GetEnvironmentVariable("HOME");
if (!string.IsNullOrEmpty(home))
{
var metinPrefix = Path.Combine(home, "metin", "wine-metin");
if (Directory.Exists(metinPrefix))
psi.Environment["WINEPREFIX"] = metinPrefix;
}
}
}
else
{