From 7760eafca1ac95f961e6804cdd261b0d94712208 Mon Sep 17 00:00:00 2001 From: wootguy Date: Tue, 10 Sep 2024 12:26:31 -0700 Subject: [PATCH] convert per-monster sound lists and ignore some errors --- convert_map.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/convert_map.py b/convert_map.py index 36606897..a261a043 100644 --- a/convert_map.py +++ b/convert_map.py @@ -180,7 +180,8 @@ def convert_audio(file, out_format, samp_rate): while True: try: - os.remove('sound/' + file) + if os.path.exists('sound/' + file): + os.remove('sound/' + file) break except Exception as e: print(e) @@ -573,7 +574,7 @@ def ents_match(d1, d2, path=""): if not os.path.exists(json_path): print("Zomg failed to info model %s" % mdl) - sys.exit() + continue had_nonstandard_audio = False @@ -623,7 +624,10 @@ def ents_match(d1, d2, path=""): # keep classname last path = os.path.normpath("sound/%s/%s" % (map_name.replace(".bsp", ""), ent['globalsoundlist'])) gsr_files.append(path) - break + if ent.get('soundlist', ''): + # keep classname last + path = os.path.normpath("sound/%s/%s" % (map_name.replace(".bsp", ""), ent['soundlist'])) + gsr_files.append(path) if check_map_problems(all_ents, False) or special_map_logic: print() @@ -694,6 +698,7 @@ def ents_match(d1, d2, path=""): continue new_lines = [] + any_replaced = False with open(gsr, 'r') as file: for line in file: line = line.strip() @@ -716,10 +721,12 @@ def ents_match(d1, d2, path=""): line = '%s %s' % (parts[0], newpath) new_lines.append(line) + any_replaced = True - with open(gsr, 'w') as file: - for line in new_lines: - file.write(line + "\n") + if any_replaced: + with open(gsr, 'w') as file: + for line in new_lines: + file.write(line + "\n")