mirror of
https://github.com/Virtual-World-RE/NeoGF.git
synced 2024-11-15 12:45:34 +01:00
Update pzztool.py
Bug fixes
This commit is contained in:
parent
665096dd87
commit
99da6dab1b
|
@ -6,7 +6,7 @@ from struct import unpack
|
||||||
from os import listdir
|
from os import listdir
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__version__ = "0.14.5"
|
__version__ = "0.14.6"
|
||||||
__author__ = "rigodron, algoflash, GGLinnk"
|
__author__ = "rigodron, algoflash, GGLinnk"
|
||||||
__OriginalAutor__ = "infval"
|
__OriginalAutor__ = "infval"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
|
@ -75,8 +75,8 @@ def remove_padding(file_content: bytearray):
|
||||||
|
|
||||||
def bytes_align_compress(bout: bytes):
|
def bytes_align_compress(bout: bytes):
|
||||||
# Comme le montre le fichier pl080d/006C_pl080d.pzzp, on ajoute 0x800 si c'est aligné sur un multiple
|
# Comme le montre le fichier pl080d/006C_pl080d.pzzp, on ajoute 0x800 si c'est aligné sur un multiple
|
||||||
if len(bout) % CHUNK_SIZE == 0:
|
#if len(bout) % CHUNK_SIZE == 0:
|
||||||
return bout.ljust(CHUNK_SIZE * (len(bout) / CHUNK_SIZE + 1), b"\x00")
|
# return bout.ljust(CHUNK_SIZE * int(len(bout) / CHUNK_SIZE + 1), b"\x00")
|
||||||
return bout.ljust(CHUNK_SIZE * ceil(len(bout) / CHUNK_SIZE), b"\x00")
|
return bout.ljust(CHUNK_SIZE * ceil(len(bout) / CHUNK_SIZE), b"\x00")
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ def pzz_decompress(compressed_bytes: bytes):
|
||||||
|
|
||||||
|
|
||||||
def pzz_compress(uncompressed_bytes: bytes):
|
def pzz_compress(uncompressed_bytes: bytes):
|
||||||
|
uncompressed_bytes += b"\x00"
|
||||||
compressed_bytes = bytearray(2)
|
compressed_bytes = bytearray(2)
|
||||||
size_uncompressed_bytes = len(uncompressed_bytes) // 2 * 2
|
size_uncompressed_bytes = len(uncompressed_bytes) // 2 * 2
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@ def pzz_unpack(pzz_path: Path, dest_folder: Path, auto_decompress: bool = False)
|
||||||
def pzz_pack(src_path: Path, dest_file: Path, auto_compress: bool = False):
|
def pzz_pack(src_path: Path, dest_file: Path, auto_compress: bool = False):
|
||||||
if dest_file == Path('.'):
|
if dest_file == Path('.'):
|
||||||
dest_file = src_path.with_suffix(".pzz")
|
dest_file = src_path.with_suffix(".pzz")
|
||||||
if dest_file.suffix != ".pzz" and pzz_path.suffix != ".mdt":
|
if dest_file.suffix != ".pzz" and dest_file.suffix != ".mdt":
|
||||||
logging.warning(f"Invalid file format '{dest_file.suffix}' : dest must be a pzz or mdt")
|
logging.warning(f"Invalid file format '{dest_file.suffix}' : dest must be a pzz or mdt")
|
||||||
|
|
||||||
# On récupère les fichiers du dossier à compresser
|
# On récupère les fichiers du dossier à compresser
|
||||||
|
|
Loading…
Reference in New Issue
Block a user