From 9227f5e63e579be94bc8cdf7d0728dbe697231b4 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Sat, 13 Jul 2024 16:53:23 +0300 Subject: [PATCH] Improve disable_vignettes With profiler overhead, this about 3.5 times faster. --- .../specific_patches/static_fixes.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/open_samus_returns_rando/specific_patches/static_fixes.py b/src/open_samus_returns_rando/specific_patches/static_fixes.py index e6daec0..0cc5905 100644 --- a/src/open_samus_returns_rando/specific_patches/static_fixes.py +++ b/src/open_samus_returns_rando/specific_patches/static_fixes.py @@ -326,9 +326,9 @@ def disable_vignettes(editor: PatcherEditor) -> None: bmsbk = editor.get_file(f"maps/levels/c10_samus/{scenario_name}/{scenario_name}.bmsbk", Bmsbk) blocks = bmsbk.raw["block_groups"][block_group]["types"][0]["blocks"] - for block in range(len(blocks)): + for block in blocks: # Separate the vignette from the block - blocks[block]["name2"] = "" + block["name2"] = "" bmssd = editor.get_file(f"maps/levels/c10_samus/{scenario_name}/{scenario_name}.bmssd", Bmssd) sg_group = bmssd.raw["unk_structs_b"] @@ -338,14 +338,12 @@ def disable_vignettes(editor: PatcherEditor) -> None: for sg in sg_group: # Check for the cc_name if sg["str1"] == cc_name: - for cc_group in range(len(sg["struct3"])): - model_group = sg["struct3"][cc_group]["struct5"] - for model in model_group: - idx = model_group.index(model) - for vignette in vignette_models: + for cc_group in sg["struct3"]: + model_group = cc_group["struct5"] + for idx, model in reversed(list(enumerate(model_group))): + if any(model["int6"] == vignette for vignette in vignette_models): # Remove the model to prevent it from loading - if model["int6"] == vignette: - model_group.pop(idx) + model_group.pop(idx) def apply_static_fixes(editor: PatcherEditor) -> None: