Launcher under Wine/Proton writes model paths the game's own prefix can't reach (C: instead of Z:)

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

The issue says the change and tests already exist on the author's fork in commit 51f28a4, with UnderWine() from commit 35077de as a dependency. Before starting, compare those commits with wg_core/util.cpp and install.cpp and coordinate with the author, who offers to open a PR. If work is still needed, run wg_core_tests under Wine and check that game settings use reachable Z: paths while non-Wine paths remain unchanged.

Written by the indexing model from the issue text.

Description

area: launcher area: linux game-compatibility

What happens

On Linux, players run the launcher under Wine, while Steam's Proton runs each game in a Wine prefix of its own. The launcher writes two paths into the game's settings:

  • model_dir (wronggpu.ini);
  • rr_model (wronggpu-rr.ini).

Both are written as C:\users\<user>\AppData\Local\WrongGPU\model... paths of the launcher's own prefix. The game's prefix has a different C:, so Model M and Ray Reconstruction find no model there.

Suggested fix

Under Wine, write those two paths as Z: paths: Z: maps the Linux root in every prefix, so the game reaches the same files.

  • Wine's kernel32 exports wine_get_unix_file_name, which gives the Linux name of a DOS path.
  • It fails when more than the last part of the path doesn't exist yet (the RR data's F\ folder before its first conversion). So convert the deepest folder that exists and append the rest.
  • A model_dir the player set stays as it is.
  • Detecting Wine: GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr.

The core of it, as I tested it (wg_core/util.cpp):

wstring PathForGamePrefix(const wstring& path) {
    if (path.empty() || !UnderWine()) return path;
    using UnixNameFn = char*(CDECL*)(const wchar_t*);
    auto unixName = reinterpret_cast<UnixNameFn>(reinterpret_cast<void*>(
        GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "wine_get_unix_file_name")));
    if (!unixName) return path;
    wstring head = path, tail;
    char* u = nullptr;
    while (!(u = unixName(head.c_str()))) {          // missing folders: walk up, keep the tail
        const size_t cut = head.find_last_of(L"\\/");
        if (cut == wstring::npos || cut < 3) return path;
        tail = head.substr(cut) + tail;
        head.resize(cut);
    }
    wstring z = L"Z:" + FromUtf8(u) + tail;
    HeapFree(GetProcessHeap(), 0, u);                  // Wine allocates it on the process heap
    for (wchar_t& c : z) if (c == L'/') c = L'\\';
    return z;
}

install.cpp then writes model_dir = PathForGamePrefix(ModelBaseDir()) under Wine when the player set none, and RrIniText(PathForGamePrefix(RrDataFile())). Outside Wine nothing changes: the function returns the path unchanged.

How it was tested (synthetic data only)

  • wg_core_tests under GE-Proton 11-11's Wine (llvm-mingw build): the path names the same file, and a path with two missing folders still becomes a Z: path with its tail kept. Outside Wine the path is unchanged. The missing-folder check failed with the walk-up taken out.
  • Launcher installs into generated test games, started with proton run on a new empty prefix under GE-Proton 11-11, Proton 11.0 and Proton-CachyOS, wrote model_dir=Z:\... and rr_model=Z:\...\F\model.wgcm.
  • Not run on Windows.

The change with its tests is in PR #105: commit 1b024cf, which needs only 677af52 (UnderWine()).

Related: #10.

Dominant language
C++
Stars
12
Forks
2
Avg merge
3h 10m
Merged PRs (30d)
171

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phantoslayer21/wronggpu

All issues in phantoslayer21/wronggpu

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.