Skip to content

Commit 1c2a101

Browse files
committed
Conversion rules are applied on every line at once again because some conversion rules use the newline character.
1 parent 9b67ad5 commit 1c2a101

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ConversionRules/Sounds.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@
141141
"Ronin.rte/Effects/Sounds/ThumperFire.wav": "Ronin.rte/Devices/Weapons/M79/Sounds/Fire1.flac",
142142
"Coalition.rte/Effects/Sounds/AutoCannonFire.wav": "Coalition.rte/Devices/Weapons/AutoCannon/Sounds/Fire1.flac",
143143
"Base.rte/Sounds/LightFlamerFire.wav": "Browncoats.rte/Devices/Weapons/Heatlance/Sounds/Loop.flac",
144+
"Base.rte/Sounds/EmptyClick3.wav": "Base.rte/Sounds/Devices/EmptyClick1.flac"
144145
}

Python/convert.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ def create_converted_file(input_file_path, output_file_path, input_folder_path):
119119
for line in file_in:
120120
line_number += 1
121121

122-
for old_str, new_str in conversion_rules.items():
123-
line = line.replace(old_str, new_str)
124-
125122
if ".bmp" in line:
126123
if not any(keep_bmp in line for keep_bmp in ["palette.bmp", "palettemat.bmp"]):
127124
line = line.replace(".bmp", ".png")
@@ -137,6 +134,13 @@ def create_converted_file(input_file_path, output_file_path, input_folder_path):
137134

138135
all_lines = "".join(all_lines_list)
139136

137+
# Conversion rules can contain newlines, so they can't be applied per-line.
138+
# Splitting the extension means it's fine that bmp -> png already happened.
139+
for old_str, new_str in conversion_rules.items():
140+
old_str_base = os.path.splitext(old_str)[0]
141+
new_str_base = os.path.splitext(new_str)[0]
142+
all_lines = all_lines.replace(old_str_base, new_str_base)
143+
140144
all_lines = regex_rules.regex_replace(all_lines)
141145
file_out.write(regex_rules.regex_replace_wavs(all_lines))
142146
# except:

0 commit comments

Comments
 (0)