Skip to content

Commit 0306beb

Browse files
committed
Fix double exception if discriminator provided when it is not needed
1 parent d7ab0ed commit 0306beb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/UnityTextModifier.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ def findInAssetBundle(self, bundle):
7272
offsets.append(offset)
7373
start = offset + 1
7474
if len(offsets) == 0:
75-
raise IndexError(f"No asset found for {self.shortString}")
75+
raise IndexError(f"WARNING: No asset found for {self.shortString}")
7676
if self.discriminator == None:
7777
if len(offsets) > 1:
78-
raise IndexError(f"Multiple assets found for {self.shortString}, candidates are " + ", ".join(f"{index}: 0x{offset:x}" for index, offset in enumerate(offsets)) + ". Please add a field like 'Discriminator: 0' to indicate which block should apply to which asset (do NOT use quotes around the number, do not use the raw address). For an example, see https://github.com/07th-mod/higurashi-dev-guides/wiki/UI-editing-scripts#unitytextmodifier")
78+
raise IndexError(f"WARNING: Multiple assets found for {self.shortString}, candidates are " + ", ".join(f"{index}: 0x{offset:x}" for index, offset in enumerate(offsets)) + ". Please add a field like 'Discriminator: 0' to indicate which block should apply to which asset (do NOT use quotes around the number, do not use the raw address). For an example, see https://github.com/07th-mod/higurashi-dev-guides/wiki/UI-editing-scripts#unitytextmodifier")
7979
self.offset = offsets[0]
8080
else:
8181
if len(offsets) <= self.discriminator:
82-
raise IndexError(f"Not enough offsets found for ${self.trimmedE} / {self.trimmedJ} to meet request for #{self.discriminator}, there were only {len(offsets)}")
82+
raise IndexError(f"WARNING: Not enough offsets found for {self.shortString} to meet request for #{self.discriminator}, there were only {len(offsets)}")
8383
self.offset = offsets[self.discriminator]
8484

8585
def checkObject(self, id, object, bundle):
@@ -113,6 +113,7 @@ def __str__(self):
113113
try: return f"<ScriptEdit for position 0x{self.offset:x}>"
114114
except: return "<ScriptEdit for unknown position>"
115115

116+
warning_count = 0
116117

117118
with open(sys.argv[2], encoding="utf-8") as jsonFile:
118119
edits = [ScriptEdit.fromJSON(x) for x in json.load(jsonFile)]
@@ -127,6 +128,8 @@ def __str__(self):
127128
print(f"Found {edit.shortString} at offset 0x{edit.offset:x}")
128129
except IndexError as e:
129130
print(e)
131+
warning_count =+ 1
132+
130133
edits = newEdits
131134

132135
assetsFile.seek(0)
@@ -136,3 +139,6 @@ def __str__(self):
136139
edit.checkObject(id, obj, bundle)
137140
for edit in edits:
138141
edit.write(sys.argv[3])
142+
143+
if warning_count > 0:
144+
print(">>>>>>>> ONE OR MORE WARNINGS OCCURRED, please check logs! <<<<<<<<<")

0 commit comments

Comments
 (0)