Triforce v0.8.0

Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-25 10:21:32 -06:00
parent 861702476a
commit 4fa4f9188b
881 changed files with 179428 additions and 15581 deletions

View File

@@ -5,9 +5,12 @@ ahead on a hard drive.
spinning(path) -> True for a spinning disk, False for an SSD or flash, None when it cannot be told (a network share, an unknown
device, another operating system). Windows asks the volume for its seek penalty (IOCTL_STORAGE_QUERY_PROPERTY,
StorageDeviceSeekPenaltyProperty: a disk that seeks says so); Linux reads the kernel's queue/rotational for the device behind the
folder, through its partitions and device-mapper/RAID slaves.
folder, through its partitions and device-mapper/RAID slaves. A Btrfs folder's device number is no disk's, so its disks are
those its mount names.
"""
import glob
import os
import stat
import sys
@@ -72,34 +75,100 @@ def _windows_spinning(path):
kernel32.CloseHandle(handle)
def _linux_spinning(path):
def _linux_spinning(path, mountinfo="/proc/self/mountinfo", sysfs="/sys"):
"""queue/rotational of the block device behind path's file system"""
try:
st = os.stat(path)
except OSError:
return None
return _device_rotational("/sys/dev/block/%d:%d" % (os.major(st.st_dev), os.minor(st.st_dev)))
node = os.path.join(sysfs, "dev", "block", "%d:%d" % (os.major(st.st_dev), os.minor(st.st_dev)))
if os.path.exists(node):
return _device_rotational(node)
# (Btrfs numbers its files' device itself, a number a subvolume and none of them a disk's (0:38): sysfs has no such node, and
# the walk below ended at None, so a hard drive with Btrfs on it, as Fedora, Bazzite and CachyOS format one, never warned)
answers = [a for a in (_device_rotational(n) for n in _mounted_from(path, mountinfo, sysfs)) if a is not None]
return any(answers) if answers else None
def _device_rotational(node, depth=0):
def _unescaped(field):
"""A mountinfo field as the path it stands for: a space, tab, newline and backslash in it are written \\040, \\011, \\012, \\134"""
parts = field.split("\\")
return parts[0] + "".join(chr(int(p[:3], 8)) + p[3:] if p[:3].isdigit() else "\\" + p for p in parts[1:])
def _block_node(device, sysfs="/sys"):
"""sysfs's node of a block device file (/dev/sda2); None for anything else (a network share's or ZFS's name)"""
try:
st = os.stat(device)
except OSError:
return None
if not stat.S_ISBLK(st.st_mode):
return None
return os.path.join(sysfs, "dev", "block", "%d:%d" % (os.major(st.st_rdev), os.minor(st.st_rdev)))
def _mounted_from(path, mountinfo="/proc/self/mountinfo", sysfs="/sys"):
"""sysfs's nodes of the block devices path's file system was mounted from: the one its mount names, and for a Btrfs over
several disks every one of them (the mount names one; /sys/fs/btrfs/<id>/devices has them all)"""
path, found = os.path.realpath(path), None
with open(mountinfo, encoding="utf-8", errors="surrogateescape", newline="\n") as f:
for line in f: # (id, parent, device, root, mount point, options... - type, source, options)
mount, dash, source = line.rstrip("\n").partition(" - ")
mount, source = mount.split(" "), source.split(" ")
if not dash or len(mount) < 5 or len(source) < 2:
continue
point = _unescaped(mount[4])
inside = path == point or path.startswith(point.rstrip("/") + "/")
if inside and (found is None or len(point) >= len(found[0])): # (the deepest; of two at one point, the later is on top)
found = (point, source[0], _unescaped(source[1]))
node = _block_node(found[2], sysfs) if found else None
if not node:
return []
if found[1] == "btrfs":
for devices in glob.glob(os.path.join(glob.escape(sysfs), "fs", "btrfs", "*", "devices")):
nodes = [os.path.join(devices, n) for n in sorted(os.listdir(devices))]
if os.path.realpath(node) in [os.path.realpath(n) for n in nodes]:
return nodes
return [node]
def _device_rotational(node):
"""The device behind sysfs's node: its slaves decide for device-mapper and RAID (any spinning one makes it slow), and a
partition's own folder has no queue/rotational, so the disk above it is read"""
path = os.path.realpath(node)
if depth < 4:
slaves = os.path.join(path, "slaves")
try:
names = sorted(os.listdir(slaves))
except OSError:
names = []
answers = [a for a in (_device_rotational(os.path.join(slaves, n), depth + 1) for n in names) if a is not None]
if answers:
return any(answers)
while True:
try:
with open(os.path.join(path, "queue", "rotational"), encoding="ascii") as f:
return f.read().strip() == "1"
except OSError:
up = os.path.dirname(path)
if up == path:
return None
path = up
root = os.path.realpath(node)
answers, active = {}, set()
pending = [(root, None)]
while pending:
path, children = pending.pop()
if children is None:
if path in answers or path in active:
continue
active.add(path)
slaves = os.path.join(path, "slaves")
try:
names = sorted(os.listdir(slaves))
except OSError:
names = []
children = [os.path.realpath(os.path.join(slaves, n)) for n in names]
# Postorder without recursion or a depth cap. A back edge has no answer;
# completed nodes are cached so shared slaves are only read once.
pending.append((path, children))
pending.extend((child, None) for child in reversed(children))
continue
known = [answers[c] for c in children if answers.get(c) is not None]
answer = any(known) if known else None
if not known:
parent = path
while True:
try:
with open(os.path.join(parent, "queue", "rotational"), encoding="ascii") as f:
answer = f.read().strip() == "1"
break
except OSError:
up = os.path.dirname(parent)
if up == parent:
break
parent = up
answers[path] = answer
active.remove(path)
return answers[root]