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