hsr/get_version: prevent reading data.unity3d if not exist

This commit is contained in:
tretrauit 2023-06-17 22:10:42 +07:00
parent f6c9f2ddfe
commit 59da35f1df

View File

@ -56,6 +56,10 @@ class Game(GameABC):
tuple[int, int, int]: The version as a tuple of integers. tuple[int, int, int]: The version as a tuple of integers.
""" """
data_file = self.data_folder().joinpath("data.unity3d")
if not data_file.exists():
return (0, 0, 0)
def bytes_to_int(byte_array: list[bytes]) -> int: def bytes_to_int(byte_array: list[bytes]) -> int:
bytes_as_int = int.from_bytes(byte_array, byteorder="big") bytes_as_int = int.from_bytes(byte_array, byteorder="big")
actual_int = bytes_as_int - 48 # 48 is the ASCII code for 0 actual_int = bytes_as_int - 48 # 48 is the ASCII code for 0