fix(game-env): draw Dragon Quest Monsters 4 slime bodies (#2847)

At the game's default monster mesh detail, slimes show only their tips.
Set the two skeletal mesh detail values in Engine.ini before each launch,
in the prefix the game profile selects, and keep the file's permissions.
The game ignores -ini: overrides and deletes a writable Engine.ini after
reading it, so a launch argument or a one-time write does not work.
This commit is contained in:
Albert Carreras authored and GitHub committed 2026-11-24 17:49:44 -05:00
1 parent 049c4be6e5
commit 925e9743a8
3 files changed
+118

No files matched your search

@@ -242,6 +242,57 @@ def skip_red_launcher(command):
return command
DQM4_MESH_DETAIL = {"r.SkeletalMeshLODBias": "-4", "r.SkeletalMeshLODRadiusScale": "0.25"}
def with_system_settings(text, settings):
lines = text.splitlines()
try:
section = lines.index("[SystemSettings]")
except ValueError:
if lines and lines[-1].strip():
lines.append("")
lines.append("[SystemSettings]")
section = len(lines) - 1
end = next((i for i in range(section + 1, len(lines)) if lines[i].startswith("[")), len(lines))
block = [line for line in lines[section + 1:end] if line.split("=", 1)[0].strip() not in settings]
while block and not block[-1].strip():
block.pop()
block += ["%s=%s" % item for item in settings.items()]
tail = lines[end:]
return "\n".join(lines[:section + 1] + block + ([""] if tail else []) + tail) + "\n"
# The game ignores -ini: overrides and deletes a writable Engine.ini after reading it, so this runs at every launch.
def dragon_quest_monsters_4_mesh_detail(exe, env):
project = Path(exe).stem.split("-", 1)[0]
if not project.lower().startswith("dragonquestmonsters4"):
return
prefix = Path(env.get("STEAM_COMPAT_DATA_PATH", "/nonexistent")) / "pfx"
config = prefix / "drive_c/users/steamuser/AppData/Local" / project / "Saved/Config/Windows/Engine.ini"
try:
if not prefix.is_dir():
return
text = config.read_text(encoding="utf-8") if config.exists() else ""
updated = with_system_settings(text, DQM4_MESH_DETAIL)
if updated == text:
return
config.parent.mkdir(parents=True, exist_ok=True)
handle, staged = tempfile.mkstemp(prefix=".engine-", dir=config.parent)
try:
with os.fdopen(handle, "w", encoding="utf-8") as target:
target.write(updated)
if config.exists():
os.chmod(staged, config.stat().st_mode & 0o7777)
os.replace(staged, config)
except BaseException:
os.unlink(staged)
raise
print("droiddeck-game-env: Dragon Quest Monsters 4: full-detail monster meshes", file=sys.stderr)
except (OSError, UnicodeDecodeError) as error:
print("droiddeck-game-env: Dragon Quest Monsters 4 mesh detail left as is (%s)" % error, file=sys.stderr)
UBISOFT_LAUNCHER = "drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher"
UBISOFT_SETTINGS = "drive_c/users/steamuser/AppData/Local/Ubisoft Game Launcher/settings.yaml"
@@ -1412,6 +1463,7 @@ def main():
command = skip_red_launcher(command)
if len(command) > 2:
death_stranding_allocator(app_id, command[2])
dragon_quest_monsters_4_mesh_detail(command[2], effective_env)
ubisoft_overlay_off(env)
project_zomboid_jvm(command)
fixes, extra, notes = engine_fixes(command[2], command[3:], app_id) if len(command) > 2 else ({}, [], [])
+60
View File
@@ -1,3 +1,4 @@
import contextlib
import hashlib
import io
import json
@@ -1548,6 +1549,65 @@ class GameEnvironmentTest(unittest.TestCase):
self.assertEqual(MODULE["engine_fixes"](game, [], "42"), ({}, [], []))
self.assertEqual(MODULE["engine_fixes"](game, []), ({}, [], []))
def test_dragon_quest_monsters_4_writes_full_detail_mesh_settings(self):
apply = MODULE["dragon_quest_monsters_4_mesh_detail"]
wanted = "r.SkeletalMeshLODBias=-4\nr.SkeletalMeshLODRadiusScale=0.25\n"
for exe, project in (("DragonQuestMonsters4Demo.exe", "DragonQuestMonsters4Demo"),
("DragonQuestMonsters4-Win64-Shipping.exe", "DragonQuestMonsters4")):
with self.subTest(exe=exe), tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "pfx").mkdir()
config = Path(tmp) / "pfx/drive_c/users/steamuser/AppData/Local" / project / "Saved/Config/Windows/Engine.ini"
with contextlib.redirect_stderr(io.StringIO()):
apply("/game/" + exe, {"STEAM_COMPAT_DATA_PATH": tmp})
self.assertEqual(config.read_text(), "[SystemSettings]\n" + wanted)
def test_dragon_quest_monsters_4_keeps_other_engine_settings(self):
with tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "pfx").mkdir()
config = Path(tmp) / "pfx/drive_c/users/steamuser/AppData/Local/DragonQuestMonsters4Demo/Saved/Config/Windows/Engine.ini"
config.parent.mkdir(parents=True)
config.write_text("[Core.Log]\nLogTemp=Log\n\n[SystemSettings]\nr.Fog=0\nr.SkeletalMeshLODBias=0\n\n[Other]\nKey=1\n")
config.chmod(0o444)
with contextlib.redirect_stderr(io.StringIO()):
MODULE["dragon_quest_monsters_4_mesh_detail"]("/game/DragonQuestMonsters4Demo.exe", {"STEAM_COMPAT_DATA_PATH": tmp})
self.assertEqual(config.read_text(), "[Core.Log]\nLogTemp=Log\n\n[SystemSettings]\nr.Fog=0\n"
"r.SkeletalMeshLODBias=-4\nr.SkeletalMeshLODRadiusScale=0.25\n\n[Other]\nKey=1\n")
self.assertEqual(config.stat().st_mode & 0o777, 0o444)
def test_dragon_quest_monsters_4_settings_use_the_game_profile_prefix(self):
with tempfile.TemporaryDirectory() as tmp:
home = Path(tmp)
exe = home / "game/DragonQuestMonsters4Demo.exe"
exe.parent.mkdir()
exe.touch()
proton = home / "fake-proton"
proton.write_text("#!" + sys.executable + "\nimport json, sys\nprint(json.dumps(sys.argv[1:]))\n")
proton.chmod(0o755)
inherited, chosen = home / "compatdata/42", home / "profile/42"
for data in (inherited, chosen):
(data / "pfx").mkdir(parents=True)
config = home / ".config/droiddeck/game-environment.json"
config.parent.mkdir(parents=True)
config.write_text(json.dumps({"version": 1, "games": {"42": {"STEAM_COMPAT_DATA_PATH": str(chosen)}}}))
subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(proton), "waitforexitandrun", str(exe)],
env=dict(os.environ, HOME=tmp, STEAM_COMPAT_DATA_PATH=str(inherited)),
text=True, capture_output=True, check=True)
engine = "pfx/drive_c/users/steamuser/AppData/Local/DragonQuestMonsters4Demo/Saved/Config/Windows/Engine.ini"
self.assertIn("r.SkeletalMeshLODBias=-4", (chosen / engine).read_text())
self.assertFalse((inherited / engine).exists())
def test_dragon_quest_monsters_4_prefix_errors_do_not_stop_the_launch(self):
errors = io.StringIO()
with mock.patch.object(Path, "is_dir", side_effect=PermissionError("denied")), contextlib.redirect_stderr(errors):
MODULE["dragon_quest_monsters_4_mesh_detail"]("/game/DragonQuestMonsters4Demo.exe", {"STEAM_COMPAT_DATA_PATH": "/compatdata/42"})
self.assertIn("left as is", errors.getvalue())
def test_other_games_do_not_get_the_dragon_quest_monsters_4_settings(self):
with tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "pfx").mkdir()
MODULE["dragon_quest_monsters_4_mesh_detail"]("/game/DragonQuestMonsters3.exe", {"STEAM_COMPAT_DATA_PATH": tmp})
self.assertEqual(list((Path(tmp) / "pfx").iterdir()), [])
def test_arkham_city_gets_full_x87_precision_over_the_preset(self):
with tempfile.TemporaryDirectory() as tmp:
city = Path(tmp) / "Batman Arkham City GOTY/Binaries/Win32"