Skip to content

Commit

Permalink
proton: import upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GloriousEggroll committed Oct 31, 2024
1 parent 3450765 commit 0921d75
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion proton
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ from pathlib import Path
#To enable debug logging, copy "user_settings.sample.py" to "user_settings.py"
#and edit it if needed.

CURRENT_PREFIX_VERSION="GE-Proton9-16"
CURRENT_PREFIX_VERSION="GE-Proton9-17"

PFX="Proton: "
ld_path_var = "LD_LIBRARY_PATH"
Expand Down Expand Up @@ -526,6 +526,57 @@ def set_dir_casefold_bit(dir_path):
pass
os.close(dr)

def get_replace_reg_value(file, key, name, new_value=None):
if not file_exists(file, follow_symlinks=True):
return None
replaced = False
out = None
if new_value is not None:
out = open(file + ".new", "w")
found_key = False
old_value = None
namestr="\"" + name + "\"="
with open(file, "r") as reg_in:
for line in reg_in:
if not replaced:
if line[0] == '[':
if found_key:
if out is not None:
out.close()
return None
if line[1:len(key) + 1] == key:
found_key = True
elif found_key:
idx = line.find(namestr)
if idx != -1:
old_value = line[idx + len(namestr):]
if out is not None:
out.write(namestr + new_value)
replaced = True
continue
else:
return old_value
if out is not None:
out.write(line)

if out is not None:
out.close()

if replaced:
try:
os.rename(file, file + ".old")
except OSError:
os.remove(file)
pass

try:
os.rename(file + ".new", file)
except OSError:
log("Unable to write new registry file to " + file)
pass

return old_value

class Proton:
def __init__(self, base_dir):
self.base_dir = base_dir + "/"
Expand Down Expand Up @@ -599,6 +650,7 @@ class CompatData:
self.config_info_file = self.path("config_info")
self.tracked_files_file = self.path("tracked_files")
self.prefix_lock = FileLock(self.path("pfx.lock"), timeout=-1)
self.old_machine_guid = None

def path(self, d):
return self.base_dir + d
Expand Down Expand Up @@ -652,6 +704,7 @@ class CompatData:
(int(new_proton_maj) == int(old_proton_maj) and \
int(new_proton_min) < int(old_proton_min)):
log("Removing newer prefix")
self.old_machine_guid = get_replace_reg_value(self.prefix_dir + "system.reg", "Software\\\\Microsoft\\\\Cryptography", "MachineGuid")
if old_proton_ver == "3.7" and not file_exists(self.tracked_files_file, follow_symlinks=True):
#proton 3.7 did not generate tracked_files, so copy it into place first
try_copy(g_proton.path("proton_3.7_tracked_files"), self.tracked_files_file)
Expand Down Expand Up @@ -911,6 +964,10 @@ class CompatData:

if not file_exists(self.prefix_dir + "/user.reg", follow_symlinks=True):
self.copy_pfx()
machine_guid = self.old_machine_guid
if machine_guid is None:
machine_guid = "\"" + str(uuid.uuid4()) + "\""
get_replace_reg_value(self.prefix_dir + "system.reg", "Software\\\\Microsoft\\\\Cryptography", "MachineGuid", machine_guid)

self.migrate_user_paths()

Expand Down Expand Up @@ -1074,6 +1131,8 @@ class CompatData:
else:
wined3dfiles.append("d3d8")

icufiles = ["icuin68", "icuuc68", "icudt68"]

for f in wined3dfiles:
try_copy(g_proton.default_pfx_dir + "drive_c/windows/system32/" + f + ".dll", "drive_c/windows/system32",
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
Expand All @@ -1094,6 +1153,11 @@ class CompatData:
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
g_session.dlloverrides[f] = "n"

for f in icufiles:
self.create_symlink(self.prefix_dir + "drive_c/windows/system32/" + f + ".dll",
g_proton.lib64_dir + "icu/" + f + ".dll")
tracked_files.write("drive_c/windows/system32/" + f + '.dll\n')

# If the user requested the NVAPI be available, copy it into place.
# If they didn't, clean up any stray nvapi DLLs.
if use_nvapi:
Expand Down Expand Up @@ -1233,6 +1297,7 @@ def default_compat_config():
"714010", #Aimlabs
"2249070", #Strip Fighter ZERO
"2526380", #Sword of Convallaria
"6030", #Star Wars - Jedi Knight II: Jedi Outcast
]:
ret.add("gamedrive")

Expand Down Expand Up @@ -1290,6 +1355,7 @@ def default_compat_config():
"255220", #GRID Autosport
"44350", #GRID 2
"2176900", #Fablecraft
"407810", #Hard Reset Redux
]:
ret.add("disablenvapi")

Expand Down

0 comments on commit 0921d75

Please sign in to comment.