Skip to content

Instantly share code, notes, and snippets.

@neckothy
Last active October 12, 2023 18:53
Show Gist options
  • Save neckothy/4d4aba25e993de22cc4a87d3bd04b719 to your computer and use it in GitHub Desktop.
Save neckothy/4d4aba25e993de22cc4a87d3bd04b719 to your computer and use it in GitHub Desktop.
Update or install Dark and Darker easily on Linux again
#!/bin/python
import hashlib
import os
import requests
def get_patch_list():
patch = {}
with requests.get(
"http://cdn.darkanddarker.com/Dark%20and%20Darker/PatchFileList.txt"
) as response:
response.raise_for_status()
patch_file_list = response.text
for line in patch_file_list.splitlines():
file_info = line.split(",")
name = file_info[0].replace("\\", "/")
sha256 = file_info[1]
size = file_info[2]
patch[name] = {"hash": sha256, "size": size}
return patch
def get_existing_file_hashes(cwd):
hashes = {}
for root, subdirs, files in os.walk(cwd):
for file_name in files:
file_path = os.path.join(root, file_name)
# https://stackoverflow.com/a/59056837
with open(file_path, "rb") as f:
file_hash = hashlib.sha256()
while chunk := f.read(8192):
file_hash.update(chunk)
trimmed_path = file_path[file_path.find("Dark and Darker") + 15 :]
hashes[trimmed_path] = {"hash": file_hash.hexdigest()}
return hashes
def compare_file_hashes(new, old):
to_update = []
for k in new.keys():
if k in old and new[k]["hash"] != old[k]["hash"]:
to_update.append(k)
elif k not in old:
to_update.append(k)
return to_update
def download_files(cwd, files):
print(f"{len(files)} to be updated")
for f in files:
print(f"Updating {f}")
last_dir = cwd + f[: f.rindex("/")]
if not os.path.exists(last_dir):
os.makedirs(last_dir, exist_ok=True)
with requests.get(
"http://cdn.darkanddarker.com/Dark%20and%20Darker/Patch" + f
) as response:
response.raise_for_status()
with open(cwd + f, "wb") as p:
p.write(response.content)
if __name__ == "__main__":
cwd = os.getcwd()
current_patch = get_patch_list()
existing_hashes = get_existing_file_hashes(cwd)
files_to_update = compare_file_hashes(current_patch, existing_hashes)
if files_to_update:
download_files(cwd, files_to_update)
else:
print("no updates found")

This script isn't needed anymore as Blacksmith works as intended after installing urlmon and wininet to the prefix with winetricks. It will be left up as an alternative/in case of future breakages.

Requires:

  • Python 3
  • requests

Usage (install) untested:

  1. Install the Blacksmith launcher through Lutris or other means
  2. Navigate to your IRONMACE folder (e.g. ~/Games/dark-and-darker/drive_c/Program Files/IRONMACE)
  3. mkdir "Dark and Darker"
  4. Continue to update instructions

Usage (update):

  1. Save dnd_linux_patcher.py
  2. Navigate to your Dark and Darker folder (e.g. ~/Games/dark-and-darker/drive_c/Program Files/IRONMACE/Dark and Darker)
  3. python path/to/dnd_linux_patcher.py

This attempts to at least partially emulate Blacksmith's patching by:

  1. Getting current file hashes from Dark and Darker's CDN
  2. Calculating SHA256 hashes of your existing files
  3. Comparing those hashes
  4. Downloading any files with hashes that don't match

This is a quick, personal script. It has worked as intended for me, but use at your own risk. Ensure no changes are needed for your setup and that you've read and followed the instructions properly before use.

@neckothy
Copy link
Author

neckothy commented Oct 10, 2023

Hi, thank you for this, very much. Curious if you know how to fix this server login error?

I haven't played in several weeks, but my game seems to launch, update, and connect without issue using my existing prefix. Since I haven't encountered the same issue it isn't something I can really test.

As it's a server error and not a crash or similar, I would assume it's just server/routing issues that are mostly out of your control. You could try using a VPN to connect if you don't want to wait, perhaps in a different region. If that doesn't work, you could try using something like mitmproxy or tcpdump to inspect network traffic and determine what is failing to connect.

I don't consider myself a Wine expert by any means, but I don't think those wine errors are particularly relevant to the issue. From some quick research {17072F7B-9ABE-4A74-A261-1EB76B55107A} seems to be related towscapi.dll, with wsc apparently being Windows Security Center. I'm not sure about the feasibility of getting this working properly in Wine.

edit: to clarify, I run the launcher through Lutris with lutris-GE-Proton8-13-x86_64. My prefix only has wininet and urlmon installed "extra", to allow updating from the official launcher to function properly. Everything else "just works".

edit again: added some suggestions and clarified that I don't think it's a Wine issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment