Code: Select all
import struct
f = open( "binary004.bin", "rb" )
# Skip the Flash stuff.
f.seek( 12, 1 )
sig = f.read( 10 )
if sig != "CNC ARRAY\0":
print "Signature didn't match"
exit()
def readInt( f ):
return struct.unpack( "<i", f.read( 4 ) )[ 0 ]
ver = readInt( f )
x_dim = readInt( f )
y_dim = readInt( f )
z_dim = readInt( f )
option_flags = readInt( f )
print ver, x_dim, y_dim, z_dim, option_flags
assert option_flags & 0b11 == 1
array = [ ]
for z in range( z_dim ):
array.append( [ ] )
for y in range( y_dim ):
array[ -1 ].append( [ ] )
for x in range( x_dim ):
array[ -1 ][ -1 ].append( readInt( f ) )
# For each z, print each row.
for z in range( z_dim ):
print "z = {}:".format( z )
for y in range( y_dim ):
print array[ z ][ y ]
The map from binary004.bin corresponds to map4.jpg in tepples' screen shots, which will certainly be useful later when making sure that things look the way they should.
BTW Dwedit, if you have a way of extracting all the media (pictures, audio) from the SWF file in some automated way, I'd appreciate that. Currently I have to capture these one by one manually.
EDIT: One more thing. There are three layers in the map files:
- z = 2 is layer where most of the background stuff is
- z = 1 contains some other stuff like the dead guy/whatever in map4 (tiles 99, 100)
- z = 0 contains the doors (tiles 117, 118) and some other stuff
Didn't figure out the exact purpose of these extra layers just yet.