Skip to content

Commit 33b39da

Browse files
authored
Merge pull request #373 from MayberryZoom/patch-function
Move game patch code from patch_extracted into new function
2 parents 0facdc7 + f81aeef commit 33b39da

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/open_dread_rando/dread_patcher.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,7 @@ def validate(configuration: dict):
201201
DefaultValidatingDraft7Validator(_read_schema()).validate(configuration)
202202

203203

204-
def patch_extracted(input_path: Path, output_path: Path, configuration: dict):
205-
LOG.info("Will patch files from %s", input_path)
206-
207-
validate(configuration)
208-
209-
editor = PatcherEditor(input_path)
210-
lua_scripts = LuaEditor()
211-
204+
def apply_patches(editor: PatcherEditor, lua_editor: LuaEditor, configuration: dict):
212205
# Copy custom files
213206
add_custom_files(editor)
214207
generate_missile_colors(editor)
@@ -238,7 +231,7 @@ def patch_extracted(input_path: Path, output_path: Path, configuration: dict):
238231
elevator.patch_elevators(editor, configuration["elevators"])
239232

240233
# Pickups
241-
patch_pickups(editor, lua_scripts, configuration["pickups"], configuration)
234+
patch_pickups(editor, lua_editor, configuration["pickups"], configuration)
242235

243236
# Hints
244237
if "hints" in configuration:
@@ -284,6 +277,18 @@ def patch_extracted(input_path: Path, output_path: Path, configuration: dict):
284277
# remote connector disconnect symbol
285278
patch_sprites(editor)
286279

280+
281+
def patch_extracted(input_path: Path, output_path: Path, configuration: dict):
282+
LOG.info("Will patch files from %s", input_path)
283+
284+
validate(configuration)
285+
286+
editor = PatcherEditor(input_path)
287+
lua_editor = LuaEditor()
288+
289+
# Apply game patches
290+
apply_patches(editor, lua_editor, configuration)
291+
287292
out_romfs, out_exefs, exefs_patches = output_paths_for_compatibility(
288293
output_path,
289294
configuration["mod_compatibility"],
@@ -301,7 +306,7 @@ def patch_extracted(input_path: Path, output_path: Path, configuration: dict):
301306
include_depackager(out_exefs)
302307

303308
LOG.info("Saving modified lua scripts")
304-
lua_scripts.save_modifications(editor)
309+
lua_editor.save_modifications(editor)
305310

306311
LOG.info("Flush modified assets")
307312
editor.flush_modified_assets()

0 commit comments

Comments
 (0)