diff --git a/UnityPy/environment.py b/UnityPy/environment.py index c4a60aea..08ea909f 100644 --- a/UnityPy/environment.py +++ b/UnityPy/environment.py @@ -176,7 +176,11 @@ def load_zip_file(self, value): def save(self, pack="none", out_path="output"): """Saves all changed assets. Mark assets as changed using `.mark_changed()`. - pack = "none" (default) or "lz4" + + ``pack`` is forwarded as ``packer`` to each file's ``save()``. + Supported values depend on the file type, for example: + BundleFile - "none", "lz4", "lz4hc", "lzma", "original" + WebFile - "none", "gzip", "brotli" """ for fname, fitem in self.files.items(): if getattr(fitem, "is_changed", False): diff --git a/UnityPy/files/BundleFile.py b/UnityPy/files/BundleFile.py index 3e17d7de..55390af5 100644 --- a/UnityPy/files/BundleFile.py +++ b/UnityPy/files/BundleFile.py @@ -191,10 +191,12 @@ def save(self, packer=None): packer: can be either one of the following strings - or tuple consisting of (block_info_flag, data_flag) + or tuple consisting of (data_flag, block_info_flag) allowed strings: none - no compression, default, safest bet lz4 - lz4 compression + lz4hc - lz4hc compression + lzma - lzma compression original - uses the original flags """ # file_header @@ -227,6 +229,8 @@ def save(self, packer=None): ) elif packer == "lz4": self.save_fs(writer, data_flag=194, block_info_flag=2) + elif packer == "lz4hc": + self.save_fs(writer, data_flag=195, block_info_flag=3) elif packer == "lzma": self.save_fs(writer, data_flag=65, block_info_flag=1) elif isinstance(packer, tuple): @@ -242,12 +246,13 @@ def save_fs(self, writer: EndianBinaryWriter, data_flag: int, block_info_flag: i # 0b1000000 / 0b11000000 | 64 / 192 - uncompressed # 0b11000010 | 194 - lz4 + # 0b11000011 | 195 - lz4hc # block_info_flag # 0 / 0b1000000 | 0 / 64 - uncompressed # 0b1 | 1 - lzma # 0b10 | 2 - lz4 - # 0b11 | 3 - lz4hc [not implemented] + # 0b11 | 3 - lz4hc # 0b100 | 4 - lzham [not implemented] # data_flag