summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2018-03-28 17:30:14 -0300
committerJesusaves <cpntb1@ymail.com>2018-03-28 17:30:14 -0300
commitd61dab6d44da181d42a654f149fc94a44ccd9cdf (patch)
tree89662ce3664c4a8760838736336ccc89b7f08a27 /hercules
parentd04bd034c7605ebe7de83d0098fab52f6bd2cd8d (diff)
downloadtools-d61dab6d44da181d42a654f149fc94a44ccd9cdf.tar.gz
tools-d61dab6d44da181d42a654f149fc94a44ccd9cdf.tar.bz2
tools-d61dab6d44da181d42a654f149fc94a44ccd9cdf.tar.xz
tools-d61dab6d44da181d42a654f149fc94a44ccd9cdf.zip
Detect stupid height layer, and cancel make maps if it is missing
Diffstat (limited to 'hercules')
-rwxr-xr-xhercules/tmx_converter.py13
1 files changed, 12 insertions, 1 deletions
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)