Advertisement
Guest User

ZnK MC1 Overwriter v1

a guest
Aug 3rd, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.72 KB | None | 0 0
  1. #Deletes the *.bin line from each *.mc1 file in the \data\cclm\map4 folder
  2. import os
  3. import struct
  4.  
  5. def get_data(filename):
  6.     totalbytes = os.path.getsize(filename)
  7.     infile = open(filename, 'rb')
  8.     totalfiledata = infile.read(totalbytes)
  9.     infile.close()
  10.     return totalfiledata
  11.  
  12. def replacestr(origstr,replacestr,startpos,replacelen):
  13. #Returns a string with a replaced sub-string
  14. #origstr - the original string, replacestr = the string to replace
  15. #startpos - where the replacement string should go
  16. #replacelen - how many characters of the original string to replace
  17.     return origstr[:startpos] + replacestr + origstr[startpos+replacelen:]
  18.  
  19. #The *_1 names have been removed from the list
  20. filenamelist = ['c0000','c000b','c000c','c0010','c001c','c0100','c0100',
  21.     'c010b','c010c','c0110','c0110','c011b','c011c','c0140','c014c','c0150',
  22.     'c015c','c0170','c017c','c0200','c020b','c020c','c0210','c0220','c0240',
  23.     'c0250','c0300','c030b','c030c','c0310','c0320','c0330','c0340','c0350',
  24.     'c0400','c040b','c040c','c0410','c041c','c0420','c042c','c0450','c045b',
  25.     'c045c','c0470','c047b','c047c','c0500','c050b','c050c','c0510','c0570',
  26.     'c0580','c0590','c0591','c0592','c0593','c0594','c0595','c0596','c0597',
  27.     'c0600','c0800','c1000','c100b','c100c','c1010','c101c','c1020','c102c',
  28.     'c1030','c103c','c1040','c1050','c1100','c110b','c110c','c1110','c1120',
  29.     'c112c','c1130','c1150','c115c','c1160','c1170','c1200','c120b','c120c',
  30.     'c1210','c121b','c1220','c1300','c130b','c130c','c1310','c131b','c1320',
  31.     'c1330','c133b','c1340','c134b','c1400','c140b','c140c','c1410','c1420',
  32.     'c1430','c1440','c1450','c1460','e0000','e0010','e0110','e0111','e0310',
  33.     'e0410','e0510','e3000','e3010','e3110','e3300','e3400','e3500','m0000',
  34.     'm0001','m0002','m0010','m0011','m0012','m0013','m0100','m0101','m0102',
  35.     'm0110','m0111','m0112','m0113','m1000','m1010','m1020','m1030','m1060',
  36.     'm1070','m1080','m1090','m1099','m1140','m1150','m2000','m2010','m2020',
  37.     'm2030','m2040','m2050','m2060','m2099','m3000','m3001','m3002','m3004',
  38.     'm3010','m3011','m3012','m3013','m3014','m3020','m3021','m3022','m3023',
  39.     'm3030','m3031','m3032','m3033','m3034','m3035','m3099','r0000','r0000',
  40.     'r000b','r0020','r0030','r0040','r0050','r0100','r0110','r0120','r1000',
  41.     'r1010','r1020','r1030','r1040','r1500','r150b','r1520','r152b','r1530',
  42.     'r153b','r1540','r154b','r1580','r158b','r2000','r2010','r2020','r2030',
  43.     'r2040','r2050','r2060','r206b','r2070','r3000','r3060','r3070','r307b',
  44.     'r3080','r308b','r308e','r3100','r3110','r3120','r3130','t0000','t0010',
  45.     't0020','t0500','t050b','t0510','t051b','t0520','t052b','t0530','t053b',
  46.     't0600','t0610','t0620','t0630','t1000','t100b','t1010','t101b','t1020',
  47.     't102b','t1030','t103b','t1040','t104b','t1050','t105b','t1060','t106b',
  48.     't1100','t110b','t1110','t111b','t1120','t112b','t1130','t113b','t1140',
  49.     't114b','t1150','t115b','t1160','t116b','t1170','t117b','t1180','t118b',
  50.     't1190','t119b','t1200','t120b','t1210','t121b','t1500','t150b','t1510',
  51.     't151b','t1520','t152b','t1530','t1530','t153b','t1540','t1540',
  52.     't154b','t1550','t155b','t1560','t156b','t1600','t160b','t1610','t161b',
  53.     't1620','t162b','t1630','t163b','t1640','t164b','t1650','t165b','t2000',
  54.     't2010','t2020','t2100','t2500','t2510','t2520','t3000','t3010','t3510',
  55.     't4000','t4010','t4020','t4100']
  56.  
  57. for file in filenamelist:
  58.     filedata = get_data(file + '.mc1.orig') #Gets data
  59.     startpos = filedata.find(file) #Find position within data
  60.     filedata = replacestr(filedata,"\x00" * 32,startpos,32) #Delete the line
  61.     outfile = open(file + '.mc1','wb') #Write output
  62.     outfile.write(filedata)
  63.     outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement