mirror of
https://github.com/d07RiV/diabloweb.git
synced 2026-07-03 11:51:35 +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",
|
"name": "diabloweb",
|
||||||
"version": "1.0.11",
|
"version": "1.0.13",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "diabloweb",
|
"name": "diabloweb",
|
||||||
"version": "1.0.11",
|
"version": "1.0.13",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "7.4.3",
|
"@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;
|
audioTransfer = null;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} 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;
|
files = data.files;
|
||||||
init_game(data.mpq, data.spawn, data.offscreen).then(
|
init_game(data.mpq, data.spawn, data.offscreen).then(
|
||||||
() => worker.postMessage({action: "loaded"}),
|
() => 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;
|
break;
|
||||||
case "event":
|
case "event":
|
||||||
call_api(data.func, ...data.params);
|
call_api(data.func, ...data.params);
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ async function do_load_game(api, audio, mpq) {
|
|||||||
api.openKeyboard(data.open);
|
api.openKeyboard(data.open);
|
||||||
break;
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
|
audio.stop_all();
|
||||||
api.onError(data.error, data.stack);
|
api.onError(data.error, data.stack);
|
||||||
break;
|
break;
|
||||||
case "failed":
|
case "failed":
|
||||||
|
|||||||
@@ -15,11 +15,18 @@ export default function init_sound() {
|
|||||||
return no_sound();
|
return no_sound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const context = new AudioContext();
|
let context = null;
|
||||||
|
try {
|
||||||
|
context = new AudioContext();
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
const sounds = new Map();
|
const sounds = new Map();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
create_sound(id, data, length, channels, rate) {
|
create_sound(id, data, length, channels, rate) {
|
||||||
|
if (!context) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const buffer = context.createBuffer(channels, length, rate);
|
const buffer = context.createBuffer(channels, length, rate);
|
||||||
for (let i = 0; i < channels; ++i) {
|
for (let i = 0; i < channels; ++i) {
|
||||||
buffer.copyToChannel(data.subarray(i * length, i * length + length), i);
|
buffer.copyToChannel(data.subarray(i * length, i * length + length), i);
|
||||||
@@ -31,6 +38,9 @@ export default function init_sound() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
duplicate_sound(id, srcId) {
|
duplicate_sound(id, srcId) {
|
||||||
|
if (!context) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const src = sounds.get(srcId);
|
const src = sounds.get(srcId);
|
||||||
if (!src) {
|
if (!src) {
|
||||||
return;
|
return;
|
||||||
@@ -77,5 +87,15 @@ export default function init_sound() {
|
|||||||
}
|
}
|
||||||
sounds.delete(id);
|
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