def basic_deprotection(self): if self.tag_index is None: return for b in self.tag_index.tag_index: if not b.path: b.path = self.map_header.map_name HaloMap.basic_deprotection(self)
def generate_map_info_string(self): string = HaloMap.generate_map_info_string(self) string += """ Tag index: tag count == %s tag types count == %s root tags count == %s index array pointer == %s""" % ( self.orig_tag_index.tag_count, self.orig_tag_index.tag_types_count, self.orig_tag_index.root_tags_count, self.tag_index.tag_index_offset - self.map_magic) for arr_name, arr in ( ("Partitions", self.map_header.partitions), ("Sections", self.map_header.sections), ): string += "\n%s:\n" % arr_name names = ("debug", "resource", "tag", "locale")\ if arr.NAME_MAP else range(len(arr)) for name in names: section = arr[name] string += """ %s: address == %s size == %s offset == %s""" % (name, section[0], section[1], section.file_offset) return string
def load_map(self, map_path, **kwargs): HaloMap.load_map(self, map_path, **kwargs) self.tag_index = h3_to_h1_tag_index(self.map_header, self.tag_index) self.basic_deprotection() tag_index_array = self.tag_index.tag_index self.tag_index_manager = TagIndexManager(tag_index_array) self.string_id_manager = StringIdManager( self.map_header.strings.string_id_table, self.string_id_set_offsets, ) for sect in self.map_header.sections: self.map_pointer_converter.add_page_info(sect.virtual_address, sect.file_offset, sect.size) for part in self.map_header.partitions: self.map_pointer_converter.add_page_info(part.load_address, part.file_offset, part.size) self.load_root_tags() play_meta = self.root_tags.get("cache_file_resource_layout_table") if play_meta: self.shared_map_names = list( b.map_path.lower().replace('\\', '/').split("/")[-1].split( ".")[0] for b in play_meta.external_cache_references.STEPTREE) self.rawdata_manager = RawdataManager(self) map_type = self.map_header.map_type.data if map_type >= 2 and map_type < 5: self.is_resource = True ext_cache_name = HALO3_SHARED_MAP_TYPES[map_type - 2] for map_name, halo_map in self.maps.items(): # update each map's rawdata_manager so each one # knows what name the shared caches are named. halo_map.rawdata_manager.add_shared_map_name( ext_cache_name, self.map_header.map_name) self.clear_map_cache()
def load_map(self, map_path, **kwargs): HaloMap.load_map(self, map_path, **kwargs) tag_index = self.tag_index if self.engine == "halo2alpha": self.tag_index = h2_alpha_to_h1_tag_index(self.map_header, tag_index) else: self.tag_index = h2_to_h1_tag_index(self.map_header, tag_index) # add the tag data section self.map_pointer_converter.add_page_info( self.index_magic, self.map_header.tag_index_header_offset, self.map_header.tag_index_data_size + self.map_header.tag_data_size) self.string_id_manager = StringIdManager( self.map_header.strings.string_id_table, (), ) self.tag_index_manager = TagIndexManager(self.tag_index.tag_index) map_type = self.map_header.map_type.data - 1 if map_type > 0 and map_type < 4: self.is_resource = True self.maps[HALO2_MAP_TYPES[map_type]] = self # get the sound_cache_file_gestalt meta try: if self.engine == "halo2vista": ugh__id = None for b in self.tag_index.tag_index: if int_to_fourcc(b.class_1.data) == "ugh!": ugh__id = b.id & 0xFFff break self.ugh__meta = self.get_meta(ugh__id) if self.ugh__meta is None: print("Could not read sound_cache_file_gestalt tag") except Exception: print(format_exc()) print("Could not read sound_cache_file_gestalt tag") self.clear_map_cache()
def generate_map_info_string(self): string = HaloMap.generate_map_info_string(self) string += """ Calculated information: index magic == %s map magic == %s """ % (self.index_magic, self.map_magic) if self.engine == "halo2alpha": string += ((""" Tag index: tag count == %s scenario tag id == %s index array pointer == %s""") % (self.orig_tag_index.tag_count, self.orig_tag_index.scenario_tag_id & 0xFFff, self.tag_index.tag_index_offset)) else: used_tag_count = 0 local_tag_count = 0 for index_ref in self.tag_index.tag_index: if is_reserved_tag(index_ref): continue elif index_ref.meta_offset != 0: local_tag_count += 1 used_tag_count += 1 string += ((""" Tag index: tag count == %s used tag count == %s local tag count == %s tag types count == %s scenario tag id == %s globals tag id == %s index array pointer == %s""") % (self.orig_tag_index.tag_count, used_tag_count, local_tag_count, self.orig_tag_index.tag_types_count, self.orig_tag_index.scenario_tag_id & 0xFFff, self.orig_tag_index.globals_tag_id & 0xFFff, self.tag_index.tag_index_offset)) return string
def __init__(self, maps=None): HaloMap.__init__(self, maps) self.setup_tag_headers()
def __init__(self, maps=None): self.root_tags = {} HaloMap.__init__(self, maps) self.setup_tag_headers()