mirror of
https://github.com/d07RiV/diabloweb.git
synced 2026-06-03 21:41:38 +00:00
fix quests loading in shareware
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "diabloweb",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.13",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "diabloweb",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.13",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/core": "7.4.3",
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -191,7 +191,10 @@ function call_api(func, ...params) {
|
||||
audioTransfer = null;
|
||||
}
|
||||
} catch (e) {
|
||||
worker.postMessage({action: "error", error: e.message || (e.constructor && e.constructor.name), stack: e.stack});
|
||||
if (typeof e === "string") {
|
||||
worker.postMessage({action: ""})
|
||||
}
|
||||
worker.postMessage({action: "error", error: e.toString(), stack: e.stack});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +277,7 @@ worker.addEventListener("message", ({data}) => {
|
||||
files = data.files;
|
||||
init_game(data.mpq, data.spawn, data.offscreen).then(
|
||||
() => worker.postMessage({action: "loaded"}),
|
||||
e => worker.postMessage({action: "failed", error: e.message || e.name || (e.constructor && e.constructor.name), stack: e.stack}));
|
||||
e => worker.postMessage({action: "failed", error: e.toString(), stack: e.stack}));
|
||||
break;
|
||||
case "event":
|
||||
call_api(data.func, ...data.params);
|
||||
|
||||
@@ -94,6 +94,7 @@ async function do_load_game(api, audio, mpq) {
|
||||
api.openKeyboard(data.open);
|
||||
break;
|
||||
case "error":
|
||||
audio.stop_all();
|
||||
api.onError(data.error, data.stack);
|
||||
break;
|
||||
case "failed":
|
||||
|
||||
@@ -15,11 +15,18 @@ export default function init_sound() {
|
||||
return no_sound();
|
||||
}
|
||||
|
||||
const context = new AudioContext();
|
||||
let context = null;
|
||||
try {
|
||||
context = new AudioContext();
|
||||
} catch (e) {
|
||||
}
|
||||
const sounds = new Map();
|
||||
|
||||
return {
|
||||
create_sound(id, data, length, channels, rate) {
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
const buffer = context.createBuffer(channels, length, rate);
|
||||
for (let i = 0; i < channels; ++i) {
|
||||
buffer.copyToChannel(data.subarray(i * length, i * length + length), i);
|
||||
@@ -31,6 +38,9 @@ export default function init_sound() {
|
||||
});
|
||||
},
|
||||
duplicate_sound(id, srcId) {
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
const src = sounds.get(srcId);
|
||||
if (!src) {
|
||||
return;
|
||||
@@ -77,5 +87,15 @@ export default function init_sound() {
|
||||
}
|
||||
sounds.delete(id);
|
||||
},
|
||||
|
||||
stop_all() {
|
||||
for (let [, sound] of sounds) {
|
||||
if (sound.source) {
|
||||
sound.source.stop();
|
||||
}
|
||||
}
|
||||
sounds.clear();
|
||||
context = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user