-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fix for Full Metal Daemon Muramasa (#114)
* Add fix for Full Metal Daemon Muramasa * Implement fix for Full Metal Daemon Muramasa
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Game fix for Full Metal Daemon Muramasa | ||
This game is borked on gog due to audio synchronization (xaudio) issues. To | ||
make this game playable, xaudio2_9.dll simply needs to be in the game | ||
directory and renamed to xaudio2_8.dll. | ||
""" | ||
|
||
import os | ||
from gzip import open as gzip_open | ||
from hashlib import sha256 | ||
from tempfile import mkdtemp | ||
from urllib.request import urlopen | ||
|
||
from protonfixes import util | ||
from protonfixes.logger import log | ||
|
||
|
||
def main(): | ||
arc = "https://github.com/user-attachments/files/16788423/xaudio2_8.dll.gz" | ||
hashsum_file = "173cac0a7931989d66338e0d7779e451f2f01b2377903df7954d86c07c1bc8fb" | ||
tmp = f"{mkdtemp()}/xaudio2_8.dll.gz" | ||
hashsum = sha256() | ||
path_dll = f"{util.get_game_install_path()}/xaudio2_8.dll" | ||
|
||
# Full Metal Daemon from gog will not have the xaudio2_8.dll | ||
if os.path.exists(path_dll): | ||
log.info( | ||
f"xaudio2_8.dll exists in '{util.get_game_install_path()}', skipping..." | ||
) | ||
return | ||
|
||
# Download the archive | ||
with urlopen(arc, timeout=30) as resp: | ||
if resp.status != 200: | ||
log.warn(f"github returned the status code: {resp.status}") | ||
return | ||
|
||
with open(tmp, mode="wb", buffering=0) as file: | ||
chunk_size = 64 * 1024 # 64 KB | ||
buffer = bytearray(chunk_size) | ||
view = memoryview(buffer) | ||
|
||
while size := resp.readinto(buffer): | ||
file.write(view[:size]) | ||
hashsum.update(view[:size]) | ||
|
||
# Verify the compessed file | ||
if hashsum_file != hashsum.hexdigest(): | ||
log.warn(f"Digest mismatch: {arc}") | ||
log.warn(f"Expected '{hashsum_file}', skipping...") | ||
return | ||
|
||
# Write xaudio2_8.dll to the game directory | ||
# NOTE: The file is actually xaudio2_9.dll from winetricks but renamed | ||
log.info("Applying fix for 'Full Metal Daemon Muramasa'...") | ||
with gzip_open(tmp, "rb") as reader: | ||
with open(path_dll, "wb") as writer: | ||
writer.write(reader.read()) |