z-edit / zedit-unified-patching-framework

A zEdit module which provides a framework for dynamic patch generation, similar to SkyProc/SUM.
MIT License
14 stars 3 forks source link

Patchers apply to other game modes. #18

Open mrudat opened 4 years ago

mrudat commented 4 years ago

I've got a patcher that supports only gmFO4, but it is allowed to (attempt, and fail) to be applied to gmSSE and gmTES5.

I figure it should either be hidden entirely, given that it does not apply to the game mode at all, or it should be marked in red, similar to the patchers that do not have their required mods installed.

mrudat commented 4 years ago

Session with expected behaviour:

================================================================================
Session started at Sun May 17 2020 22:35:37 GMT+1000 (Australian Eastern Standard Time)

[INFO] zEdit v0.6.5 x64
...
[INFO] Modules loaded
[INFO] User selected profile: Fallout 4
[INFO] Using game mode: gmFO4
[INFO] DataPath: E:\Program Files (x86)\Steam\steamapps\common\Fallout 4\data\
[INFO] AppDataPath: C:\Users\Martin Rudat\AppData\Local\Fallout4\
[INFO] MyGamesPath: C:\Users\Martin Rudat\Documents\My Games\Fallout4\
[INFO] GameIniPath: C:\Users\Martin Rudat\Documents\My Games\Fallout4\Fallout4.ini
[INFO] Loading deferred modules...

Session with unexpected behaviour:

================================================================================
Session started at Sun May 17 2020 22:33:40 GMT+1000 (Australian Eastern Standard Time)

[INFO] zEdit v0.6.5 x64
[INFO] Initializing xelib with "E:\Games\zEdit\XEditLib.dll"
[INFO] xelib v0.6.0.0 initialized successfully
[INFO] xelib working directory: "E:\Games\zEdit\"
[INFO] Loading modules...
[INFO] Loading module itemTypeService v1.9.0
[INFO] Loading module referencesServices v0.0.1
[INFO] Loading module skyrimKeywordHelpers v1.0
[INFO] Loading module unifiedPatchingFramework v1.5.1
[INFO] Loading module skyrimMaterialPatcher v1.0.0
[INFO] Modules loaded
[INFO] Loading deferred modules...
[INFO] Loading module aCastOfThousands v0.0.1
...
[INFO] Loading module theJoyOfPerspective v0.0.1
[INFO] Deferred modules loaded
[INFO] User selected profile: Fallout 4
[INFO] Using game mode: gmFO4

It looks like sometimes the profile gets selected after the deferred modules are loaded, and usually before. I'm supplying the profile on the command line (I'm launching zEdit from MO2, so I know for certain what profile I want to load).

mrudat commented 4 years ago

This doesn't fix why it's not working, but it does make the problem go away without restarting repeatedly:

     this.reloadPatchers = function() {
         let patcherIds = patchers.map(patcher => patcher.info.id);
         patchers = [];
         patcherIds.forEach(id => {
             let patcherPath = fh.jetpack.path(`modules\\${id}`);
             moduleService.loadModule(patcherPath);
         });
+        this.updateForGameMode();
     };

     this.updateForGameMode = function(gameMode) {
+        if (gameMode) this.gameMode = gameMode;
+        if (this.gameMode) gameMode = this.gameMode;
         patchers = patchers.filter(patcher => {
             return patcher.gameModes.includes(gameMode);
         });
     };