From d61dab6d44da181d42a654f149fc94a44ccd9cdf Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 28 Mar 2018 17:30:14 -0300 Subject: Detect stupid height layer, and cancel make maps if it is missing --- hercules/tmx_converter.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'hercules') diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 8638a9c..49bd846 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -31,6 +31,8 @@ import xml.sax dump_all = False # wall of text check_mobs = False # mob_db.txt +heigherror=True +fatalError=False # lower case versions of everything except 'spawn' and 'warp' other_object_types = set([ @@ -166,6 +168,7 @@ class ContentHandler(xml.sax.ContentHandler): pass def startElement(self, name, attr): + global heigherror if dump_all: attrs = ' '.join('%s="%s"' % (k,v) for k,v in attr.items()) if attrs: @@ -193,6 +196,7 @@ class ContentHandler(xml.sax.ContentHandler): self.width = int(attr[u'width']) self.height = int(attr[u'height']) self.state = State.LAYER + heigherror=False elif self.state is State.LAYER: if name == u'data': if attr.get(u'encoding','') not in (u'', u'csv'): @@ -263,6 +267,7 @@ class ContentHandler(xml.sax.ContentHandler): pass setattr(obj, key, value) + def add_warp_line(self, line): self.warps.write(line) @@ -366,6 +371,7 @@ class ContentHandler(xml.sax.ContentHandler): os.remove(posixpath.join(main.this_map_npc_dir, NPC_IMPORTS)) def main(argv): + global heigherror, fatalError _, client_data, server_data = argv tmx_dir = posixpath.join(client_data, CLIENT_MAPS) npc_dir = posixpath.join(server_data, SERVER_NPCS) @@ -402,7 +408,10 @@ def main(argv): xml.sax.parse(tmx, ContentHandler(main.this_map_npc_dir, mobs, saves, warps, imports)) 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: + print("ERROR: Height layer possibly missing") + fatalError=True + heigherror=True map_db.write('%s %d\n' % (arg.split('.')[0], map_count)) map_conf.write(' "%s",\n' % (arg.split('.')[0])) @@ -413,6 +422,8 @@ def main(argv): npc_master.sort() for line in npc_master: out.write(line) + if fatalError: + exit(1) if __name__ == '__main__': main(sys.argv) -- cgit v1.2.3-70-g09d2