NearInfinityBrowser / NearInfinity

An Infinity Engine Browser and Editor
GNU Lesser General Public License v2.1
85 stars 37 forks source link

Expand unused file search logic #184

Open ColossusChang opened 3 weeks ago

ColossusChang commented 3 weeks ago

Currently the "Unused File" search only checks whether the files themselves are unused/unreferenced.

However, it would be logical to also consider a file to be unused, if all uses of that file are in files that are themselves unused.

For example, as of v2.4-20240424, in "Baldur's Gate: Siege of Dragonspear v2.6.6.0", LENORE.DLG is not considered unused. However, it is only used in LENORE.CRE. Since LENORE.CRE is unused, LENORE.DLG should also be considered unused.

Argent77 commented 3 weeks ago

Expanding the feature like this would introduce several issues:

  1. It would increase the complexity of the search exponentially.
  2. It would also produce many false positives since usage of a good number of game resources is hardcoded in the game executable. These resources would be erroneously marked as 'unused' even though they are referenced by the game.
  3. There is no safe way to decide when to stop the search since many chains of resource references will encounter a dead end eventually even though they are accessible in the game (see point 2).

The current implementation may not be exhaustive but it should produce the most accurate result under the given circumstances.