Skip to content

Commit

Permalink
- Fixed issue where FOMOD installers that define install files that d…
Browse files Browse the repository at this point in the history
…on't match the casing of the actual file were failing to install sometimes (#10).

- Fixed issue where FOMOD installers that map source folders to an empty destination would cause plugins to be imported with a leading slash (#11).
- Updated README to note that 7-Zip is a required dependency (#12).
  • Loading branch information
lVlyke committed May 28, 2024
1 parent 7627ddd commit c1deea1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Starfield Mod Loader supports the following games:

To install Starfield Mod Loader, simply download the latest release from the [releases page](https://github.com/lVlyke/starfield-mod-loader/releases) and extract the archive to a folder of your choice.

**Note:** [7-Zip](https://www.7-zip.org/) is required to be installed in order to add mods that use RAR archives.

To enable mods in Starfield, add the following lines to the `StarfieldCustom.ini` file in your `Documents/My Games/Starfield` folder if not already present:

```ini
Expand Down
28 changes: 15 additions & 13 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -1174,36 +1174,38 @@ class ElectronLoader {

if (modFilePathMapFilter) {
// Check if a mapping entry exists for the current file path
const mappedEntry = Object.entries(modFilePathMapFilter).find(([pathMapSrc]) => {
pathMapSrc = this.#expandPath(pathMapSrc);
const mappedEntry = Object.entries(modFilePathMapFilter).find(([pathMapSrcRaw]) => {
let pathMapSrcNorm = this.#expandPath(pathMapSrcRaw).toLowerCase();

if (!pathMapSrc.startsWith(modSubdirRoot)) {
pathMapSrc = path.join(modSubdirRoot, pathMapSrc);
if (!pathMapSrcNorm.startsWith(modSubdirRoot.toLowerCase())) {
pathMapSrcNorm = path.join(modSubdirRoot, pathMapSrcNorm).toLowerCase();
}

// Check if the mapping src is a direct match for the file
if (fileEntry.filePath === pathMapSrc) {
if (fileEntry.filePath.toLowerCase() === pathMapSrcNorm) {
return true;
}

if (!pathMapSrc.endsWith(path.sep)) {
pathMapSrc += path.sep;
if (!pathMapSrcNorm.endsWith(path.sep)) {
pathMapSrcNorm += path.sep;
}

// Check if the file is inside the mapping src dir
return fileEntry.filePath.startsWith(pathMapSrc);
return fileEntry.filePath.toLowerCase().startsWith(pathMapSrcNorm);
});
fileEntry.enabled = !!mappedEntry;

if (mappedEntry) {
const mappedSrcPath = this.#expandPath(mappedEntry[0]);
const mappedDestPath = this.#expandPath(mappedEntry[1].replace(/^[Dd]ata[\\/]/, ""));
// Map the file path to the destination path, excluding any root data dir
fileEntry.mappedFilePath = fileEntry.filePath.replace(
this.#expandPath(mappedEntry[0]),
this.#expandPath(mappedEntry[1].replace(/^[Dd]ata[\\/]/, ""))
);
if (fileEntry.filePath.toLowerCase().startsWith(mappedSrcPath.toLowerCase())) {
fileEntry.mappedFilePath = `${mappedDestPath}${fileEntry.filePath.substring(mappedSrcPath.length)}`;
fileEntry.mappedFilePath = fileEntry.mappedFilePath.replace(/^[/\\]+/, "");
}
}
} else {
fileEntry.enabled = fileEntry.enabled && fileEntry.filePath.startsWith(modSubdirRoot);
fileEntry.enabled = fileEntry.enabled && fileEntry.filePath.toLowerCase().startsWith(modSubdirRoot.toLowerCase());
}

if (fileEntry.enabled) {
Expand Down

0 comments on commit c1deea1

Please sign in to comment.