def compileData(self): stream = StreamWriter() stream.writeInt(len(self.children)) for child in self.children.values(): stream.write(child.formatData()) stream.write(b'\0' * (0x4408 - stream.tell())) return stream.getvalue()
def compileData(self): stream = StreamWriter() stream.writeInt(len(self.children)) self.recalculateOffsets() for child in self.children.values(): stream.write(child.formatData()) for child in self.children.values(): stream.write(child.data) return stream.getvalue()
def compressor(data): stream = StreamParser(data) chunks = [] header = StreamWriter() # chunkify the data into chunks of 0x20000 bytes while (chunk := stream.read(0x20000)): chunks.append(chunk)
def compileData(self): stream = StreamWriter() offset = 0x290008 names = self.imeta.names() for i in range(len(self.children)): self.imeta.children[names[i]].offset = offset offset += len(self.children[names[i]].data) + 64 stream.write(self.imeta.compileData()) for child in self.children.values(): stream.write(child.formatData()) stream.write(b'\0' * 0x200000) return stream.getvalue()
def imeta_from_scenedata(scenedata, inplace1_loc, inplace2_loc): inplace1 = inplace1_loc inplace2 = inplace2_loc if type(inplace1_loc) != Ipak: print("Loading inplace1..") print("\t" + inplace1_loc) inplace1 = Ipak(inplace1_loc) if type(inplace1_loc) != Ipak: print("Loading inplace2..") print("\t" + inplace2_loc) inplace2 = Ipak(inplace1_loc) print("Finding dependancies") output = StreamWriter() output.writeInt(len(scenedata.Textures) + 14) output.writeInt(0) unlisted_names = [ 'arifle_display_i1', 'expl_flame', 'font_main_00', 'menu_common_i17', 'menu_common_i7', 'menu_manager_i54', 'menu_manager_i5f', 'msg_box_i6', 'part_alias_akill', 'part_alias_normal', 'part_alias_transp', 'part_plasma', 'scorch_pak_parallax', 'xbox_rt_b', 'smoke_sm', 'part_rmp_flame_01' ] dependancies = scenedata.Textures + unlisted_names dependancies.sort() print("Writing dependancies") for texture in dependancies: dependant = inplace1.items.get(texture, None) dependant = inplace2.items.get(texture, dependant) if dependant: output.write(dependant.compile_data()) print("Finalizing") output.write(b'\0' * (0x00290008 - output.tell())) return output.getvalue()
def formatData(self): output = StreamWriter() output.writeString(self.string.ljust(0x108, "\0")) output.writeInt(1) output.writeInt(self.width) output.writeInt(self.height) output.writeInt(1) output.writeInt(self.mip_map_count) output.writeInt(self.face_count) output.writeInt(self.type) output.write(b'\0' * 8) output.writeInt(self.size) output.writeInt(0) output.writeInt(self.size2) output.writeInt(self.offset) output.writeInt(0) output.writeInt(self.size3) output.writeInt(0) return output.getvalue()
def compile(self): stream = StreamWriter() stream.writeString(self.magic) stream.writeInt(self.size) stream.writeInt(self.flags) stream.writeInt(self.height) stream.writeInt(self.width) stream.writeInt(self.pitchOrLinearSize) stream.writeInt(self.depth) stream.writeInt(self.mipmap_count) for item in self.reserved: stream.writeInt(0) self.ddspf.compile(stream) stream.writeInt(self.caps) stream.writeInt(self.caps2) stream.writeInt(self.caps3) stream.writeInt(self.caps4) stream.writeInt(self.reserved2) return stream.getvalue()
def compile(self, stream: StreamWriter): stream.writeInt(self.size) stream.writeInt(self.flags) if self.fourCC: stream.writeString(self.fourCC) else: stream.writeInt(0) stream.writeInt(self.RGBBitCount) stream.writeInt(self.RBitMask) stream.writeInt(self.GBitMask) stream.writeInt(self.BBitMask) stream.writeInt(self.ABitMask)
def formatData(self): output = StreamWriter() output.writeInt(self.offset) output.writeInt(self.size) # if scene data, don't write a string if self.string == "SceneData": output.writeInt(0) else: output.writeInt(self.string_length) output.writeString(self.string, encoding="utf-8") output.writeInt(self.type) # write padding output.write(b"\x00" * 8) return output.getvalue()
def formatData(self): output = StreamWriter() output.writeString(self.string.ljust(0x100, "\0")) output.writeInt(0) output.writeInt(self.type) if self.type == 0: output.write(b'\xff' * 8) else: output.writeInt(self.decompressed_size) output.write(b'\00' * 4) return output.getvalue()
def formatData(self): output = StreamWriter() # don't worry about it. it doesn't need explanation output.write( b"\xf0\x00\xff\xff\xff\xff\x54\x43\x49\x50\x02\x01\xff\xff\xff\xff" ) output.writeInt(self.width) output.writeInt(self.height) output.writeInt(1) output.writeInt(self.face_count) output.write(b"\xf2\x00\xff\xff\xff\xff") output.writeInt(self.type) output.write(b"\xf9\x00\xff\xff\xff\xff") output.writeInt(self.mip_map_count) output.write(b"\xff\x00\xff\xff\xff\xff") output.write(self.data) output.write(b"\x01\x00\xff\xff\xff\xff") return output.getvalue()