Skip to content

Commit

Permalink
convert per-monster sound lists and ignore some errors
Browse files Browse the repository at this point in the history
wootguy committed Sep 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 1474518 commit 7760eaf
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions convert_map.py
Original file line number Diff line number Diff line change
@@ -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")



0 comments on commit 7760eaf

Please sign in to comment.