Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Engines/Wine/Plugins/override DLL/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ const Regedit = include("engines.wine.plugins.regedit");
module.default = class OverrideDLL {
constructor(wine) {
this.wine = wine;
this.modes = {};
this.modes = new Map();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed a Map is a better choice here.

}

withMode(mode, libraries) {
this.modes[mode] = libraries;
this.modes.set(mode, libraries);

return this;
}

go() {
let regeditFileContent = `REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides]\n`;

Object.entries(this.modes)
.map(([mode, libraries]) => libraries.map(library => [library, mode]))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a sidenot, I think the following change would be enough to fix the issue but I agree that your code is more readable:

.flatMap(([mode, libraries]) => libraries.map(library => [library, mode]))

.forEach(([library, mode]) => {
regeditFileContent += `"*${library}"="${mode}"\n`;
});
this.modes.forEach((libraries, mode) =>
libraries.forEach(library => regeditFileContent += `"*${library}"="${mode}"\n`)
);

new Regedit(this.wine).patch(regeditFileContent);
}
Expand Down