""" A simple tool for converting 512x64x512 icemap files into vxl. NOTE: this does NOT do the icemap footer variant. (Yet.) GreaseMonkey, 2012 - Public Domain """ from __future__ import print_function import sys, struct # Backwards compatibility - make new code work on old version, not vice-versa PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 if PY2: # This script didn't use range() anyway, so no problem overwriting it in Py2 import __builtin__ range = getattr(__builtin__, "xrange") _ord = ord else: _ord = lambda x: x USAGE_MSG = """ usage: python2 icemap2vxl.py in.icemap out.vxl note: icemap file MUST be 512x64x512, and the type information will be LOST! """ if len(sys.argv) <= 2: print(USAGE_MSG) exit() infp = open(sys.argv[1],"rb") if infp.read(8) != "IceMap\x1A\x01": raise Exception("not an IceMap v1 file") while True: tag = infp.read(7) taglen = _ord(infp.read(1)) if tag == b" "*7: break if taglen == 255: taglen, = struct.unpack("