Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 23.51 KB | None | 0 0
  1. #!/usr/bin/python
  2. # created using python 3.6
  3.  
  4. from struct import pack, unpack, calcsize
  5. import sys
  6.  
  7. SCMAPMAGIC = b'\x4d\x61\x70\x1a'
  8. DDSMAGIC = b'DDS '
  9.  
  10. class MapParsingException(Exception):
  11.     def __init__( self, subject, fileObject ):
  12.         self.fileName = fileObject.name
  13.         self.offset = fileObject.tell()
  14.         self.message = "Couldn't parse {} from \"{}\" before offset {} ".format( subject, self.fileName, self.offset )
  15.         super(Exception, self).__init__( self.message )
  16.  
  17. def readcstr(f):
  18.     buf = b''
  19.     while True:
  20.         b = f.read(1)
  21.         if b is None or b == b'\0':
  22.             return buf
  23.         else:
  24.             buf += b
  25.  
  26. def readMap( pathToScmap ):
  27.     with open(pathToScmap,'rb') as scmap:
  28.        
  29.         scmapMagic = scmap.read(4)
  30.         if len(scmapMagic) < 4 or scmapMagic != SCMAPMAGIC:
  31.             raise MapParsingException( "file magic", scmap )
  32.  
  33.         fileVersionMajor = unpack('I', scmap.read(4) )[0]
  34.         if not fileVersionMajor:
  35.             raise MapParsingException( "file major version", scmap )
  36.         print("fileVersionMajor: {}".format(fileVersionMajor))
  37.        
  38.  
  39.         # always 0xbeeffeed and other always 2
  40.         (unknown3,unknown4) = ( scmap.read(4), scmap.read(4) )
  41.         print("unknown3: {}".format(unknown3))
  42.         print("unknown4: {}".format(unknown4))
  43.        
  44.         (scaledMapWidth,scaledMapHeight) = unpack('ff', scmap.read(calcsize('ff')) )
  45.         if not scaledMapWidth or not scaledMapHeight:
  46.             raise MapParsingException( "scaled map size", scmap )
  47.         print("scaledMapWidth: {}".format(scaledMapWidth))
  48.         print("scaledMapHeight: {}".format(scaledMapHeight))
  49.        
  50.         # always 0
  51.         (unknown5,unknown6) = ( scmap.read(4), scmap.read(2) )
  52.         print("unknown5: {}".format(unknown5))
  53.         print("unknown6: {}".format(unknown6))
  54.        
  55.         #######################################################################
  56.         ### Preview Image
  57.         #######################################################################
  58.  
  59.         previewImageDataLength = unpack('I', scmap.read(4) )[0]
  60.         if not previewImageDataLength:
  61.             raise MapParsingException( "preview image data length", scmap )
  62.         previewImageData = scmap.read(previewImageDataLength)
  63.         if len(previewImageData) != previewImageDataLength:
  64.             raise MapParsingException( "preview image data ({} bytes)".format(previewImageDataLength), scmap )
  65.         print("previewImageDataLength: {} bytes".format(previewImageDataLength))
  66.         print("previewImageDataMagic: {}".format(previewImageData[0:4].decode()))
  67.         #if previewImageData[0:4] == DDSMAGIC:
  68.             #previewDataPath = "{}_preview.dds".format( scmap.name )
  69.             #with open(previewDataPath,'wb') as previewDumpFile:
  70.                 #previewDumpFile.write( previewImageData )
  71.             #print("preview image dumped to \"{}\"".format(previewDataPath))
  72.        
  73.         fileVersionMinor = unpack('I', scmap.read(4) )[0]
  74.         if not fileVersionMinor:
  75.             raise MapParsingException( "file minor version", scmap )
  76.         print("fileVersionMinor: {}".format(fileVersionMinor))
  77.        
  78.         if fileVersionMinor not in [60, 59, 56, 53]:
  79.             raise MapParsingException( "unsupported file minor version", scmap )
  80.        
  81.         #######################################################################
  82.        
  83.         (mapWidth,mapHeight) = unpack('II', scmap.read(8) )
  84.         if not mapWidth or not mapHeight:
  85.             raise MapParsingException( "map size", scmap )
  86.         print("mapWidth: {}".format(mapWidth))
  87.         print("mapHeight: {}".format(mapHeight))
  88.        
  89.         #######################################################################
  90.         ### Height Map
  91.         #######################################################################
  92.  
  93.         print("read position: 0x{:08X}".format(scmap.tell()))
  94.        
  95.         # Height Scale, usually 1/128
  96.         heightScale = unpack('f', scmap.read(4) )[0]
  97.         print("heightScale: {}".format(heightScale))
  98.         heightMapDataLength = ( mapHeight + 1 ) * ( mapWidth + 1 ) * calcsize('h')
  99.         print("heightMapDataLength: {}".format(heightMapDataLength))
  100.         heightMapData = scmap.read(heightMapDataLength)
  101.  
  102.         #######################################################################
  103.         ### Some Strings
  104.         #######################################################################
  105.        
  106.         if fileVersionMinor >= 56:
  107.             unknown7 = readcstr(scmap)
  108.             print("unknown7: {}".format(unknown7))
  109.        
  110.         terrain = readcstr(scmap)
  111.         print("terrain: {}".format(terrain))
  112.        
  113.         texPathBackground = readcstr(scmap)
  114.         print("texPathBackground: {}".format(texPathBackground))
  115.        
  116.         texPathSkyCubemap = readcstr(scmap)
  117.         print("texPathSkyCubemap: {}".format(texPathSkyCubemap))
  118.  
  119.         if fileVersionMinor < 56:
  120.        
  121.             texPathEnvCubemap = readcstr(scmap)
  122.             print("texPathEnvCubemap: {}".format(texPathEnvCubemap))            
  123.        
  124.         elif fileVersionMinor >= 56:
  125.  
  126.             environmentLookupTexturesCount = unpack('I', scmap.read(4) )[0]
  127.             print("environmentLookupTexturesCount: {}".format(environmentLookupTexturesCount))
  128.            
  129.             for i in range(environmentLookupTexturesCount):
  130.                 environmentLookupTexturesLabel = readcstr(scmap)
  131.                 print("environmentLookupTexturesLabel: {}".format(environmentLookupTexturesLabel))
  132.                 environmentLookupTexturesFile = readcstr(scmap)
  133.                 print("environmentLookupTexturesFile: {}".format(environmentLookupTexturesFile))
  134.        
  135.         #######################################################################
  136.         ### Render Settings
  137.         #######################################################################
  138.  
  139.         lightingMultiplier = unpack('f', scmap.read(4) )[0]
  140.         print("lightingMultiplier: {}".format(lightingMultiplier))
  141.  
  142.         lightDirection = unpack('fff', scmap.read(12) )
  143.         print("lightDirection: {}".format(lightDirection))
  144.  
  145.         ambienceLightColor = unpack('fff', scmap.read(12) )
  146.         print("ambienceLightColor: {}".format(ambienceLightColor))
  147.  
  148.         lightColor = unpack('fff', scmap.read(12) )
  149.         print("lightColor: {}".format(lightColor))
  150.  
  151.         shadowFillColor = unpack('fff', scmap.read(12) )
  152.         print("shadowFillColor: {}".format(shadowFillColor))
  153.  
  154.         specularColor = unpack('ffff', scmap.read(16) )
  155.         print("specularColor: {}".format(specularColor))
  156.  
  157.         bloom = unpack('f', scmap.read(4) )[0]
  158.         print("bloom: {}".format(bloom))
  159.  
  160.         fogColor = unpack('fff', scmap.read(12) )
  161.         print("fogColor: {}".format(fogColor))
  162.        
  163.         fogStart = unpack('f', scmap.read(4) )[0]
  164.         print("fogStart: {}".format(fogStart))
  165.  
  166.         fogEnd = unpack('f', scmap.read(4) )[0]
  167.         print("fogEnd: {}".format(fogEnd))
  168.  
  169.         hasWater = unpack('c', scmap.read(1) )[0]
  170.         print("hasWater: {}".format(hasWater))
  171.  
  172.         waterElevation = unpack('f', scmap.read(4) )[0]
  173.         print("waterElevation: {}".format(waterElevation))
  174.  
  175.         waterElevationDeep = unpack('f', scmap.read(4) )[0]
  176.         print("waterElevationDeep: {}".format(waterElevationDeep))
  177.  
  178.         waterElevationAbyss = unpack('f', scmap.read(4) )[0]
  179.         print("waterElevationAbyss: {}".format(waterElevationAbyss))
  180.        
  181.        
  182.         surfaceColor = unpack('fff', scmap.read(12) )
  183.         print("surfaceColor: {}".format(surfaceColor))
  184.        
  185.         colorLerpMin = unpack('f', scmap.read(4) )[0]
  186.         print("colorLerpMin: {}".format(colorLerpMin))
  187.        
  188.         colorLerpMax = unpack('f', scmap.read(4) )[0]
  189.         print("colorLerpMax: {}".format(colorLerpMax))
  190.        
  191.         refraction = unpack('f', scmap.read(4) )[0]
  192.         print("refraction: {}".format(refraction))
  193.        
  194.         fresnelBias = unpack('f', scmap.read(4) )[0]
  195.         print("fresnelBias: {}".format(fresnelBias))
  196.        
  197.         fresnelPower = unpack('f', scmap.read(4) )[0]
  198.         print("fresnelPower: {}".format(fresnelPower))
  199.        
  200.         reflectionUnit = unpack('f', scmap.read(4) )[0]
  201.         print("reflectionUnit: {}".format(reflectionUnit))
  202.        
  203.         reflectionSky = unpack('f', scmap.read(4) )[0]
  204.         print("reflectionSky: {}".format(reflectionSky))
  205.        
  206.         sunShininess = unpack('f', scmap.read(4) )[0]
  207.         print("sunShininess: {}".format(sunShininess))
  208.        
  209.         sunStrength = unpack('f', scmap.read(4) )[0]
  210.         print("sunStrength: {}".format(sunStrength))
  211.        
  212.         sunGlow = unpack('f', scmap.read(4) )[0]
  213.         print("sunGlow: {}".format(sunGlow))
  214.        
  215.         unknown8 = unpack('f', scmap.read(4) )[0]
  216.         print("unknown8: {}".format(unknown8))
  217.        
  218.         unknown9 = unpack('f', scmap.read(4) )[0]
  219.         print("unknown9: {}".format(unknown9))
  220.        
  221.         sunColor = unpack('fff', scmap.read(12) )
  222.         print("sunColor: {}".format(sunColor))
  223.        
  224.         reflectionSun = unpack('f', scmap.read(4) )[0]
  225.         print("reflectionSun: {}".format(reflectionSun))
  226.  
  227.         print("read position: 0x{:08X}".format(scmap.tell()))
  228.        
  229.         unknown10 = unpack('f', scmap.read(4) )[0]
  230.         print("unknown10: {}".format(unknown10))
  231.  
  232.         ### Texture Maps
  233.  
  234.         texPathWaterCubemap = readcstr(scmap)
  235.         print("texPathWaterCubemap: {}".format(texPathWaterCubemap))
  236.  
  237.         texPathWaterRamp = readcstr(scmap)
  238.         print("texPathWaterRamp: {}".format(texPathWaterRamp))
  239.  
  240.         for i in range(4):
  241.             print("waveTexture: {}".format(i))
  242.             normalsFrequency = unpack('f', scmap.read(4) )[0]
  243.             print("normalsFrequency: {}".format(normalsFrequency))
  244.  
  245.         for i in range(4):
  246.             print("waveTexture: {}".format(i))
  247.             waveTextureScaleX = unpack('f', scmap.read(4) )[0]
  248.             print("waveTextureScaleX: {}".format(waveTextureScaleX))
  249.             waveTextureScaleY = unpack('f', scmap.read(4) )[0]
  250.             print("waveTextureScaleY: {}".format(waveTextureScaleY))
  251.             waveTexturePath = readcstr(scmap)
  252.             print("waveTexturePath: {}".format(waveTexturePath))
  253.  
  254.         waveGeneratorCount = unpack('I', scmap.read(4) )[0]
  255.         print("waveGeneratorCount: {}".format(waveGeneratorCount))
  256.         for i in range(waveGeneratorCount):
  257.             print("waveGenerator: {}".format(i))
  258.             textureName = readcstr(scmap)
  259.             print("textureName: {}".format(textureName))
  260.             rampName = readcstr(scmap)
  261.             print("rampName: {}".format(rampName))
  262.             position = unpack('fff', scmap.read(12) )
  263.             print("position: {}".format(position))
  264.             rotation = unpack('f', scmap.read(4) )[0]
  265.             print("rotation: {}".format(rotation))
  266.             velocity = unpack('fff', scmap.read(12) )
  267.             print("velocity: {}".format(velocity))
  268.             lifetimeFirst = unpack('f', scmap.read(4) )[0]
  269.             print("lifetimeFirst: {}".format(lifetimeFirst))
  270.             lifetimeSecond = unpack('f', scmap.read(4) )[0]
  271.             print("lifetimeSecond: {}".format(lifetimeSecond))
  272.             periodFirst = unpack('f', scmap.read(4) )[0]
  273.             print("periodFirst: {}".format(periodFirst))
  274.             periodSecond = unpack('f', scmap.read(4) )[0]
  275.             print("periodSecond: {}".format(periodSecond))
  276.             scaleFirst = unpack('f', scmap.read(4) )[0]
  277.             print("scaleFirst: {}".format(scaleFirst))
  278.             scaleSecond = unpack('f', scmap.read(4) )[0]
  279.             print("scaleSecond: {}".format(scaleSecond))
  280.             frameCount = unpack('f', scmap.read(4) )[0]
  281.             print("frameCount: {}".format(frameCount))
  282.             frameRateFirst = unpack('f', scmap.read(4) )[0]
  283.             print("frameRateFirst: {}".format(frameRateFirst))
  284.             frameRateSecond = unpack('f', scmap.read(4) )[0]
  285.             print("frameRateSecond: {}".format(frameRateSecond))
  286.             stripCount = unpack('f', scmap.read(4) )[0]
  287.             print("stripCount: {}".format(stripCount))
  288.  
  289.         print("read position: 0x{:08X}".format(scmap.tell()))
  290.        
  291.         if fileVersionMinor >= 59:
  292.             unkownData12 = scmap.read(28)
  293.             print("unkownData12: {}".format(unkownData12.hex()))
  294.         elif fileVersionMinor > 53:
  295.             unkownData12 = scmap.read(24)
  296.             print("unkownData12: {}".format(unkownData12.hex()))
  297.         else:
  298.             noTileset = readcstr(scmap)
  299.             print("noTileset: {}".format(noTileset))
  300.            
  301.        
  302.         if fileVersionMinor > 53:
  303.  
  304.             strata = ['LowerStratum','Stratum1','Stratum2','Stratum3','Stratum4','Stratum5','Stratum6','Stratum7','Stratum8','UpperStratum']
  305.             print("strata: {}".format(strata))
  306.  
  307.             for stratum in strata:
  308.                 print("stratum: {}".format(stratum))
  309.                 albedoFile = readcstr(scmap)
  310.                 print("albedoFile: {}".format(albedoFile))
  311.                 albedoScale = unpack('f', scmap.read(4) )[0]
  312.                 print("albedoScale: {}".format(albedoScale))
  313.                 print("-"*80)
  314.            
  315.             for stratum in strata:
  316.                 # fucking special cases
  317.                 if stratum == 'UpperStratum':
  318.                     # no Normal for UpperStratum
  319.                     continue
  320.                 print("stratum: {}".format(stratum))
  321.                 normalFile = readcstr(scmap)
  322.                 print("normalFile: {}".format(normalFile))
  323.                 normalScale = unpack('f', scmap.read(4) )[0]
  324.                 print("normalScale: {}".format(normalScale))
  325.                 print("-"*80)
  326.        
  327.         else:
  328.  
  329.             strataCount = unpack('I', scmap.read(4) )[0]
  330.             print("strataCount: {}".format(strataCount))
  331.             for stratum in range(strataCount):
  332.                 print("stratum: {}".format(stratum))
  333.                 albedoFile = readcstr(scmap)
  334.                 print("albedoFile: {}".format(albedoFile))
  335.                 normalFile = readcstr(scmap)
  336.                 print("normalFile: {}".format(normalFile))
  337.                 albedoScale = unpack('f', scmap.read(4) )[0]
  338.                 print("albedoScale: {}".format(albedoScale))
  339.                 normalScale = unpack('f', scmap.read(4) )[0]
  340.                 print("normalScale: {}".format(normalScale))
  341.                 print("-"*80)
  342.            
  343.    
  344.         print("read position: 0x{:08X}".format(scmap.tell()))
  345.  
  346.         unknown13 = unpack('I', scmap.read(4) )[0]
  347.         print("unknown13: {}".format(unknown13))
  348.  
  349.         unknown14 = unpack('I', scmap.read(4) )[0]
  350.         print("unknown14: {}".format(unknown14))
  351.  
  352.         decalsCount = unpack('I', scmap.read(4) )[0]
  353.         print("decalsCount: {}".format(decalsCount))
  354.    
  355.         for decalIndex in range(decalsCount):
  356.  
  357.             decalId = unpack('I', scmap.read(4) )[0]
  358.             print("decalId: {}".format(decalId))
  359.  
  360.             unknown15 = unpack('I', scmap.read(4) )[0]
  361.             print("unknown15: {}".format(unknown15))
  362.  
  363.             unknown16 = unpack('I', scmap.read(4) )[0]
  364.             print("unknown16: {}".format(unknown16))
  365.  
  366.             #decalsTextureCount = unpack('I', scmap.read(4) )[0]
  367.             #print("decalsTextureCount: {}".format(decalsTextureCount))
  368.  
  369.             #for i in range(decalsTextureCount):
  370.             #while True:
  371.             decalsTexturePathLength = unpack('I', scmap.read(4) )[0]
  372.             print("decalsTexturePathLength: {}".format(decalsTexturePathLength))
  373.                
  374.                 #if decalsTexturePathLength == 0:
  375.                     #break
  376.                
  377.             if decalsTexturePathLength > 1024:
  378.                 raise MapParsingException( "decalsTexturePathLength", scmap )
  379.  
  380.             decalsTexturePath = scmap.read(decalsTexturePathLength)
  381.             print("decalsTexturePath: {}".format(decalsTexturePath))
  382.  
  383.             decalsTexturePathLength = unpack('I', scmap.read(4) )[0]
  384.             print("decalsTexturePathLength: {}".format(decalsTexturePathLength))
  385.                
  386.             if decalsTexturePathLength > 1024:
  387.                 raise MapParsingException( "decalsTexturePathLength", scmap )
  388.             if decalsTexturePathLength > 0:
  389.                 decalsTexturePath = scmap.read(decalsTexturePathLength)
  390.                 print("decalsTexturePath: {}".format(decalsTexturePath))
  391.  
  392.             scale = unpack('fff', scmap.read(12) )
  393.             print("scale: {}".format(scale))
  394.  
  395.             position = unpack('fff', scmap.read(12) )
  396.             print("position: {}".format(position))
  397.  
  398.             rotation = unpack('fff', scmap.read(12) )
  399.             print("rotation: {}".format(rotation))
  400.  
  401.             cutOffLOD = unpack('f', scmap.read(4) )[0]
  402.             print("cutOffLOD: {}".format(cutOffLOD))
  403.  
  404.             ownerArmy = unpack('I', scmap.read(4) )[0]
  405.             print("ownerArmy: {}".format(ownerArmy))
  406.  
  407.             unknown17 = unpack('I', scmap.read(4) )[0]
  408.             print("unknown17: {}".format(unknown17))
  409.  
  410.         print("read position: 0x{:08X}".format(scmap.tell()))
  411.  
  412.         decalGroupsCount = unpack('I', scmap.read(4) )[0]
  413.         print("decalGroupsCount: {}".format(decalGroupsCount))
  414.         for decalGroupIndex in range(decalGroupsCount):
  415.             decalGroupId = unpack('I', scmap.read(4) )[0]
  416.             print("decalGroupId: {}".format(decalGroupId))
  417.             decalGroupName = readcstr(scmap)
  418.             print("decalGroupName: {}".format(decalGroupName))
  419.             decalGroupEntriesCount = unpack('I', scmap.read(4) )[0]
  420.             print("decalGroupEntriesCount: {}".format(decalGroupEntriesCount))
  421.             for i in range(decalGroupEntriesCount):
  422.                 decalGroupEntry = unpack('I', scmap.read(4) )[0]
  423.                 print("decalGroupEntry: {}".format(decalGroupEntry))
  424.            
  425.         (unknown19Width,unknown19Height) = unpack('II', scmap.read(8) )
  426.         print("unknown19Width: {}".format(unknown19Width))
  427.         print("unknown19Height: {}".format(unknown19Height))
  428.  
  429.         # most often 1, sometimes 4
  430.         normalMapsCount = unpack('I', scmap.read(4) )[0]
  431.         print("normalMapsCount: {}".format(normalMapsCount))
  432.         for normalMapIndex in range(normalMapsCount):
  433.        
  434.             normalMapDataLength = unpack('I', scmap.read(4) )[0]
  435.             print("normalMapDataLength: {}".format(normalMapDataLength))
  436.             normalMapData = scmap.read(normalMapDataLength)
  437.             print("normalMapData: {}...".format(normalMapData[:4]))
  438.  
  439.             #if normalMapData[0:4] == DDSMAGIC:
  440.                 #pnormalMapDataPath = "{}_normalMap{}.dds".format( scmap.name, normalMapIndex )
  441.                 #with open(pnormalMapDataPath,'wb') as dumpFile:
  442.                     #dumpFile.write( normalMapData )
  443.                 #print("normalMapData dumped to \"{}\"".format(pnormalMapDataPath))
  444.  
  445.         print("read position: 0x{:08X}".format(scmap.tell()))
  446.        
  447.         if fileVersionMinor < 56:
  448.             unknown20 = unpack('I', scmap.read(4) )[0]
  449.             print("unknown20: {}".format(unknown20))
  450.  
  451.         textureMapDataLength = unpack('I', scmap.read(4) )[0]
  452.         print("textureMapDataLength: {}".format(textureMapDataLength))
  453.         textureMapData = scmap.read(textureMapDataLength)
  454.         print("textureMapData: {}...".format(textureMapData[:4]))
  455.  
  456.         print("read position: 0x{:08X}".format(scmap.tell()))
  457.        
  458.         if fileVersionMinor < 56:
  459.             unknown21 = unpack('I', scmap.read(4) )[0]
  460.             print("unknown21: {}".format(unknown21))
  461.  
  462.         waterMapDataLength = unpack('I', scmap.read(4) )[0]
  463.         print("waterMapDataLength: {}".format(waterMapDataLength))
  464.         waterMapData = scmap.read(waterMapDataLength)
  465.         print("waterMapData: {}...".format(waterMapData[:4]))
  466.        
  467.         if fileVersionMinor > 53:
  468.             unknown22 = unpack('I', scmap.read(4) )[0]
  469.             print("unknown22: {}".format(unknown22))
  470.  
  471.             unknown23MapDataLength = unpack('I', scmap.read(4) )[0]
  472.             print("unknown23MapDataLength: {}".format(unknown23MapDataLength))
  473.             unknown23MapData = scmap.read(unknown23MapDataLength)
  474.             print("unknown23MapData: {}...".format(unknown23MapData[:4]))
  475.  
  476.         someWaterMapLength = int( (mapWidth / 2) * (mapHeight / 2) )
  477.         waterFoamMapData = scmap.read(someWaterMapLength)
  478.         print("waterFoamMapData: {}...".format(waterFoamMapData[:4]))
  479.         waterFlatnessMapData = scmap.read(someWaterMapLength)
  480.         print("waterFlatnessMapData: {}...".format(waterFlatnessMapData[:4]))
  481.         waterDepthBiasMapData = scmap.read(someWaterMapLength)
  482.         print("waterDepthBiasMapData: {}...".format(waterDepthBiasMapData[:4]))
  483.        
  484.  
  485.         print("read position: 0x{:08X}".format(scmap.tell()))
  486.  
  487.         terrainTypeDataLength = mapWidth * mapHeight
  488.         print("terrainTypeDataLength: {}...".format(terrainTypeDataLength))
  489.         terrainTypeData = scmap.read(terrainTypeDataLength)
  490.         print("terrainTypeData: {}...".format(terrainTypeData[:4]))
  491.  
  492.         if fileVersionMinor < 53:
  493.             unknown24 = unpack('h', scmap.read(2) )[0]
  494.             print("unknown24: {}".format(unknown24))
  495.        
  496.  
  497.         if fileVersionMinor >= 59:
  498.             unknown25 = scmap.read(64)
  499.             print("unknown25: {}".format(unknown25[:4]))
  500.             unknown26String = readcstr(scmap)
  501.             print("unknown26String: {}".format(unknown26String))
  502.             unknown27String = readcstr(scmap)
  503.             print("unknown27String: {}".format(unknown27String))
  504.             unknown28 = unpack('I', scmap.read(4) )[0]
  505.             print("unknown28: {}".format(unknown28))
  506.             unknown28MagicFactor = 40
  507.             if unknown28 > 0:
  508.                 unknown29 = scmap.read( unknown28 * unknown28MagicFactor )
  509.                 print("unknown29: {}".format(unknown29[:4]))
  510.             unknown30 = scmap.read(19)
  511.             print("unknown30: {}".format(unknown30))
  512.             unknown31String = readcstr(scmap)
  513.             print("unknown31String: {}".format(unknown31String))
  514.            
  515.             unknown31 = scmap.read(88)
  516.             print("unknown31: {}".format(unknown31[:4]))
  517.  
  518.         print("read position: 0x{:08X}".format(scmap.tell()))
  519.  
  520.  
  521.         propsCount = unpack('I', scmap.read(4) )[0]
  522.         print("propsCount: {}".format(propsCount))
  523.  
  524.         newPropsList = []
  525.         for propIndex in range( 0, propsCount ):
  526.             print("prop {}".format(propIndex))
  527.             blueprintPath = readcstr(scmap)
  528.             print("blueprintPath: {}".format(blueprintPath))
  529.             position = unpack('fff', scmap.read(12) )
  530.             print("position: {}".format(position))
  531.             rotationX = unpack('fff', scmap.read(12) )
  532.             print("rotationX: {}".format(rotationX))
  533.             rotationY = unpack('fff', scmap.read(12) )
  534.             print("rotationY: {}".format(rotationX))
  535.             rotationZ = unpack('fff', scmap.read(12) )
  536.             print("rotationZ: {}".format(rotationX))
  537.             scale = unpack('fff', scmap.read(12) )
  538.             newPosition = (position[2],position[1],position[0])
  539.             newPropsList += [(blueprintPath,*newPosition,*rotationX,*rotationY,*rotationZ,*scale)]
  540.             print("(unused) scale: {}".format(scale))
  541.             print("-"*80)
  542.  
  543.  
  544. if __name__ == '__main__':
  545.  
  546.     if len(sys.argv) < 2:
  547.         print("Usage: {} <file>".format(sys.argv[0]))
  548.         sys.exit(1)
  549.  
  550.     readMap( pathToScmap = sys.argv[1] )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement