skyrim-multiplayer / skymp

Multiplayer Mod & TypeScript SDK for Skyrim Special Edition
Other
220 stars 74 forks source link

[Bug]: Hot-reload works in an unexpected way when using Mod Organizer 2 #765

Open rzkyif opened 2 years ago

rzkyif commented 2 years ago

Severity

Major. A crucial error that indicates a deviation from business logic or disrupts the program, but doesn't have a vital impact on the app.

Priority

Medium. Anything that negatively affects the user experience.

Description

For users who use Mod Organizer 2, Skyrim Platform only watches certain plugin files and setting files for hot-reloading:

  1. Plugin files and setting files that are in the Platform/Plugins folder of the first mod in the mod list that includes a Platform/Plugins folder.
  2. Plugin files and setting files that are in the Platform/PluginsDev folder of the first mod in the mod list that includes a Platform/PluginsDev folder.

For the above conditions, the Overwrite folder is also counted as a mod. Because it is always the last mod in the mod list, if any mod before it includes a Platform/Plugins folder, then plugin files and setting files in it's Platform/Plugins folder will not be watched for hot-reloading. This also applies for Platform/PluginsDev folders.

The above conditions apply even if the first mod in the mod lists that includes a Platform/Plugins or Platform/PluginsDev folder has those folders as empty folders. When it's like this, plugin files and setting files in every mod after it will also not be watched for hot-reloading.

OS

Windows

OS version

10

Skyrim version

1.5.97

SKSE version

2.0.20

client commit''s hash

83cccd6d5b91149f45ab0169b30087fac56cfae6

server commit''s hash

N/A

Videocard model

Geforce GTX 1050 Ti

Steps to reproduce

Say we have four mods (A, B, C, and D) and an Overwrite folder with the following structure and the same order in the mod list:

/A/
  /Platform/
           /Plugins/
                   /A-settings.txt
/B/
  /Platform/
           /PluginsDev/
/C/
  /Platform/
           /Plugins/
                   /C.js
                   /C-settings.txt
/D/
  /Platform/
           /PluginsDev/
                      /D.js
                      /D-settings.txt
/Overwrite/
          /Platform/
                   /Plugins/
                           /X.js

Expected result

Editing any of the following files should initiate plugin hot-reloading:

Actual result

Editing the following files actually initiates plugin hot-reloading:

While editing the following files doesn't initiate any plugin hot-reloading:

Note that after plugin hot-reloading is actually initiated (e.g. by editing A-settings.txt), all of the files above are detected and loaded by Skyrim Platform.

Pospelove commented 2 years ago

Thanks for posting the detailed explanation. I think FindFirstChangeNotificationW doesn't work well under MO2.

https://github.com/skyrim-multiplayer/skymp/blob/main/skyrim-platform/src/platform_se/skyrim_platform/DirectoryMonitor.cpp#L8

We can rewrite WaitForNextUpdate to poll filesystem periodically instead of waiting for the event.

Pospelove commented 2 years ago

https://github.com/skyrim-multiplayer/skymp/blob/bd74404b40e2015327134be671d009ea10366b53/skyrim-platform/src/platform_se/skyrim_platform/SkyrimPlatform.cpp#L277

Pospelove commented 2 years ago

We should discuss this problem with MO2 authors. Maybe they know if we can get FindFirstChangeNotificationW to work in this case.