Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wine plugin "Override DLL" #1152

Merged
merged 1 commit into from
Dec 24, 2019
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
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
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