summaryrefslogtreecommitdiff
path: root/src/exporter.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/exporter.py')
-rw-r--r--src/exporter.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/exporter.py b/src/exporter.py
index c4bb410..2f99a56 100644
--- a/src/exporter.py
+++ b/src/exporter.py
@@ -210,6 +210,7 @@ class KPMapExporter:
if isinstance(eLayer, self.TileLayerExporter):
data += u32.pack(0)
+ data += u32.pack(0xFF000000)
# tileset name
tileset = '/Maps/Texture/%s.bin' % layer.tileset
@@ -228,6 +229,7 @@ class KPMapExporter:
elif isinstance(eLayer, self.DoodadLayerExporter):
data += u32.pack(1)
+ data += u32.pack(0xFF000000)
# doodad list
try:
@@ -262,13 +264,14 @@ class KPMapExporter:
elif isinstance(eLayer, self.PathLayerExporter):
data += u32.pack(2)
+ data += zero32
# before we do anything, build the list of secret levels
# we'll need that
levelsWithSecrets = set()
for path in layer.paths:
- if hasattr(path, 'unlockSpec'):
+ if hasattr(path, 'unlockSpec') and path.unlockSpec is not None:
self._checkSpecForSecrets(path.unlockSpec, levelsWithSecrets)
# lists
@@ -337,8 +340,8 @@ class KPMapExporter:
if node.level:
level1, level2 = node.level
hasSecret = (1 if ((level1,level2) in levelsWithSecrets) else 0)
- # i i b b b b: node type, Extra pointer, world, level, hasSecret, padding
- data += struct.pack('>iibbbb', 2, 0, level1, level2, hasSecret, 0)
+ # i i i b b b b: node type, isNew, Extra pointer, world, level, hasSecret, padding
+ data += struct.pack('>iiibbbb', 2, 0, 0, level1, level2, hasSecret, 0)
elif node.mapChange:
data += u32.pack(3) # node type
@@ -347,15 +350,17 @@ class KPMapExporter:
requiredFixUps.append((len(data)+4, destMap))
stringsToAdd.add(destMap)
- # i i b b b b: Extra pointer, dest map, map ID, foreign ID, transition, padding
- data += struct.pack('>iibbbb', 0, 0, node.mapID, node.foreignID, node.transition, 0)
+ # i i i b b b b: isNew, Extra pointer, dest map, map ID, foreign ID, transition, padding
+ data += struct.pack('>iiibbbb', 0, 0, 0, node.mapID, node.foreignID, node.transition, 0)
else:
data += u32.pack(1) # node type
- data += u32.pack(0) # Extra pointer
+ data += zero32 # isNew
+ data += zero32 # Extra pointer
else:
- data += u32.pack(0) # node type
- data += u32.pack(0) # Extra pointer
+ data += zero32 # node type
+ data += zero32 # isNew
+ data += zero32 # Extra pointer
pathIndices = {}
@@ -376,7 +381,11 @@ class KPMapExporter:
data += (zero32 * 4)
- data += struct.pack('>bbbbfi', 1, 0, 0, 0, path.movementSpeed, path.animation)
+ available = 0
+ if (not hasattr(path, 'unlockSpec')) or path.unlockSpec is None:
+ available = 3
+
+ data += struct.pack('>bbbbfi', available, 0, 0, 0, path.movementSpeed, path.animation)
# now that we're almost done... pack the strings
for string in stringsToAdd:
@@ -416,6 +425,8 @@ class KPMapExporter:
# first off, build a map of unlocks
unlockLists = {}
+
+ from unlock import stringifyUnlockData
for path in self.map.pathLayer.paths:
if not hasattr(path, 'unlockSpec'):
@@ -424,6 +435,10 @@ class KPMapExporter:
if spec is None:
continue
+ # we stringify it first because the specs become lists when
+ # imported from the kpmap (not tuples) and those can't be
+ # used as dict keys
+ spec = stringifyUnlockData(spec)
try:
lst = unlockLists[spec]
except KeyError:
@@ -432,10 +447,10 @@ class KPMapExporter:
lst.append(path)
# now produce the thing
- from unlock import packUnlockSpec
+ from unlock import parseUnlockText, packUnlockSpec
for spec, lst in unlockLists.iteritems():
- data += packUnlockSpec(spec)
+ data += packUnlockSpec(parseUnlockText(spec))
data += chr(len(lst))
for p in lst:
data += u16.pack(pathIndices[p])