Ignore invalid strings, some models use them for some reason

This commit is contained in:
Pyogenics
2024-12-09 13:53:29 +00:00
parent e4e395b6e1
commit 11fdb83627
2 changed files with 3 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ class A3DMaterial:
print(f"[A3DMaterial name: {self.name} color: {self.color} diffuse map: {self.diffuseMap}]") print(f"[A3DMaterial name: {self.name} color: {self.color} diffuse map: {self.diffuseMap}]")
def read3(self, stream): def read3(self, stream):
print(stream.tell())
self.name = readLengthPrefixedString(stream) self.name = readLengthPrefixedString(stream)
self.color = unpackStream("<3f", stream) self.color = unpackStream("<3f", stream)
self.diffuseMap = readLengthPrefixedString(stream) self.diffuseMap = readLengthPrefixedString(stream)

View File

@@ -33,7 +33,7 @@ def readNullTerminatedString(stream):
while char != b"\x00": while char != b"\x00":
string += char string += char
char = stream.read(1) char = stream.read(1)
return string.decode("utf8") return string.decode("utf8", errors="ignore")
def calculatePadding(length): def calculatePadding(length):
# (it basically works with rounding) # (it basically works with rounding)
@@ -47,4 +47,4 @@ def readLengthPrefixedString(stream):
paddingSize = calculatePadding(length) paddingSize = calculatePadding(length)
stream.read(paddingSize) stream.read(paddingSize)
return string.decode("utf8") return string.decode("utf8", errors="ignore")