Skip to content

Commit

Permalink
Merge pull request #109 from aschmitz/patch-1
Browse files Browse the repository at this point in the history
fix: don't double-load chd files for chd-based items
  • Loading branch information
db48x authored Oct 1, 2023
2 parents 6b318f0 + bfc5402 commit 3195735
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,15 @@ var Module = null;

function get_mame_files(cfgr, metadata, modulecfg, filelist) {
var files = [],
bios_files = modulecfg['bios_filenames'];
bios_files = modulecfg['bios_filenames'],
already_fetched_urls = [];
bios_files.forEach(function (fname, i) {
if (fname) {
var title = "Bios File ("+ (i+1) +" of "+ bios_files.length +")";
var url = get_bios_url(fname);
files.push(cfgr.mountFile('/'+ fname,
cfgr.fetchFile(title,
get_bios_url(fname))));
cfgr.fetchFile(title, url)));
already_fetched_urls.push(url);
}
});

Expand All @@ -421,6 +423,7 @@ var Module = null;
: get_zip_url(filename, get_item_name(game));
files.push(cfgr.mountFile('/'+ filename,
cfgr.fetchFile(title, url)));
already_fetched_urls.push(url);
});

// add on game drive (.chd) files, if any
Expand All @@ -431,8 +434,10 @@ var Module = null;
var title = "Game Drive ("+ (i+1) +" of "+ len +")";
var url = (file.name.includes("/")) ? get_zip_url(file.name)
: get_zip_url(file.name, get_item_name(game));
files.push(cfgr.mountFile(modulecfg.driver + '/' + file.name,
cfgr.fetchFile(title, url)));
if (!already_fetched_urls.includes(url)) {
files.push(cfgr.mountFile(modulecfg.driver + '/' + file.name,
cfgr.fetchFile(title, url)));
}
});

Object.keys(peripherals).forEach(function (periph) {
Expand Down

0 comments on commit 3195735

Please sign in to comment.