Truncate Theirsce files before insertion

Avoids dangling bytes that make DAT.BIN bigger
This commit is contained in:
Mc-muffin
2023-08-11 23:48:13 -05:00
parent deb2357582
commit 41c63ab6c0
2 changed files with 7 additions and 0 deletions

View File

@@ -35,6 +35,12 @@ class FileIO(object):
def tell(self):
return self.f.tell()
def truncate(self, size=None):
if size is None:
self.f.truncate(self.f.tell())
else:
self.f.truncate(size)
def seek(self, pos, whence=0):
self.f.seek(pos, whence)

View File

@@ -428,6 +428,7 @@ class ToolsTOR(ToolsTales):
#Go at the start of the dialog
#Loop on every Entry and reinsert
theirsce.seek(theirsce.strings_offset + 1)
theirsce.truncate()
nodes = [ele for ele in root.iter('Entry') if ele.find('Id').text != "-1"]
nodes = [ele for ele in nodes if ele.find('PointerOffset').text != "-1"]