From 113b38189960be1acb388a6dd344230cee96c979 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 1 Mar 2021 20:57:51 -0300 Subject: TMX Converter: Do not explode and exit with code 1 if a map is corrupted. --- hercules/tmx_converter.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 8a34a06..96a37d9 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -32,6 +32,7 @@ import sys import os import posixpath import xml.sax +import traceback dump_all = False # wall of text check_mobs = False # mob_db.txt @@ -625,11 +626,16 @@ def main(argv): main.this_map_npc_dir = posixpath.join(npc_dir, base) os.path.isdir(main.this_map_npc_dir) or os.mkdir(main.this_map_npc_dir) print('Converting %s' % (tmx)) - with open(posixpath.join(main.this_map_npc_dir, NPC_MOBS), 'w') as mobs: + try: + with open(posixpath.join(main.this_map_npc_dir, NPC_MOBS), 'w') as mobs: with open(posixpath.join(main.this_map_npc_dir, NPC_CONFIG), 'w') as confs: with open(posixpath.join(main.this_map_npc_dir, NPC_WARPS), 'w') as warps: with open(posixpath.join(main.this_map_npc_dir, NPC_IMPORTS), 'w') as imports: xml.sax.parse(tmx, ContentHandler(main.this_map_npc_dir, mobs, confs, warps, imports)) + except: + traceback.print_exc() + print("ERROR: MAP \"%s\" WAS NOT CONVERTED. ERROR FOUND!" % tmx) + fatalError=True if os.path.isfile(posixpath.join(main.this_map_npc_dir, NPC_IMPORTS)): npc_master.append('@include "%s"\n' % posixpath.join(SERVER_NPCS, base, NPC_IMPORTS)) if heigherror: -- cgit v1.2.3-60-g2f50