From e485f7a5566b5e699dc96ea612004793a706ba96 Mon Sep 17 00:00:00 2001 From: sebbu Date: Mon, 13 Aug 2012 19:12:35 +0200 Subject: Added support for gzip and zlib compression with base64 encoding Amended by Jenalya to update submodule pointer. --- client-data | 2 +- tools/tmx_converter.py | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/client-data b/client-data index fb3a77de..83d87517 160000 --- a/client-data +++ b/client-data @@ -1 +1 @@ -Subproject commit fb3a77de6633633c3c5ebbe374334df79c682843 +Subproject commit 83d8751731d47707e06ca2872bc18241aa96199f diff --git a/tools/tmx_converter.py b/tools/tmx_converter.py index 763ed926..bb88ecc1 100755 --- a/tools/tmx_converter.py +++ b/tools/tmx_converter.py @@ -28,6 +28,8 @@ import os import posixpath import struct import xml.sax +import base64 +import zlib dump_all = False # wall of text @@ -97,6 +99,10 @@ class ContentHandler(xml.sax.ContentHandler): 'state', # state of collision info 'tilesets', # first gid of each tileset 'buffer', # characters within a section + 'encoding', # encoding of layer data + 'compression', # compression of layer data + 'width', # width of the collision layer + 'height', # height of the collision layer 'base', # base name of current map 'npc_dir', # world/map/npc/ 'mobs', # open file to _mobs.txt @@ -113,6 +119,10 @@ class ContentHandler(xml.sax.ContentHandler): self.state = State.INITIAL self.tilesets = {0} # consider the null tile as its own tileset self.buffer = bytearray() + self.encoding = None + self.compression = None + self.width = None + self.height = None self.base = posixpath.basename(npc_dir) self.npc_dir = npc_dir self.mobs = mobs @@ -154,15 +164,20 @@ class ContentHandler(xml.sax.ContentHandler): self.tilesets.add(int(attr[u'firstgid'])) if name == u'layer' and attr[u'name'].lower().startswith(u'collision'): - width = int(attr[u'width']) - height = int(attr[u'height']) - self.out.write(struct.pack('