From 1a7f17d93189ae9981ff286d67c9b0406e99ce96 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 24 Jul 2012 15:55:58 +0200 Subject: preparing for exporting --- src/exporter.py | 11 ++++++++++- src/unlock.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/exporter.py b/src/exporter.py index 2396633..f39497f 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -191,7 +191,8 @@ class KPMapExporter: sectorData = self._packSectorData(sectors) # now that we've got that, we can pack the first part of the file - data = bytearray(struct.pack('>IIII', len(self.layers), 16 + len(sectorData), 0, 0)) + data = bytearray(struct.pack('>IIIII', len(self.layers), 20 + len(sectorData), 0, 0, 0)) + requiredFixUps.append((16, 'UnlockBytecode')) # list of layer pointers goes here.. or will, later data += sectorData @@ -420,6 +421,14 @@ class KPMapExporter: for piece in imageData: data += piece + # at the end comes the unlock bytecode + offsets['UnlockBytecode'] = len(data) + unlockBytecode = '' + # note: subtract 1 from the world and level number when saving + # note: also limit world to 1-10 in the parser + # note: enforce maximum term limit (64) + # note: block recursion too much + # to finish up, correct every offset for offset, target in requiredFixUps: u32.pack_into(data, offset, offsets[target]) diff --git a/src/unlock.py b/src/unlock.py index 16063ca..dfeaa33 100644 --- a/src/unlock.py +++ b/src/unlock.py @@ -8,7 +8,7 @@ class UnlockParseError(ValueError): pass def parseUnlockText(text): - return _parseUnlockBit(text) + return _parseUnlockBit(text.lower()) def _parseUnlockBit(text): # blank criterion -- cgit v1.2.3