Skip to content

Commit

Permalink
Unify scanOrder and editOrder
Browse files Browse the repository at this point in the history
scanOrder was equal to editOrder for every single patcher, so it made no
sense to have them split up - YAGNI.

Under #312
  • Loading branch information
Infernio committed Dec 1, 2020
1 parent c966a48 commit 8a9b581
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 30 deletions.
3 changes: 1 addition & 2 deletions Mopy/bash/game/oblivion/patcher/special.py
Expand Up @@ -39,8 +39,7 @@ class _ExSpecial(Abstract_Patcher):
"""Those used to be subclasses of SpecialPatcher that did not make much
sense as they did not use scan_more."""
patcher_group = u'Special'
scanOrder = 40
editOrder = 40
patcher_order = 40

@classmethod
def gui_cls_vars(cls):
Expand Down
6 changes: 2 additions & 4 deletions Mopy/bash/patcher/base.py
Expand Up @@ -40,9 +40,8 @@
class Abstract_Patcher(object):
"""Abstract base class for patcher elements - must be the penultimate class
in MRO (method resolution order), just before object"""
scanOrder = 10
editOrder = 10
patcher_group = u'UNDEFINED'
patcher_order = 10
iiMode = False
# TODO naming (_patcher_top_sigs ?) and unify getTypes/read/writeClasses
_read_write_records = () # top group signatures this patcher patches
Expand Down Expand Up @@ -113,8 +112,7 @@ class AMultiTweaker(Abstract_Patcher):
"""Combines a number of sub-tweaks which can be individually enabled and
configured through a choice menu."""
patcher_group = u'Tweakers'
scanOrder = 30
editOrder = 30
patcher_order = 30
_tweak_classes = [] # override in implementations

def __init__(self, p_name, p_file, enabled_tweaks):
Expand Down
6 changes: 4 additions & 2 deletions Mopy/bash/patcher/patch_files.py
Expand Up @@ -239,7 +239,8 @@ def scanLoadMods(self,progress):
else:
progress(pstate, u'%s\n' % modName + _(u'Scanning...'))
self.update_patch_records_from_mod(modFile)
for patcher in sorted(self._patcher_instances, key=attrgetter(u'scanOrder')):
for patcher in sorted(self._patcher_instances,
key=attrgetter(u'patcher_order')):
if iiMode and not patcher.iiMode: continue
progress(pstate, u'%s\n%s' % (modName, patcher.getName()))
patcher.scan_mod_file(modFile,nullProgress)
Expand Down Expand Up @@ -286,7 +287,8 @@ def buildPatch(self,log,progress):
# Run buildPatch on each patcher
self.keepIds |= self.mergeIds
subProgress = SubProgress(progress, 0, 0.9, len(self._patcher_instances))
for index,patcher in enumerate(sorted(self._patcher_instances, key=attrgetter(u'editOrder'))):
for index,patcher in enumerate(sorted(self._patcher_instances,
key=attrgetter(u'patcher_order'))):
subProgress(index,_(u'Completing')+u'\n%s...' % patcher.getName())
patcher.buildPatch(log,SubProgress(subProgress,index))
# Trim records to only keep ones we actually changed
Expand Down
12 changes: 4 additions & 8 deletions Mopy/bash/patcher/patchers/base.py
Expand Up @@ -175,15 +175,13 @@ def buildPatch(self,log,progress):
# Patchers: 10 ----------------------------------------------------------------
class AliasModNamesPatcher(Patcher):
"""Specify mod aliases for patch files."""
scanOrder = 10
editOrder = 10
patcher_group = u'General'
patcher_order = 10

class MergePatchesPatcher(ListPatcher):
"""Merges specified patches into Bashed Patch."""
scanOrder = 10
editOrder = 10
patcher_group = u'General'
patcher_order = 10

def __init__(self, p_name, p_file, p_sources):
super(MergePatchesPatcher, self).__init__(p_name, p_file, p_sources)
Expand All @@ -196,9 +194,8 @@ def __init__(self, p_name, p_file, p_sources):
# TODO move this to a file it's imported after MreRecord.simpleTypes is set
class ReplaceFormIDsPatcher(ListPatcher):
"""Imports Form Id replacers into the Bashed Patch."""
scanOrder = 15
editOrder = 15
patcher_group = u'General'
patcher_order = 15

def __init__(self, p_name, p_file, p_sources):
super(ReplaceFormIDsPatcher, self).__init__(p_name, p_file, p_sources)
Expand Down Expand Up @@ -386,8 +383,7 @@ def swapper(oldId):
class ImportPatcher(ListPatcher):
"""Subclass for patchers in group Importer."""
patcher_group = u'Importers'
scanOrder = 20
editOrder = 20
patcher_order = 20
# Override in subclasses as needed
logMsg = u'\n=== ' + _(u'Modified Records')

Expand Down
7 changes: 5 additions & 2 deletions Mopy/bash/patcher/patchers/multitweak_assorted.py
Expand Up @@ -851,6 +851,9 @@ def tweak_record(self, record):
#------------------------------------------------------------------------------
class TweakAssortedPatcher(MultiTweaker):
"""Tweaks assorted stuff. Sub-tweaks behave like patchers themselves."""
scanOrder = 29 # Run before other tweakers (due to the 'playable' tweaks)
editOrder = 29
# Run this before all other tweakers, since it contains the 'playable'
# tweaks, which set the playable flag on various records. Tweaks from other
# tweakers use this flag to determine which records to target, so they
# *must* run afterwards or we'll miss some records.
patcher_order = 29
_tweak_classes = [globals()[t] for t in bush.game.assorted_tweaks]
6 changes: 2 additions & 4 deletions Mopy/bash/patcher/patchers/preservers.py
Expand Up @@ -398,8 +398,7 @@ def _parse_csv_sources(self, progress):
#------------------------------------------------------------------------------
class ImportStatsPatcher(_APreserver):
"""Import stats from mod file."""
scanOrder = 28
editOrder = 28 #--Run ahead of bow patcher
patcher_order = 28 # Run ahead of Bow Reach Fix ##: This seems unneeded
logMsg = u'\n=== ' + _(u'Imported Stats')
srcsHeader = u'=== ' + _(u'Source Mods/Files')
# Don't patch Editor IDs - those are only in statsTypes for the
Expand All @@ -426,8 +425,7 @@ class ImportTextPatcher(_APreserver):
# this could potentially be refactored and reused for FO4's modifications
class ImportWeaponModificationsPatcher(_APreserver):
"""Merge changes to weapon modifications for FalloutNV."""
scanOrder = 27
editOrder = 27
patcher_order = 27 ##: This seems unneeded + no reason given
rec_attrs = {b'WEAP': (
u'modelWithMods', u'firstPersonModelWithMods', u'weaponMods',
u'soundMod1Shoot3Ds', u'soundMod1Shoot2D', u'effectMod1',
Expand Down
3 changes: 1 addition & 2 deletions Mopy/bash/patcher/patchers/races_multitweaks.py
Expand Up @@ -300,8 +300,7 @@ def tweak_record(self, record):
class RaceRecordsPatcher(AMultiTweaker, ListPatcher):
"""Race patcher - we inherit from AMultiTweaker to use tweak_instances."""
patcher_group = u'Special'
scanOrder = 40
editOrder = 40
patcher_order = 40
_read_write_records = ('RACE', 'EYES', 'HAIR', 'NPC_',)
_tweak_classes = [RaceTweaker_BiggerOrcsAndNords,
RaceTweaker_MergeSimilarRaceHairs, RaceTweaker_MergeSimilarRaceEyes,
Expand Down
9 changes: 3 additions & 6 deletions Mopy/bash/patcher/patchers/special.py
Expand Up @@ -34,8 +34,7 @@
class _AListsMerger(ListPatcher):
"""Merges lists of objects, e.g. leveled lists or FormID lists."""
patcher_group = u'Special'
scanOrder = 45
editOrder = 45
patcher_order = 45
iiMode = True
# De/Re Tags - None means the patcher does not have such a tag
_de_tag = None
Expand Down Expand Up @@ -300,8 +299,7 @@ def _get_entries(self, target_list):
#------------------------------------------------------------------------------
class FormIDListsPatcher(_AListsMerger):
"""Merges FormID lists."""
scanOrder = 46
editOrder = 46
patcher_order = 46
_read_write_records = (b'FLST',)
_de_tag = u'Deflst'
_type_to_label = {'FLST': _(u'FormID')}
Expand All @@ -315,8 +313,7 @@ class ContentsCheckerPatcher(Patcher):
"""Checks contents of leveled lists, inventories and containers for
correct content types."""
patcher_group = u'Special'
scanOrder = 50
editOrder = 50
patcher_order = 50
contType_entryTypes = bush.game.cc_valid_types
contTypes = set(contType_entryTypes)
entryTypes = set(chain.from_iterable(contType_entryTypes.itervalues()))
Expand Down

0 comments on commit 8a9b581

Please sign in to comment.