Skip to content

Commit 150ca3b

Browse files
authored
Merge pull request K0lb3#217 from K0lb3/K0lb3-patch-1
Minor fixes
2 parents cc87a54 + 765b84c commit 150ca3b

6 files changed

Lines changed: 15 additions & 25 deletions

File tree

‎UnityPy/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.10.6"
1+
__version__ = "1.10.7"
22

33
from .environment import Environment
44
from .helpers.ArchiveStorageManager import set_assetbundle_decrypt_key

‎UnityPy/export/AudioClipConverter.py‎

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,15 @@ def import_pyfmodex():
5757

5858
# prepare the environment for pyfmodex
5959
if system == "Windows":
60-
# register fmod.dll, so that windll.fmod in pyfmodex can find it
61-
ctypes.WinDLL(os.path.join(LIB_PATH, "fmod.dll"))
62-
import pyfmodex
60+
os.environ["PYFMODEX_DLL_PATH"] = os.path.join(LIB_PATH, "fmod.dll")
6361
else:
64-
# It's a bit more complicated on Linux and Mac
65-
# as CDLL doesn't cache the loaded libraries.
66-
# So our only option is to hook into the ctypes loader
67-
# and add the path to the library there.
68-
CDLL = ctypes.CDLL
69-
70-
def cdll_hook(name, *args, **kwargs):
71-
if name.startswith("libfmod"):
72-
name = os.path.join(LIB_PATH, name)
73-
return CDLL(name, *args, **kwargs)
74-
75-
ctypes.CDLL = cdll_hook
76-
import pyfmodex
77-
78-
ctypes.CDLL = CDLL
62+
ext = "dylib" if system == "Darwin" else "so"
63+
os.environ["PYFMODEX_DLL_PATH"] = os.path.join(LIB_PATH, f"libfmod.{ext}")
64+
65+
# hotfix ctypes for pyfmodex for non windows
66+
ctypes.windll = getattr(ctypes, "windll", None)
67+
68+
import pyfmodex
7969

8070

8171
def extract_audioclip_samples(audio) -> dict:
@@ -109,7 +99,7 @@ def dump_samples(clip):
10999
sound = system.create_sound(
110100
bytes(clip.m_AudioData),
111101
pyfmodex.flags.MODE.OPENMEMORY,
112-
exinfo=pyfmodex.system.CREATESOUNDEXINFO(
102+
exinfo=pyfmodex.structure_declarations.CREATESOUNDEXINFO(
113103
length=clip.m_Size,
114104
numchannels=clip.m_Channels,
115105
defaultfrequency=clip.m_Frequency,
@@ -134,7 +124,7 @@ def dump_samples(clip):
134124

135125
def subsound_to_wav(subsound):
136126
# get sound settings
137-
length = subsound.get_length(0x00000004) # TIMEUNIT.PCMBYTES
127+
length = subsound.get_length(pyfmodex.enums.TIMEUNIT.PCMBYTES)
138128
channels = subsound.format.channels
139129
bits = subsound.format.bits
140130
sample_rate = int(subsound.default_frequency)

‎UnityPy/files/SerializedFile.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def set_version(self, string_version):
328328
build_type = re.findall(r"([^\d.])", string_version)
329329
self.build_type = BuildType(build_type[0] if build_type else "")
330330
version_split = re.split(r"\D", string_version)
331-
self.version = tuple(int(x) for x in version_split)
331+
self.version = tuple(int(x) for x in version_split[:4])
332332

333333
def read_type_tree(self):
334334
type_tree = []

‎UnityPy/helpers/Tpk.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def fromString(version: str) -> UnityVersion:
292292
return UnityVersion(version.split("."))
293293

294294
@staticmethod
295-
def fromList(major: int, minor: int, patch: int, build: int) -> UnityVersion:
295+
def fromList(major: int = 0, minor: int = 0, patch: int = 0, build: int = 0) -> UnityVersion:
296296
return UnityVersion(major << 48 | minor << 32 | patch << 16 | build)
297297

298298
@property

‎UnityPy/streams/EndianBinaryReader.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import List, Union
55
from io import BytesIO, BufferedIOBase, IOBase, BufferedReader
66

7-
reNot0 = re.compile(b"(.*?)\x00")
7+
reNot0 = re.compile(b"(.*?)\x00", re.S)
88

99
SYS_ENDIAN = "<" if sys.byteorder == "little" else ">"
1010

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies = [
4646
# raw typetree dumping
4747
"tabulate",
4848
# audio extraction
49-
"pyfmodex",
49+
"pyfmodex >= 0.7.1",
5050
# filesystem handling
5151
"fsspec",
5252
]

0 commit comments

Comments
 (0)