fix multiplayer crash #77

This commit is contained in:
d07riv
2019-08-18 02:45:44 +03:00
parent 91e26bd4fe
commit d922765878
4 changed files with 20 additions and 15 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "diabloweb",
"version": "1.0.33",
"version": "1.0.34",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "diabloweb",
"version": "1.0.33",
"version": "1.0.34",
"private": true,
"dependencies": {
"@babel/core": "7.4.3",

View File

@@ -19,7 +19,7 @@ if (process.env.NODE_ENV === 'production') {
}
function reportLink(e, retail) {
const message = e.stack || e.message || "Unknown error";
const message = (e.message || "Unknown error") + (e.stack ? "\n" + e.stack : "");
const url = new URL("https://github.com/d07RiV/diabloweb/issues/new");
url.searchParams.set("body",
`**Description:**

View File

@@ -287,9 +287,12 @@ function try_api(func) {
function call_api(func, ...params) {
try_api(() => {
audioBatch = [];
audioTransfer = [];
packetBatch = [];
const nested = (audioBatch != null);
if (!nested) {
audioBatch = [];
audioTransfer = [];
packetBatch = [];
}
if (func !== "text") {
wasm["_" + func](...params);
} else {
@@ -303,16 +306,18 @@ function call_api(func, ...params) {
heap[ptr + length] = 0;
wasm._DApi_SyncText(params[1]);
}
if (audioBatch.length) {
maxSoundId = maxBatchId;
worker.postMessage({action: "audioBatch", batch: audioBatch}, audioTransfer);
if (!nested) {
if (audioBatch.length) {
maxSoundId = maxBatchId;
worker.postMessage({action: "audioBatch", batch: audioBatch}, audioTransfer);
}
if (packetBatch.length) {
worker.postMessage({action: "packetBatch", batch: packetBatch}, packetBatch);
}
audioBatch = null;
audioTransfer = null;
packetBatch = null;
}
if (packetBatch.length) {
worker.postMessage({action: "packetBatch", batch: packetBatch}, packetBatch);
}
audioBatch = null;
audioTransfer = null;
packetBatch = null;
});
}