Skip to content

Commit

Permalink
Emscripten: shell.html: Fix additional data package loading
Browse files Browse the repository at this point in the history
Must use a global Module var to store the config, as the generated file packager scripts rely on it
  • Loading branch information
past-due committed Jun 30, 2024
1 parent 61d8b9b commit e652c64
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions platforms/emscripten/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ <h1 class="modal-title fs-5" id="refreshForUpdateLabel">Update Required</h1>
'debug_3d': 'launchOption_Debug3D'
}

var Module; // populated once setting up to start game - must be a global for the additional data package scripts to find it (music, etc)
var LaunchedModule; // set once createWZModule succeeds
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
Expand Down Expand Up @@ -1249,12 +1250,9 @@ <h1 class="modal-title fs-5" id="refreshForUpdateLabel">Update Required</h1>
wz_js_display_loading_indicator(1);
window.wz_starting_game = true;

function actuallyStartGame(additional_command_line_args) {
function actuallyStartGame(Module) {
setTimeout( function() {

// customize initial Module config
let Module = constructWZModuleConfig(additional_command_line_args);

// try to create WebAssembly.Memory
let {wasmMemory, maximumMemory} = allocateWZWasmMemory();
Module["wasmMemory"] = wasmMemory;
Expand Down Expand Up @@ -1298,18 +1296,20 @@ <h1 class="modal-title fs-5" id="refreshForUpdateLabel">Update Required</h1>
}, 10);
}

var WZ_LAUNCH_OPTIONS = {};
// customize initial Module config
Module = constructWZModuleConfig();

let WZ_LAUNCH_OPTIONS = {};
Object.entries(WZ_LAUNCH_OPTIONS_MAPPING).forEach(([k,v]) => {
WZ_LAUNCH_OPTIONS[k] = document.getElementById(v)?.checked;
})
wz_save_launch_options();
var data_load_promises = [];
let data_load_promises = [];

// additional debug flags
var additional_command_line_args = [];
Object.entries(WZ_LAUNCH_OPTIONS).forEach(([k,v]) => {
if (k.startsWith('debug_') && v) {
additional_command_line_args.push('--debug='+k.substring(k.indexOf('_') + 1));
Module.arguments.push('--debug='+k.substring(k.indexOf('_') + 1));
}
})

Expand Down Expand Up @@ -1339,7 +1339,7 @@ <h1 class="modal-title fs-5" id="refreshForUpdateLabel">Update Required</h1>
console.error('Failed to load at least one required data file');
return;
}
actuallyStartGame(additional_command_line_args);
actuallyStartGame(Module);
});
}

Expand Down

0 comments on commit e652c64

Please sign in to comment.