Skip to content

Commit 13dd372

Browse files
MacSplodySharlikran
authored andcommitted
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 c9cea91 commit 13dd372

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
@@ -410,18 +410,6 @@ def scanModFile(self, modFile, progress): # scanModFile0
410410

411411
def buildPatch(self,log,progress): # buildPatch0
412412
"""Adds merged lists to patchfile."""
413-
414-
def regions_differ(patch_value, value_):
415-
"""
416-
Required for regions because comparing using `==` or `!=`
417-
results in false positives.
418-
"""
419-
sorted_patch_value = sorted(patch_value)
420-
sorted_value = sorted(value_)
421-
regions_compare = set(sorted_value).difference(
422-
sorted_patch_value)
423-
return (bool(regions_compare))
424-
425413
def handlePatchCellBlock(patchCellBlock):
426414
"""
427415
This function checks if an attribute or flag in CellData has
@@ -436,12 +424,13 @@ def handlePatchCellBlock(patchCellBlock):
436424
modified=False
437425
for attr, value in cellData[patchCellBlock.cell.fid].viewitems():
438426
if attr == 'regions':
439-
if regions_differ(patchCellBlock.cell.__getattribute__(attr), value):
427+
if set(value).difference(set(patchCellBlock.cell.__getattribute__(attr))):
440428
patchCellBlock.cell.__setattr__(attr, value)
441429
modified = True
442-
elif patchCellBlock.cell.__getattribute__(attr) != value:
443-
patchCellBlock.cell.__setattr__(attr, value)
444-
modified = True
430+
else:
431+
if patchCellBlock.cell.__getattribute__(attr) != value:
432+
patchCellBlock.cell.__setattr__(attr, value)
433+
modified=True
445434
for flag, value in cellData[
446435
patchCellBlock.cell.fid + ('flags',)].viewitems():
447436
if patchCellBlock.cell.flags.__getattr__(flag) != value:

0 commit comments

Comments
 (0)