diff --git a/README.md b/README.md index 78392d7..377e1d7 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,22 @@ A tool aimed at enhancing the experience when playing the game on linux through 1. Copy the file `er-patcher` to the game directory. 2. In steam, set the game launch options to `python er-patcher ARGS -- %command%` See [Features](#features) for available options. - - Example: `python er-patcher --all --rate 30 --disable-rune-loss -- %command%` - - Example using the [seamless co-op](https://www.nexusmods.com/eldenring/mods/510) mod: `python er-patcher --all --executable launch_elden_ring_seamlesscoop.exe -- %command%` - - Example using [MangoHud](https://github.com/flightlessmango/MangoHud) and wine fullscreen FSR: `python er-patcher --rate 144 -uvca -- env WINE_FULLSCREEN_FSR=1 MANGOHUD=1 MANGOHUD_CONFIG=histogram %command%` + - Example: + + `python er-patcher --all --rate 30 --disable-rune-loss -- %command%` + + - Example using the [Seamless Co-op](https://www.nexusmods.com/eldenring/mods/510) mod: + + `python er-patcher --all --executable ersc_launcher.exe -- %command%` + + - Example using [MangoHud](https://github.com/flightlessmango/MangoHud) and wine fullscreen FSR: + + `python er-patcher --rate 144 -uvca -- env WINE_FULLSCREEN_FSR=1 MANGOHUD=1 MANGOHUD_CONFIG=histogram %command%` + + - Example for enabling HDR using gamescope on Linux (reported to work on Plasma 6.1): + + `ENABLE_GAMESCOPE_WSI=1 DXVK_HDR=1 gamescope -W 3440 -H 1440 -f -r 165 --hdr-enabled -- python er-patcher --all --rate 165 -- %command%` + 3. Launch the game through steam. `er-patcher` automatically launches a patched version of `eldenring.exe` with EAC disabled. Note: There might be some distros (e.g. older Ubuntu releases) that launch python 2 instead of 3 when running `python`. In that case you'll need to replace `python` with `python3` in the launch option line. @@ -47,6 +60,8 @@ The patcher works just as well on windows. The following launch option line work Note: This spawns a python console which will close by itself after the game has finished running. If you find this annoying you can try using `pythonw` instead. In any case `python` needs to be in PATH for windows to find it. +Note 2: Ensure Vertical Sync is turned off for Elden Ring in Nvidia Control Panel / AMD Radeon Software / Intel Graphics Command Center, otherwise the custom framerate limit feature won't work. + ## How it works When the game is launched through steam, the tool creates a patched version of `eldenring.exe` in a temporary subdirectory while leaving the original intact. As long the flag `--with-eac` is not set, the tool modifies the steam launch command to launch the patched executable instead of `start_protected_game.exe`, thefore ensuring that the patched exe is never run with EAC enabled. After the game is closed, the patched executable is removed. diff --git a/er-patcher b/er-patcher index f328e0d..2e51c39 100755 --- a/er-patcher +++ b/er-patcher @@ -7,7 +7,23 @@ from pathlib import Path import struct import re from shutil import rmtree +import os +import time +def cleanup(game_dir_patched): + if game_dir_patched.exists(): + eldenring_path = game_dir_patched / "eldenring.exe" + while eldenring_path.exists(): + try: + os.remove(eldenring_path) + break + except PermissionError: + # eldenring.exe is still running, retry in 3 s + time.sleep(3) + except Exception as e: + print(f"er-patcher: could not delete {eldenring_path}: {e}") + break + rmtree(game_dir_patched) if __name__ == "__main__": @@ -37,7 +53,7 @@ if __name__ == "__main__": exe_hex = f.read().hex() if patch.rate != 60 and patch.rate > 0: - r_pattern = "c7 43 20 89 88 88 3c eb 43 89 73 18 eb ca 89 73 18".replace(" ", "") + r_pattern = "c7 43 1c 89 88 88 3c eb 6d 89 73 18 eb c7 89 73 18".replace(" ", "") if (res := re.search(r_pattern, exe_hex)) is not None: r_addr = res.span()[0] + 6 r_patch = struct.pack('