Skip to content

Commit 2e4f6bb

Browse files
committed
Correct a few changes
Removed Regions differ, set.difference will check the regions correctly regardless of order. Restored else after "if attr = 'regions':" Otherwise Regions will always be kept because of the "elif"
1 parent e5ef5d3 commit 2e4f6bb

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

Mopy/bash/patcher/patchers/importers.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,6 @@ def scanModFile(self, modFile, progress): # scanModFile0
406406

407407
def buildPatch(self,log,progress): # buildPatch0
408408
"""Adds merged lists to patchfile."""
409-
410-
def regions_differ(patch_value, value_):
411-
"""
412-
Required for regions because comparing using `==` or `!=`
413-
results in false positives.
414-
"""
415-
sorted_patch_value = sorted(patch_value)
416-
sorted_value = sorted(value_)
417-
regions_compare = set(sorted_value).difference(
418-
sorted_patch_value)
419-
return (bool(regions_compare))
420-
421409
def handlePatchCellBlock(patchCellBlock):
422410
"""
423411
This function checks if an attribute or flag in CellData has
@@ -432,12 +420,13 @@ def handlePatchCellBlock(patchCellBlock):
432420
modified=False
433421
for attr, value in cellData[patchCellBlock.cell.fid].viewitems():
434422
if attr == 'regions':
435-
if regions_differ(patchCellBlock.cell.__getattribute__(attr), value):
423+
if set(value).difference(set(patchCellBlock.cell.__getattribute__(attr))):
436424
patchCellBlock.cell.__setattr__(attr, value)
437425
modified = True
438-
elif patchCellBlock.cell.__getattribute__(attr) != value:
439-
patchCellBlock.cell.__setattr__(attr, value)
440-
modified = True
426+
else:
427+
if patchCellBlock.cell.__getattribute__(attr) != value:
428+
patchCellBlock.cell.__setattr__(attr, value)
429+
modified=True
441430
for flag, value in cellData[
442431
patchCellBlock.cell.fid + ('flags',)].viewitems():
443432
if patchCellBlock.cell.flags.__getattr__(flag) != value:

0 commit comments

Comments
 (0)