@@ -93,29 +93,21 @@ def _overhaul_compat(self, mods, _skip_id):
9393 self .OverhaulUOPSkips = set ()
9494
9595class ListsMerger (_AListsMerger , ListPatcher ):
96+ _read_write_records = bush .game .listTypes # bush.game must be set!
9697
9798 #--Patch Phase ------------------------------------------------------------
9899 def initPatchFile (self , patchFile ):
99100 super (ListsMerger , self ).initPatchFile (patchFile )
100101 self .srcs_ordered = self .srcs
101102 self .srcs = set (self .srcs ) & patchFile .loadSet
102- self .listTypes = bush .game .listTypes
103- self .type_list = dict ([(type ,{}) for type in self .listTypes ])
103+ self .type_list = dict ([(rec , {}) for rec in self ._read_write_records ])
104104 self .masterItems = {}
105105 self .mastersScanned = set ()
106106 self .levelers = None #--Will initialize later
107107 self .empties = set ()
108108 _skip_id = lambda x : (GPath (u'Oblivion.esm' ), x )
109109 self ._overhaul_compat (self .srcs , _skip_id )
110110
111- def getReadClasses (self ):
112- """Returns load factory classes needed for reading."""
113- return self .listTypes
114-
115- def getWriteClasses (self ):
116- """Returns load factory classes needed for writing."""
117- return self .listTypes
118-
119111 def scanModFile (self , modFile , progress ):
120112 """Add lists from modFile."""
121113 #--Level Masters (complete initialization)
@@ -127,10 +119,10 @@ def scanModFile(self, modFile, progress):
127119 self .delevMasters .update (bosh .modInfos [leveler ].get_masters ())
128120 #--Begin regular scan
129121 modName = modFile .fileInfo .name
130- modFile .convertToLongFids (self .listTypes )
122+ modFile .convertToLongFids (self ._read_write_records )
131123 #--PreScan for later Relevs/Delevs?
132124 if modName in self .delevMasters :
133- for list_type in self .listTypes :
125+ for list_type in self ._read_write_records :
134126 for levList in getattr (modFile ,list_type ).getActiveRecords ():
135127 masterItems = self .masterItems .setdefault (levList .fid ,{})
136128 masterItems [modName ] = set (
@@ -141,7 +133,7 @@ def scanModFile(self, modFile, progress):
141133 isRelev = (u'Relev' in configChoice )
142134 isDelev = (u'Delev' in configChoice )
143135 #--Scan
144- for list_type in self .listTypes :
136+ for list_type in self ._read_write_records :
145137 levLists = self .type_list [list_type ]
146138 newLevLists = getattr (modFile ,list_type )
147139 for newLevList in newLevLists .getActiveRecords ():
@@ -190,7 +182,7 @@ def buildPatch(self,log,progress):
190182 #--Save to patch file
191183 for label , type in ((_ (u'Creature' ), 'LVLC' ), (_ (u'Actor' ), 'LVLN' ),
192184 (_ (u'Item' ), 'LVLI' ), (_ (u'Spell' ), 'LVSP' )):
193- if type not in self .listTypes : continue
185+ if type not in self ._read_write_records : continue
194186 log .setHeader (u'=== ' + _ (u'Merged %s Lists' ) % label )
195187 patchBlock = getattr (self .patchFile ,type )
196188 levLists = self .type_list [type ]
@@ -210,7 +202,7 @@ def buildPatch(self,log,progress):
210202 if not self .remove_empty_sublists : return
211203 for label , type in ((_ (u'Creature' ), 'LVLC' ), (_ (u'Actor' ), 'LVLN' ),
212204 (_ (u'Item' ), 'LVLI' ), (_ (u'Spell' ), 'LVSP' )):
213- if type not in self .listTypes : continue
205+ if type not in self ._read_write_records : continue
214206 patchBlock = getattr (self .patchFile ,type )
215207 levLists = self .type_list [type ]
216208 #--Empty lists
@@ -465,27 +457,19 @@ class FidListsMerger(_AListsMerger,ListPatcher):
465457 tip = _ (u"Merges changes to formid lists from all active mods." )
466458 autoKey = {u'Deflst' }
467459 iiMode = True
460+ _read_write_records = ('FLST' ,)
468461
469462 #--Patch Phase ------------------------------------------------------------
470463 def initPatchFile (self , patchFile ):
471464 """Prepare to handle specified patch mod. All functions are called
472465 after this."""
473466 super (FidListsMerger , self ).initPatchFile (patchFile )
474467 self .srcMods = set (self .getConfigChecked ()) & patchFile .loadSet
475- self .listTypes = ('FLST' ,)
476- self .type_list = dict ([(type ,{}) for type in self .listTypes ])
468+ self .type_list = dict ([(rec , {}) for rec in self ._read_write_records ])
477469 self .masterItems = {}
478470 self .mastersScanned = set ()
479471 self .levelers = None #--Will initialize later
480472
481- def getReadClasses (self ):
482- """Returns load factory classes needed for reading."""
483- return self .listTypes
484-
485- def getWriteClasses (self ):
486- """Returns load factory classes needed for writing."""
487- return self .listTypes
488-
489473 def scanModFile (self , modFile , progress ):
490474 """Add lists from modFile."""
491475 #--Level Masters (complete initialization)
@@ -497,10 +481,10 @@ def scanModFile(self, modFile, progress):
497481 self .deflstMasters .update (bosh .modInfos [leveler ].get_masters ())
498482 #--Begin regular scan
499483 modName = modFile .fileInfo .name
500- modFile .convertToLongFids (self .listTypes )
484+ modFile .convertToLongFids (self ._read_write_records )
501485 #--PreScan for later Deflsts?
502486 if modName in self .deflstMasters :
503- for list_type in self .listTypes :
487+ for list_type in self ._read_write_records :
504488 for levList in getattr (modFile ,list_type ).getActiveRecords ():
505489 masterItems = self .masterItems .setdefault (levList .fid ,{})
506490 # masterItems[modName] = set([entry.listId for entry in levList.entries])
@@ -510,7 +494,7 @@ def scanModFile(self, modFile, progress):
510494 configChoice = self .configChoices .get (modName ,tuple ())
511495 isDeflst = (u'Deflst' in configChoice )
512496 #--Scan
513- for list_type in self .listTypes :
497+ for list_type in self ._read_write_records :
514498 levLists = self .type_list [list_type ]
515499 newLevLists = getattr (modFile ,list_type )
516500 for newLevList in newLevLists .getActiveRecords ():
0 commit comments