diff --git a/Klib/GMblob.py b/Klib/GMblob.py index 9b2f854..f922bee 100644 --- a/Klib/GMblob.py +++ b/Klib/GMblob.py @@ -120,6 +120,8 @@ def _get_padding(self, alignement = 16): padding = alignement - misalignement return padding + + return self.get_str(name_str_offset) def _write_to_file_otherchunk(self,token): self.filein.seek(self.chunk_list[token]["offset"]) @@ -446,6 +448,32 @@ def get_str(self, str_offset): size = unpack('= nb_entries: + return None + + # Jump to the offset of the specific audiogroup entry + # AGRP Chunk: [4B Count] [4B Offset0] [4B Offset1] ... + self.filein.seek(self.chunk_list["AGRP"]["offset"] + 12 + (audiogroup_id * 4)) + entry_offset = unpack(' self.filein_size: + return None + + return self.get_str(name_str_offset) def __init_sond(self): self.filein.seek(self.chunk_list["SOND"]["offset"] + 8) @@ -512,7 +540,35 @@ def __init_sond(self): def __init_audiogroup_dat(self, audiogroup): if audiogroup > 0 and not f"{audiogroup}" in self.audiogroup_dat.keys(): - self.audiogroup_dat[f"{audiogroup}"] = GMaudiogroup(self.filein_path.parents[0] / f"audiogroup{audiogroup}.dat" , self.verbose, self.audiosettings, audiogroup) + # 1. Get the internal friendly name + ag_name = self.__get_audiogroup_filename(audiogroup) + base_path = self.filein_path.parents[0] + + # Define potential filenames + potential_names = [ + ag_name, # Friendly name (e.g., Aud_SFX_Weapons) + f"{ag_name}.dat", # Friendly name + .dat + f"audiogroup{audiogroup}.dat" # Indexed name (e.g., audiogroup1.dat) + ] + + ag_path = None + for name in potential_names: + test_path = base_path / name + if test_path.exists(): + ag_path = test_path + break + + if ag_path: + self._vprint(f"[AGRP {audiogroup}] Found asset file: {ag_path.name}") + self.audiogroup_dat[f"{audiogroup}"] = GMaudiogroup( + ag_path, + self.verbose, + self.audiosettings, + audiogroup + ) + else: + self._vprint(f"Warning: Could not find audio file for group '{ag_name}' " + f"(Tried: {', '.join(potential_names)})") def __sond_get_raw_entry(self,key):