Exemplo n.º 1
0
    def get_file(self, file_name):
        if file_name in self.instantiated_object_files:
            return self.instantiated_object_files[file_name]

        file_entry = self.get_file_entry(file_name)
        if file_entry is None:
            return None

        if file_name.endswith(".dzs"):
            dzx = DZx(file_entry)
            self.instantiated_object_files[file_name] = dzx
            return dzx
        elif file_name.endswith(".dzr"):
            dzx = DZx(file_entry)
            self.instantiated_object_files[file_name] = dzx
            return dzx
        elif file_name == "event_list.dat":
            event_list = EventList(file_entry)
            self.instantiated_object_files[file_name] = event_list
            return event_list
        elif file_name.endswith(".bmg"):
            bmg = BMG(file_entry)
            self.instantiated_object_files[file_name] = bmg
            return bmg
        elif file_name.endswith(".bdl"):
            bdl = BDL(file_entry)
            self.instantiated_object_files[file_name] = bdl
            return bdl
        elif file_name.endswith(".bmd"):
            bmd = BMD(file_entry)
            self.instantiated_object_files[file_name] = bmd
            return bmd
        elif file_name.endswith(".bmt"):
            bmt = BMT(file_entry)
            self.instantiated_object_files[file_name] = bmt
            return bmt
        elif file_name.endswith(".brk"):
            brk = BRK(file_entry)
            self.instantiated_object_files[file_name] = brk
            return brk
        elif file_name.endswith(".bti"):
            bti = BTIFileEntry(file_entry)
            self.instantiated_object_files[file_name] = bti
            return bti
        elif file_name == "cmapdat.bin":
            chart_list = ChartList(file_entry)
            self.instantiated_object_files[file_name] = chart_list
            return chart_list
        else:
            raise Exception("Unknown file type: %s" % file_name)
Exemplo n.º 2
0
 def __init__(self, data):
   self.data = data
   
   if try_read_str(self.data, 0, 4) == "Yaz0":
     self.data = Yaz0Decompressor.decompress(self.data)
   
   data = self.data
   
   self.size = read_u32(data, 4)
   self.file_data_list_offset = read_u32(data, 0xC) + 0x20
   self.file_data_total_size = read_u32(data, 0x10)
   self.file_data_total_size_2 = read_u32(data, 0x14)
   self.file_data_total_size_3 = read_u32(data, 0x18)
   num_nodes = read_u32(data, 0x20)
   node_list_offset = 0x40
   self.total_num_file_entries = read_u32(data, 0x28)
   file_entries_list_offset = read_u32(data, 0x2C) + 0x20
   self.string_list_offset = read_u32(data, 0x34) + 0x20
   
   self.nodes = []
   for node_index in range(0, num_nodes):
     offset = node_list_offset + node_index*0x10
     node = Node(data, offset)
     self.nodes.append(node)
   
   self.file_entries = []
   self.dzx_files = []
   self.event_list_files = []
   self.bmg_files = []
   self.bdl_files = []
   self.bti_files = []
   self.chart_lists = []
   for node in self.nodes:
     for file_index in range(node.first_file_index, node.first_file_index+node.num_files):
       file_entry_offset = file_entries_list_offset + file_index*0x14
       
       file_entry = FileEntry(data, file_entry_offset, self)
       self.file_entries.append(file_entry)
       node.files.append(file_entry)
       
       if file_entry.is_dir:
         continue
       
       if file_entry.name.endswith(".dzs"):
         dzx = DZx(file_entry)
         self.dzx_files.append(dzx)
       elif file_entry.name.endswith(".dzr"):
         dzx = DZx(file_entry)
         self.dzx_files.append(dzx)
       elif file_entry.name == "event_list.dat":
         event_list = EventList(file_entry)
         self.event_list_files.append(event_list)
       elif file_entry.name.endswith(".bmg"):
         bmg = BMG(file_entry)
         self.bmg_files.append(bmg)
       elif file_entry.name.endswith(".bdl"):
         bdl = BDL(file_entry)
         self.bdl_files.append(bdl)
       elif file_entry.name.endswith(".bti"):
         bti = BTIFile(file_entry)
         self.bti_files.append(bti)
       elif file_entry.name == "cmapdat.bin":
         chart_list = ChartList(file_entry)
         self.chart_lists.append(chart_list)